From 400021da78cdede29291167f2f65b2e15727d552 Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Thu, 5 Sep 2024 22:11:42 -0500 Subject: [PATCH] FEATURE field labels and lng file --- lang/_manifest_exclude | 0 lang/en.yml | 19 +++++++++++++++++++ src/Model/Location.php | 19 +++++++++++++++++++ src/Model/LocationCategory.php | 13 +++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 lang/_manifest_exclude create mode 100644 lang/en.yml diff --git a/lang/_manifest_exclude b/lang/_manifest_exclude new file mode 100644 index 0000000..e69de29 diff --git a/lang/en.yml b/lang/en.yml new file mode 100644 index 0000000..369c000 --- /dev/null +++ b/lang/en.yml @@ -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' diff --git a/src/Model/Location.php b/src/Model/Location.php index 03618df..47d3b22 100644 --- a/src/Model/Location.php +++ b/src/Model/Location.php @@ -109,6 +109,9 @@ class Location extends DataObject AddressDataExtension::class, ]; + /** + * create a list of assigned categories + */ public function getCategoryList() { if ($this->Categories()->count()) { @@ -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 */ diff --git a/src/Model/LocationCategory.php b/src/Model/LocationCategory.php index f657285..c6cc750 100644 --- a/src/Model/LocationCategory.php +++ b/src/Model/LocationCategory.php @@ -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; + } }