From 00b465cd03cd6ec3b120dc24121a175f7ad0ee9b Mon Sep 17 00:00:00 2001 From: Yousaf Zaman Date: Tue, 15 Aug 2023 23:55:10 -0700 Subject: [PATCH 1/2] added EN translation file and setup for localization --- src/Plugin.php | 12 ++--- src/fields/strategies/Add.php | 2 +- src/fields/strategies/Divide.php | 2 +- src/fields/strategies/Merge.php | 2 +- src/fields/strategies/Multiply.php | 2 +- src/fields/strategies/Replace.php | 2 +- src/fields/strategies/Subtract.php | 2 +- .../elementactions/BulkEdit/_edit.twig | 8 +-- .../elementactions/BulkEdit/_fields.twig | 27 ++++++---- src/translations/en/bulk-edit.php | 17 ------- src/translations/en/venveo-bulk-edit.php | 50 +++++++++++++++++++ 11 files changed, 82 insertions(+), 44 deletions(-) delete mode 100644 src/translations/en/bulk-edit.php create mode 100644 src/translations/en/venveo-bulk-edit.php diff --git a/src/Plugin.php b/src/Plugin.php index 597fb67..e69996e 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -56,26 +56,26 @@ public function init() Event::on(UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS, function(RegisterUserPermissionsEvent $event) { $permissions = []; $permissions[self::PERMISSION_BULKEDIT_ENTRIES] = [ - 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Entries'), + 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-entries'), ]; $permissions[self::PERMISSION_BULKEDIT_ASSETS] = [ - 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Assets'), + 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-assets'), ]; $permissions[self::PERMISSION_BULKEDIT_CATEGORIES] = [ - 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Categories'), + 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-categories'), ]; $permissions[self::PERMISSION_BULKEDIT_USERS] = [ - 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Users'), + 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-users'), ]; if (Craft::$app->plugins->isPluginInstalled('commerce')) { $permissions[self::PERMISSION_BULKEDIT_PRODUCTS] = [ - 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Products'), + 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-products'), ]; } $event->permissions[] = [ - 'heading' => Craft::t('venveo-bulk-edit', 'Bulk Edit'), + 'heading' => Craft::t('venveo-bulk-edit', 'user-permissons-label'), 'permissions' => $permissions ]; }); diff --git a/src/fields/strategies/Add.php b/src/fields/strategies/Add.php index 7bf109c..c1c4494 100644 --- a/src/fields/strategies/Add.php +++ b/src/fields/strategies/Add.php @@ -9,6 +9,6 @@ class Add implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'Add'); + return Craft::t('venveo-bulk-edit', 'add'); } } diff --git a/src/fields/strategies/Divide.php b/src/fields/strategies/Divide.php index 0c6f7c7..55354a6 100644 --- a/src/fields/strategies/Divide.php +++ b/src/fields/strategies/Divide.php @@ -9,6 +9,6 @@ class Divide implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'Divide'); + return Craft::t('venveo-bulk-edit', 'divide'); } } diff --git a/src/fields/strategies/Merge.php b/src/fields/strategies/Merge.php index 6d5a91b..d5d37ab 100644 --- a/src/fields/strategies/Merge.php +++ b/src/fields/strategies/Merge.php @@ -9,6 +9,6 @@ class Merge implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'Merge'); + return Craft::t('venveo-bulk-edit', 'merge'); } } diff --git a/src/fields/strategies/Multiply.php b/src/fields/strategies/Multiply.php index 7cd3c03..bd5455a 100644 --- a/src/fields/strategies/Multiply.php +++ b/src/fields/strategies/Multiply.php @@ -9,6 +9,6 @@ class Multiply implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'Multiply'); + return Craft::t('venveo-bulk-edit', 'multiply'); } } diff --git a/src/fields/strategies/Replace.php b/src/fields/strategies/Replace.php index 50d6638..d04b5a6 100644 --- a/src/fields/strategies/Replace.php +++ b/src/fields/strategies/Replace.php @@ -9,6 +9,6 @@ class Replace implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'Replace'); + return Craft::t('venveo-bulk-edit', 'replace'); } } diff --git a/src/fields/strategies/Subtract.php b/src/fields/strategies/Subtract.php index 53113f9..063c8cf 100644 --- a/src/fields/strategies/Subtract.php +++ b/src/fields/strategies/Subtract.php @@ -9,6 +9,6 @@ class Subtract implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'Subtract'); + return Craft::t('venveo-bulk-edit', 'subtract'); } } diff --git a/src/templates/elementactions/BulkEdit/_edit.twig b/src/templates/elementactions/BulkEdit/_edit.twig index 06b3e6c..f1fc5ed 100644 --- a/src/templates/elementactions/BulkEdit/_edit.twig +++ b/src/templates/elementactions/BulkEdit/_edit.twig @@ -10,14 +10,14 @@ {% endnamespace %}
-
{{ "Cancel"|t('venveo-bulk-edit') }}
-
+
{{ "cancel"|t('venveo-bulk-edit') }}
+
{% else %} -

