Skip to content

Commit

Permalink
FEATURE field labels and lng file
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Sep 6, 2024
1 parent 4082597 commit 400021d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Empty file added lang/_manifest_exclude
Empty file.
19 changes: 19 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
en:
Dynamic\Locations\Model\Location:
CategoriesLabel: 'Categories'
ContentLabel: 'Description'
LinksLabel: 'Links'
PLURALNAME: 'Locations'
PLURALS:
one: 'A Location'
other: '{count} Locations'
SINGULARNAME: 'Location'
TitleLabel: 'Title'

Dynamic\Locations\Model\LocationCategory:
PLURALNAME: Categories
PLURALS:
one: 'A Cateogry'
other: '{count} Categories'
SINGULARNAME: Category
TitleLabel: 'Title'
19 changes: 19 additions & 0 deletions src/Model/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class Location extends DataObject
AddressDataExtension::class,
];

/**
* create a list of assigned categories
*/
public function getCategoryList()
{
if ($this->Categories()->count()) {
Expand All @@ -118,6 +121,22 @@ public function getCategoryList()
return '';
}

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

$labels['Title'] = _t(__CLASS__ . '.TitleLabel', 'Title');
$labels['Content'] = _t(__CLASS__ . '.ContentLabel', 'Description');
$labels['Links'] = _t(__CLASS__ . '.LinksLabel', 'Links');
$labels['Categories'] = _t(__CLASS__ . '.CategoriesLabel', 'Categories');

return $labels;
}

/**
* @return FieldList
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Model/LocationCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ class LocationCategory extends DataObject
private static array $belongs_many_many = [
'Locations' => Location::class,
];

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

$labels['Title'] = _t(__CLASS__ . '.TitleLabel', 'Title');

return $labels;
}
}

0 comments on commit 400021d

Please sign in to comment.