Skip to content

Commit

Permalink
initial i18n (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish authored May 2, 2019
1 parent 4fabaae commit 1806462
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
Empty file added lang/_manifest_exclude
Empty file.
13 changes: 13 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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)',
'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
Original file line number Diff line number Diff line change
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

0 comments on commit 1806462

Please sign in to comment.