{{ "It doesn't look like there are any fields that support bulk editing on these elements."|t('venveo-bulk-edit') }}

+

{{ "edit-fields-warning"|t('venveo-bulk-edit') }}

-
{{ "Cancel"|t('venveo-bulk-edit') }}
+
{{ "cancel"|t('venveo-bulk-edit') }}
{% endif %} diff --git a/src/templates/elementactions/BulkEdit/_fields.twig b/src/templates/elementactions/BulkEdit/_fields.twig index 76463eb..55f0032 100644 --- a/src/templates/elementactions/BulkEdit/_fields.twig +++ b/src/templates/elementactions/BulkEdit/_fields.twig @@ -1,16 +1,21 @@ {% import '_includes/forms' as forms %}
-

{{ "Select Fields"|t('venveo-bulk-edit') }}

-

Editing {{ selectedTotal }} elements on site - {{ site.name }} ({{ site.language }})

+

{{ "select-fields"|t('venveo-bulk-edit') }}

+

+ {{ "fields-desc"|t('venveo-bulk-edit', params = { + site: site.name, + language: site.language, + total: selectedTotal + }) }} +

{% if fieldWrappers|length %}
{{ forms.checkbox({ id: 'bulk-edit-select-all', checked: selectAllChecked, - label: 'Select all ' ~ selectAllTotal ~ ' elements matching current filters', + label: 'chk-select-all-elements'|t('venveo-bulk-edit', params = {total: selectAllTotal}), name: 'selectAll', }) }}
@@ -20,22 +25,22 @@ - Field Name + {{ 'col-field-name'|t('venveo-bulk-edit') }} - Field Handle + {{ 'col-field-handle'|t('venveo-bulk-edit') }} - Edit + {{ 'col-edit'|t('venveo-bulk-edit') }} - Strategy + {{ 'col-strategy'|t('venveo-bulk-edit') }} @@ -82,12 +87,12 @@ {% endif %} {% else %} -

These elements have no associated fields.

+

{{ 'assoc-fields-warning'|t('venveo-bulk-edit') }}

