Skip to content

Commit

Permalink
Updated translation
Browse files Browse the repository at this point in the history
  • Loading branch information
gorriecoe committed Mar 12, 2018
1 parent 60f2acf commit 7bcb7bd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
20 changes: 11 additions & 9 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
en:
gorriecoe\Link\Models\Link:
PLURALNAME: Links
PLURALS:
one: 'A Link'
other: '{count} Links'
SINGULARNAME: Link
link:
gorriecoe\Link\Extensions\DefineableMarkupID:
ID: ID
IDCUSTOMVALUE: 'Define an ID for the link. This is particularly useful for google tracking.'
gorriecoe\Link\Extensions\LinkSiteTree:
ANCHOR: Anchor/Querystring
ANCHORINFO: 'Include # at the start of your anchor name or, ? at the start of your querystring'
DELETEDWARNING: 'Warning: The selected page appears to have been deleted or unpublished. This link may not appear or may be broken in the frontend'
PAGE: Page
gorriecoe\Link\Models\Link:
EMAILADDRESS: 'Email Address'
FILE: File
IDCUSTOMVALUE: 'Define a ID for the link. This is particularly useful for google tracking.'
LINKTYPE: Type
OPENINNEWWINDOW: 'Open link in a new window'
OPTIONALTITLE: 'Optional. Will be auto-generated from link if left blank.'
PAGE: Page
PHONENUMBER: 'Phone Number'
PLURALNAME: Links
PLURALS:
one: 'A Link'
other: '{count} Links'
SINGULARNAME: Link
STYLE: Style
TITLE: Title
URL: URL
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/DefineableMarkupID.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function updateCMSFields(FieldList $fields)
'Root.Main',
TextField::create(
'IDCustomValue',
'ID'
_t(__CLASS__ . '.ID', 'ID')
)
->setDescription(_t('link.IDCUSTOMVALUE', 'Define a ID for the link. This is particularly useful for google tracking.'))
->setDescription(_t(__CLASS__ . '.IDCUSTOMVALUE', 'Define an ID for the link. This is particularly useful for google tracking.'))
);
return $fields;
}
Expand Down
8 changes: 4 additions & 4 deletions src/extensions/LinkSiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public function updateCMSFields(FieldList $fields)
Wrapper::create(
TreeDropdownField::create(
'SiteTreeID',
_t('link.PAGE', 'Page'),
_t(__CLASS__ . '.PAGE', 'Page'),
SiteTree::class
),
TextField::create(
'Anchor',
_t('link.ANCHOR', 'Anchor/Querystring')
_t(__CLASS__ . '.ANCHOR', 'Anchor/Querystring')
)
->setDescription(_t('link.ANCHORINFO', 'Include # at the start of your anchor name or, ? at the start of your querystring'))
->setDescription(_t(__CLASS__ . '.ANCHORINFO', 'Include # at the start of your anchor name or, ? at the start of your querystring'))
)
->displayIf('Type')->isEqualTo('SiteTree')->end()
);
Expand All @@ -73,7 +73,7 @@ public function updateCMSFields(FieldList $fields)
if ($owner->SiteTreeID && !$owner->SiteTree()->isPublished()) {
$fields
->dataFieldByName('SiteTreeID')
->setDescription(_t('link.DELETEDWARNING', 'Warning: The selected page appears to have been deleted or unpublished. This link may not appear or may be broken in the frontend'));
->setDescription(_t(__CLASS__ . '.DELETEDWARNING', 'Warning: The selected page appears to have been deleted or unpublished. This link may not appear or may be broken in the frontend'));
}
}
}
36 changes: 18 additions & 18 deletions src/models/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function getCMSFields()
'Root.Main',
DropdownField::create(
'Style',
_t('link.STYLE', 'Style'),
_t(__CLASS__ . '.STYLE', 'Style'),
$styles
)
->setEmptyString('Default')
Expand All @@ -143,19 +143,19 @@ public function getCMSFields()
[
TextField::create(
'Title',
_t('link.TITLE', 'Title')
_t(__CLASS__ . '.TITLE', 'Title')
)
->setDescription(_t('link.OPTIONALTITLE', 'Optional. Will be auto-generated from link if left blank.')),
->setDescription(_t(__CLASS__ . '.OPTIONALTITLE', 'Optional. Will be auto-generated from link if left blank.')),
OptionsetField::create(
'Type',
_t('link.LINKTYPE', 'Type'),
_t(__CLASS__ . '.LINKTYPE', 'Type'),
$this->i18nTypes
)
->setValue('URL'),
Wrapper::create(
TreeDropdownField::create(
'FileID',
_t('link.FILE', 'File'),
_t(__CLASS__ . '.FILE', 'File'),
File::class,
'ID',
'Title'
Expand All @@ -165,27 +165,27 @@ public function getCMSFields()
Wrapper::create(
TextField::create(
'URL',
_t('link.URL', 'URL')
_t(__CLASS__ . '.URL', 'URL')
)
)
->displayIf("Type")->isEqualTo('URL')->end(),
Wrapper::create(
TextField::create(
'Email',
_t('link.EMAILADDRESS', 'Email Address')
_t(__CLASS__ . '.EMAILADDRESS', 'Email Address')
)
)
->displayIf("Type")->isEqualTo('Email')->end(),
Wrapper::create(
TextField::create(
'Phone',
_t('link.PHONENUMBER', 'Phone Number')
_t(__CLASS__ . '.PHONENUMBER', 'Phone Number')
)
)
->displayIf("Type")->isEqualTo('Phone')->end(),
CheckboxField::create(
'OpenInNewWindow',
_t('link.OPENINNEWWINDOW','Open link in a new window')
_t(__CLASS__ . '.OPENINNEWWINDOW','Open link in a new window')
)
->displayIf('Type')->isEqualTo("URL")
->orIf()->isEqualTo('File')
Expand Down Expand Up @@ -302,7 +302,7 @@ public function geti18nTypes()
$i18nTypes = [];
// Get translatable labels
foreach ($this->Types as $key => $label) {
$i18nTypes[$key] = _t('link.TYPE'.strtoupper($key), $label);
$i18nTypes[$key] = _t(__CLASS__ . '.TYPE'.strtoupper($key), $label);
}
$this->extend('updatei18nTypes', $i18nTypes);
return $i18nTypes;
Expand All @@ -327,7 +327,7 @@ public function geti18nStyles()
{
$i18nStyles = [];
foreach ($this->styles as $key => $label) {
$i18nStyles[$key] = _t('link.STYLE'.strtoupper($key), $label);
$i18nStyles[$key] = _t(__CLASS__ . '.STYLE'.strtoupper($key), $label);
}
$this->extend('updatei18nStyles', $i18nStyles);
return $i18nStyles;
Expand Down Expand Up @@ -363,7 +363,7 @@ public function getLinkURL()
if ($component->hasMethod('Link')) {
$LinkURL = $component->Link() . $this->Anchor;
} else {
$LinkURL = "Please implement a Link() method on your dataobject \"$type\"";
$LinkURL = _t(__CLASS__ . '.LINKMETHODMISSING', "Please implement a Link() method on your dataobject \"$type\"");
}
}
break;
Expand Down Expand Up @@ -447,7 +447,7 @@ public function getIDAttr()
public function getLinkType()
{
$types = $this->config()->get('types');
return isset($types[$this->Type]) ? _t('link.TYPE'.strtoupper($this->Type), $types[$this->Type]) : null;
return isset($types[$this->Type]) ? _t(__CLASS__ . '.TYPE'.strtoupper($this->Type), $types[$this->Type]) : null;
}

/**
Expand Down Expand Up @@ -532,7 +532,7 @@ public function validate()
if ($this->{$type} == '') {
$valid = false;
$message = _t(
'link.VALIDATIONERROR_EMPTY'.strtoupper($type),
__CLASS__ . '.VALIDATIONERROR_EMPTY'.strtoupper($type),
'You must enter a {LinkType}',
[
'LinkType' => $this->LinkType
Expand All @@ -545,7 +545,7 @@ public function validate()
if ($type && empty($this->{$type.'ID'})) {
$valid = false;
$message = _t(
'link.VALIDATIONERROR_OBJECT',
__CLASS__ . '.VALIDATIONERROR_OBJECT',
'Please select a {LinkType}',
[
'LinkType' => $this->LinkType
Expand All @@ -562,7 +562,7 @@ public function validate()
if (!in_array(substr($this->URL, 0, 1), $allowedFirst) && !filter_var($this->URL, FILTER_VALIDATE_URL)) {
$valid = false;
$message = _t(
'link.VALIDATIONERROR_VALIDURL',
__CLASS__ . '.VALIDATIONERROR_VALIDURL',
'Please enter a valid URL. Be sure to include http:// for an external URL. or begin your internal url/anchor with a "/" character'
);
}
Expand All @@ -571,7 +571,7 @@ public function validate()
if (!filter_var($this->Email, FILTER_VALIDATE_EMAIL)) {
$valid = false;
$message = _t(
'link.VALIDATIONERROR_VALIDEMAIL',
__CLASS__ . '.VALIDATIONERROR_VALIDEMAIL',
'Please enter a valid Email address'
);
}
Expand All @@ -580,7 +580,7 @@ public function validate()
if (!preg_match("/^\+?[0-9a-zA-Z\-\s]*[\,\#]?[0-9\-\s]*$/", $this->Phone)) {
$valid = false;
$message = _t(
'link.VALIDATIONERROR_VALIDPHONE',
__CLASS__ . '.VALIDATIONERROR_VALIDPHONE',
'Please enter a valid Phone number'
);
}
Expand Down

0 comments on commit 7bcb7bd

Please sign in to comment.