Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial i18n #18

Merged
merged 2 commits into from May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Empty file added lang/_manifest_exclude
Empty file.
13 changes: 13 additions & 0 deletions lang/en.yml
@@ -0,0 +1,13 @@
en:
Dynamic\Elements\CustomerService\Elements\ElementCustomerService:
BlockType: 'Customer Service'
EmailLabel: 'Email'
FaxLabel: 'Fax'
LocationNameLabel: 'Location Name'
PhoneLabel: 'Phone'
PLURALNAME: 'Customer Service Elements'
PLURALS:
one: 'A Customer Service Element'
other: '{count} Customer Service Elements'
SINGULARNAME: 'Customer Service Element'
WebsiteLabel: 'Website'
38 changes: 23 additions & 15 deletions src/Elements/ElementCustomerService.php
Expand Up @@ -24,16 +24,6 @@ class ElementCustomerService extends BaseElement
*/
private static $icon = 'font-icon-info-circled';

/**
* @var string
*/
private static $singular_name = 'Customer Service Element';

/**
* @var string
*/
private static $plural_name = 'Customer Service Elements';

/**
* @var string
*/
Expand All @@ -43,26 +33,44 @@ class ElementCustomerService extends BaseElement
* @var array
*/
private static $db = [
'Title' => 'Varchar(255)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change require a task to move existing data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data seems to map to both tables

'LocationName' => 'Varchar(255)',
'Website' => 'Varchar(255)',
'Phone' => 'Varchar(40)',
'Email' => 'Varchar(255)',
'Fax' => 'Varchar(45)',
];

/**
* @param bool $includerelations
* @return array
*/
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);

$labels['LocationName'] = _t(__CLASS__.'.LocationNameLabel', 'Location Name');
$labels['Website'] = _t(__CLASS__ . '.WebsiteLabel', 'Website');
$labels['Phone'] = _t(__CLASS__ . '.PhoneLabel', 'Phone');
$labels['Email'] = _t(__CLASS__ . '.EmailLabel', 'Email');
$labels['Fax'] = _t(__CLASS__ . '.FaxLabel', 'Fax');

return $labels;
}

/**
* @return FieldList
*/
public function getCMSFields()
{
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields->dataFieldByName('Title')
->setTitle('Name');

if ($website = $fields->dataFieldByName('Website')) {
$website->setAttribute('placeholder', 'http://');
}
$fields->replaceField('Email', EmailField::create('Email'));
$fields->replaceField(
'Email',
EmailField::create('Email')
->setTitle($this->fieldLabel('Email'))
);
});

return parent::getCMSFields();
Expand Down
Expand Up @@ -11,7 +11,7 @@
<div class="col-sm-12">
<% end_if %>


<% if $LocationName %><h3>$LocationName</h3><% end_if %>
<% if $Address || $Address2 || $City || $State || $PostalCode || $Country %>
<p>
<% if $Address %>$Address<br><% if $Address2 %>$Address2<br><% end_if %><% end_if %>
Expand Down