{% endif %}
-
Cancel
- {{ "cancel"|t('venveo-bulk-edit') }}
+
diff --git a/src/translations/en/bulk-edit.php b/src/translations/en/bulk-edit.php deleted file mode 100644 index 92d37e0..0000000 --- a/src/translations/en/bulk-edit.php +++ /dev/null @@ -1,17 +0,0 @@ - 'Cancel', + 'continue' => 'Continue', + + // Strategies + 'add' => 'Add', + 'divide' => 'Divide', + 'merge' => 'Merge', + 'multiply' => 'Multiply', + 'replace' => 'Replace', + 'subtract' => 'Subtract', + + // User Permissions + 'user-permissions-edit-entries' => 'Bulk Edit Entries', + 'user-permissions-edit-assets' => 'Bulk Edit Assets', + 'user-permissions-edit-categories' => 'Bulk Edit Categories', + 'user-permissions-edit-users' => 'Bulk Edit Users', + 'user-permissions-edit-products' => 'Bulk Edit Products', + 'user-permissons-label' => 'Bulk Edit', + + // Select Fields Modal + 'select-fields' => 'Select Fields', + 'fields-desc' => 'Editing {total} elements on site {site} ({language})', + 'col-field-name' => 'Field Name', + 'col-field-handle' => 'Field Handle', + 'col-edit' => 'Edit', + 'col-strategy' => 'Strategy', + 'assoc-fields-warning' => 'These elements have no associated fields.', + 'chk-select-all-elements' => 'Select all {total} elements matching current filters', + + // Edit Fields Modal + 'edit-fields-warning' => 'It doesn\'t look like there are any fields that support bulk editing on these elements.', + 'save-elements' => 'Save {totalElements} Elements', +]; From ac8f8d8e983e0d17aa683320199c6ec2e78baf11 Mon Sep 17 00:00:00 2001 From: Yousaf Zaman Date: Wed, 16 Aug 2023 09:36:38 -0700 Subject: [PATCH 2/2] swapped translation file keys with default text --- src/Plugin.php | 12 ++--- src/fields/strategies/Add.php | 2 +- src/fields/strategies/Divide.php | 2 +- src/fields/strategies/Merge.php | 2 +- src/fields/strategies/Multiply.php | 2 +- src/fields/strategies/Replace.php | 2 +- src/fields/strategies/Subtract.php | 2 +- .../elementactions/BulkEdit/_edit.twig | 8 +-- .../elementactions/BulkEdit/_fields.twig | 20 ++++---- src/translations/en/venveo-bulk-edit.php | 50 +++++++++---------- 10 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index e69996e..597fb67 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -56,26 +56,26 @@ public function init() Event::on(UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS, function(RegisterUserPermissionsEvent $event) { $permissions = []; $permissions[self::PERMISSION_BULKEDIT_ENTRIES] = [ - 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-entries'), + 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Entries'), ]; $permissions[self::PERMISSION_BULKEDIT_ASSETS] = [ - 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-assets'), + 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Assets'), ]; $permissions[self::PERMISSION_BULKEDIT_CATEGORIES] = [ - 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-categories'), + 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Categories'), ]; $permissions[self::PERMISSION_BULKEDIT_USERS] = [ - 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-users'), + 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Users'), ]; if (Craft::$app->plugins->isPluginInstalled('commerce')) { $permissions[self::PERMISSION_BULKEDIT_PRODUCTS] = [ - 'label' => Craft::t('venveo-bulk-edit', 'user-permissions-edit-products'), + 'label' => Craft::t('venveo-bulk-edit', 'Bulk Edit Products'), ]; } $event->permissions[] = [ - 'heading' => Craft::t('venveo-bulk-edit', 'user-permissons-label'), + 'heading' => Craft::t('venveo-bulk-edit', 'Bulk Edit'), 'permissions' => $permissions ]; }); diff --git a/src/fields/strategies/Add.php b/src/fields/strategies/Add.php index c1c4494..7bf109c 100644 --- a/src/fields/strategies/Add.php +++ b/src/fields/strategies/Add.php @@ -9,6 +9,6 @@ class Add implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'add'); + return Craft::t('venveo-bulk-edit', 'Add'); } } diff --git a/src/fields/strategies/Divide.php b/src/fields/strategies/Divide.php index 55354a6..0c6f7c7 100644 --- a/src/fields/strategies/Divide.php +++ b/src/fields/strategies/Divide.php @@ -9,6 +9,6 @@ class Divide implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'divide'); + return Craft::t('venveo-bulk-edit', 'Divide'); } } diff --git a/src/fields/strategies/Merge.php b/src/fields/strategies/Merge.php index d5d37ab..6d5a91b 100644 --- a/src/fields/strategies/Merge.php +++ b/src/fields/strategies/Merge.php @@ -9,6 +9,6 @@ class Merge implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'merge'); + return Craft::t('venveo-bulk-edit', 'Merge'); } } diff --git a/src/fields/strategies/Multiply.php b/src/fields/strategies/Multiply.php index bd5455a..7cd3c03 100644 --- a/src/fields/strategies/Multiply.php +++ b/src/fields/strategies/Multiply.php @@ -9,6 +9,6 @@ class Multiply implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'multiply'); + return Craft::t('venveo-bulk-edit', 'Multiply'); } } diff --git a/src/fields/strategies/Replace.php b/src/fields/strategies/Replace.php index d04b5a6..50d6638 100644 --- a/src/fields/strategies/Replace.php +++ b/src/fields/strategies/Replace.php @@ -9,6 +9,6 @@ class Replace implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'replace'); + return Craft::t('venveo-bulk-edit', 'Replace'); } } diff --git a/src/fields/strategies/Subtract.php b/src/fields/strategies/Subtract.php index 063c8cf..53113f9 100644 --- a/src/fields/strategies/Subtract.php +++ b/src/fields/strategies/Subtract.php @@ -9,6 +9,6 @@ class Subtract implements FieldStrategyInterface { public static function displayName(): string { - return Craft::t('venveo-bulk-edit', 'subtract'); + return Craft::t('venveo-bulk-edit', 'Subtract'); } } diff --git a/src/templates/elementactions/BulkEdit/_edit.twig b/src/templates/elementactions/BulkEdit/_edit.twig index f1fc5ed..2244a5a 100644 --- a/src/templates/elementactions/BulkEdit/_edit.twig +++ b/src/templates/elementactions/BulkEdit/_edit.twig @@ -10,14 +10,14 @@ {% endnamespace %}
-
{{ "cancel"|t('venveo-bulk-edit') }}
-
+
{{ "Cancel"|t('venveo-bulk-edit') }}
+
{% else %} -

