From 7cef5d2545d97041978e2ba71ddcc4e3ea76fa86 Mon Sep 17 00:00:00 2001 From: Michal Kleiner Date: Sun, 21 May 2023 22:32:38 +1200 Subject: [PATCH 1/2] Use curly brackets for translation placeholders instead of sprintf style --- lang/en.yml | 4 ++-- src/Models/TaxonomyTerm.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lang/en.yml b/lang/en.yml index 430322b..dab7ec2 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -9,9 +9,9 @@ en: PublicDefinition_Description: 'Shown to users on the front-end; a brief definition of the term for those who view taxonomy terms as tags or filters.' URLSegment_Description: 'A unique identifier used by the CMS (e.g. in URL filter parameters), which must be unique across all terms and taxonomies. It will be automatically generated from Name, if left blank. Use lower case, URL-safe characters, no spaces. Avoid parentheses. Required.' InternalOnly_Description: 'When enabled, the taxonomy will be available for tagging by authors, and in various CMS configuration settings, but won’t be shown or made directly accessible to users. If disabled, the terms in this taxonomy will be displayed throughout the site as tags, labels and within filter options (e.g. during the listing and searching of content).' - SingleSelect_Checked_Readonly_Description: 'This taxonomy has been permanently configured to prevent more than one term being tagged to any individual content item. Typically, this is due to the mutually exclusive nature of the terms. If you wish to enable multi-select, all tags from the taxonomy must be removed from all content (not recommended). Currently, at least one %s has been tagged, possibly others. You might want to consider creating a new taxonomy instead.' + SingleSelect_Checked_Readonly_Description: 'This taxonomy has been permanently configured to prevent more than one term being tagged to any individual content item. Typically, this is due to the mutually exclusive nature of the terms. If you wish to enable multi-select, all tags from the taxonomy must be removed from all content (not recommended). Currently, at least one {taggedClass} has been tagged, possibly others. You might want to consider creating a new taxonomy instead.' SingleSelect_Checked_Description: 'This taxonomy has been configured to prevent more than one term being tagged to any individual content item. Typically, this is due to the mutually exclusive nature of the terms. As soon as any term from the associated taxonomy is tagged to any content item, this option will become permanently set. As none of the terms have yet been used as tags, you can still disable this option.' - SingleSelect_Readonly_Description: 'This taxonomy type has been permanently configured to allow more than one term to be tagged to any individual content item. Typically, this is due to the synergistic nature of the terms. If you wish to enable single select, all tags from this taxonomy must be removed from all content (not recommended). Currently, at least one %s has been tagged, possibly others. You might want to consider creating a new taxonomy instead.' + SingleSelect_Readonly_Description: 'This taxonomy type has been permanently configured to allow more than one term to be tagged to any individual content item. Typically, this is due to the synergistic nature of the terms. If you wish to enable single select, all tags from this taxonomy must be removed from all content (not recommended). Currently, at least one {taggedClass} has been tagged, possibly others. You might want to consider creating a new taxonomy instead.' SingleSelect_Description: 'If your taxonomy includes mutually exclusive terms or concepts, you might want to enable this option. It will restrict authors from applying more than one tag at a time to any individual content item. Caution: once enabled, this option is not intended to be turned off again; once content has been tagged with single select taxonomy terms, this option becomes permanently enabled.' RequiredTypes_Description: 'Required taxonomies will prompt admins to select a term from these other taxonomies, too, when this current term is assigned to a page, block or file etc. If required taxonomies are set on the root term, then all descendant terms will inherit the requirements. Inheritance can be manually overridden, and further requirements set, on individual terms.' Terms_Description: 'This is a flattened (non-hierarchical) list of all the descendant terms within this taxonomy. This is useful when you need a quick view of all the terms, as it saves you navigating through multiple child term screens.' diff --git a/src/Models/TaxonomyTerm.php b/src/Models/TaxonomyTerm.php index e23b116..7ccaa0e 100644 --- a/src/Models/TaxonomyTerm.php +++ b/src/Models/TaxonomyTerm.php @@ -231,9 +231,10 @@ public function getCMSFields() // provide description for different combination of states from the lang file $singleSelectDescription = _t( static::class - . '.SingleSelect' . ($checked ? '_Checked' : '') . ($readonly ? '_Readonly' : '') . '_Description' - ); - $singleSelectField->setDescription(sprintf($singleSelectDescription, $taggedClass)); + . '.SingleSelect' . ($checked ? '_Checked' : '') . ($readonly ? '_Readonly' : '') . '_Description', + null, + ['taggedClass' => $taggedClass]); + $singleSelectField->setDescription($singleSelectDescription); } From 38fa1c28e127f5227919c4f37a2dbd07c5f1af0f Mon Sep 17 00:00:00 2001 From: Michal Kleiner Date: Sun, 21 May 2023 22:32:49 +1200 Subject: [PATCH 2/2] Use config merge instead of update --- src/Models/TaxonomyTerm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/TaxonomyTerm.php b/src/Models/TaxonomyTerm.php index 7ccaa0e..6c9a4f7 100644 --- a/src/Models/TaxonomyTerm.php +++ b/src/Models/TaxonomyTerm.php @@ -143,7 +143,7 @@ public function getCMSFields() $fields->removeByName('DataObjectTaxonomyTerms'); // Begin to use _t(), first disable 'missing_default_warning', which allows _t() to be called without default - i18n::config()->update('missing_default_warning', false); + i18n::config()->merge('missing_default_warning', false); // Define a literalField that presents empty line , and could be reused in many occasionz. $lineBreak = LiteralField::create('LineBreak', '
');