{{ "edit-fields-warning"|t('venveo-bulk-edit') }}

+

{{ "It doesn\'t look like there are any fields that support bulk editing on these elements."|t('venveo-bulk-edit') }}

-
{{ "cancel"|t('venveo-bulk-edit') }}
+
{{ "Cancel"|t('venveo-bulk-edit') }}
{% endif %} diff --git a/src/templates/elementactions/BulkEdit/_fields.twig b/src/templates/elementactions/BulkEdit/_fields.twig index 55f0032..72bf8c2 100644 --- a/src/templates/elementactions/BulkEdit/_fields.twig +++ b/src/templates/elementactions/BulkEdit/_fields.twig @@ -1,9 +1,9 @@ {% import '_includes/forms' as forms %}
-

{{ "select-fields"|t('venveo-bulk-edit') }}

+

{{ "Select Fields"|t('venveo-bulk-edit') }}

- {{ "fields-desc"|t('venveo-bulk-edit', params = { + {{ "Editing {total} elements on site {site} ({language})"|t('venveo-bulk-edit', params = { site: site.name, language: site.language, total: selectedTotal @@ -15,7 +15,7 @@ {{ forms.checkbox({ id: 'bulk-edit-select-all', checked: selectAllChecked, - label: 'chk-select-all-elements'|t('venveo-bulk-edit', params = {total: selectAllTotal}), + label: 'Select all {total} elements matching current filters'|t('venveo-bulk-edit', params = {total: selectAllTotal}), name: 'selectAll', }) }}

@@ -25,22 +25,22 @@ - {{ 'col-field-name'|t('venveo-bulk-edit') }} + {{ 'Field Name'|t('venveo-bulk-edit') }} - {{ 'col-field-handle'|t('venveo-bulk-edit') }} + {{ 'Field Handle'|t('venveo-bulk-edit') }} - {{ 'col-edit'|t('venveo-bulk-edit') }} + {{ 'Edit'|t('venveo-bulk-edit') }} - {{ 'col-strategy'|t('venveo-bulk-edit') }} + {{ 'Strategy'|t('venveo-bulk-edit') }} @@ -87,12 +87,12 @@ {% endif %} {% else %} -

{{ 'assoc-fields-warning'|t('venveo-bulk-edit') }}

+

{{ 'These elements have no associated fields.'|t('venveo-bulk-edit') }}

{% endif %}
-
{{ "cancel"|t('venveo-bulk-edit') }}
- {{ "Cancel"|t('venveo-bulk-edit') }}
+
diff --git a/src/translations/en/venveo-bulk-edit.php b/src/translations/en/venveo-bulk-edit.php index 5131f64..3fe676f 100644 --- a/src/translations/en/venveo-bulk-edit.php +++ b/src/translations/en/venveo-bulk-edit.php @@ -14,37 +14,37 @@ * @since 1.0.0 */ return [ - // Common Actions - 'cancel' => 'Cancel', - 'continue' => 'Continue', + // Common + 'Cancel' => 'Cancel', + 'Continue' => 'Continue', // Strategies - 'add' => 'Add', - 'divide' => 'Divide', - 'merge' => 'Merge', - 'multiply' => 'Multiply', - 'replace' => 'Replace', - 'subtract' => 'Subtract', + 'Add' => 'Add', + 'Divide' => 'Divide', + 'Merge' => 'Merge', + 'Multiply' => 'Multiply', + 'Replace' => 'Replace', + 'Subtract' => 'Subtract', // User Permissions - 'user-permissions-edit-entries' => 'Bulk Edit Entries', - 'user-permissions-edit-assets' => 'Bulk Edit Assets', - 'user-permissions-edit-categories' => 'Bulk Edit Categories', - 'user-permissions-edit-users' => 'Bulk Edit Users', - 'user-permissions-edit-products' => 'Bulk Edit Products', - 'user-permissons-label' => 'Bulk Edit', + 'Bulk Edit Entries' => 'Bulk Edit Entries', + 'Bulk Edit Assets' => 'Bulk Edit Assets', + 'Bulk Edit Categories' => 'Bulk Edit Categories', + 'Bulk Edit Users' => 'Bulk Edit Users', + 'Bulk Edit Products' => 'Bulk Edit Products', + 'Bulk Edit' => 'Bulk Edit', // Select Fields Modal - 'select-fields' => 'Select Fields', - 'fields-desc' => 'Editing {total} elements on site {site} ({language})', - 'col-field-name' => 'Field Name', - 'col-field-handle' => 'Field Handle', - 'col-edit' => 'Edit', - 'col-strategy' => 'Strategy', - 'assoc-fields-warning' => 'These elements have no associated fields.', - 'chk-select-all-elements' => 'Select all {total} elements matching current filters', + 'Select Fields' => 'Select Fields', + 'Editing {total} elements on site {site} ({language})' => 'Editing {total} elements on site {site} ({language})', + 'Field Name' => 'Field Name', + 'Field Handle' => 'Field Handle', + 'Edit' => 'Edit', + 'Strategy' => 'Strategy', + 'These elements have no associated fields.' => 'These elements have no associated fields.', + 'Select all {total} elements matching current filters' => 'Select all {total} elements matching current filters', // Edit Fields Modal - 'edit-fields-warning' => 'It doesn\'t look like there are any fields that support bulk editing on these elements.', - 'save-elements' => 'Save {totalElements} Elements', + 'It doesn\'t look like there are any fields that support bulk editing on these elements.' => 'It doesn\'t look like there are any fields that support bulk editing on these elements.', + 'Save {totalElements} Elements' => 'Save {totalElements} Elements', ];