Bugzilla – Attachment 107550 Details for
Bug 26065
Move translatable strings out of marc_modification_templates.tt and into marc_modification_templates.js
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26065: Move translatable strings out of marc_modification_templates.tt and into marc_modification_templates.js
Bug-26065-Move-translatable-strings-out-of-marcmod.patch (text/plain), 9.35 KB, created by
Katrin Fischer
on 2020-07-29 22:21:05 UTC
(
hide
)
Description:
Bug 26065: Move translatable strings out of marc_modification_templates.tt and into marc_modification_templates.js
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-07-29 22:21:05 UTC
Size:
9.35 KB
patch
obsolete
>From 72d21bed21c1e6a362ff61d4b1fa92008ab0f968 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Sat, 25 Jul 2020 15:10:24 +0000 >Subject: [PATCH] Bug 26065: Move translatable strings out of > marc_modification_templates.tt and into marc_modification_templates.js > >This patch removes the <script> block in the MARC modification >templates template in which strings are defined for translation >purposes. > >Strings are now in place in the JavaScript file and wrapped in the new >__() function. > >To test, apply the patch and clear your browser cache if necessary. > >- Perform some actions which will trigger translated strings, for > example: > - Create a new template > - Add an action to the template and then delete it. > - The confirmation should appear correctly > - Add an action. Select "Copy" as the operation and click "Add action" > without filling in any fields. > - You should see a message, "Both subfield values should be filled > or empty" > >TESTING TRANSLATABILITY > >- Update a translation, e.g. fr-FR: > >> cd misc/translator >> perl translate update fr-FR > >- Open the corresponding .po file for JavaScript strings, e.g. > misc/translator/po/fr-FR-messages-js.po >- Locate strings pulled from > koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js for > translation, e.g.: > > msgid "Both subfield values should be filled or empty." > msgstr "" > >- Edit the "msgstr" string however you want (it's just for testing). >- Install the updated translation: > >> perl translate install fr-FR > >- Switch to your newly translated language in the staff client and > repeat the test plan above. The translated string should appear. >--- > .../modules/tools/marc_modification_templates.tt | 18 +--------- > .../prog/js/marc_modification_templates.js | 39 +++++++++++----------- > 2 files changed, 21 insertions(+), 36 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt >index 9098bda200..f692b42b95 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt >@@ -322,26 +322,10 @@ > > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/tools-menu.js") | $raw %] >+ [% Asset.js("js/marc_modification_templates.js") | $raw %] > <script> >- var MSG_MMT_SUBFIELDS_MATCH = _("Both subfield values should be filled or empty."); >- var MSG_MMT_DESTINATION_REQUIRED = _("The destination should be filled."); >- var MSG_MMT_CONTROL_FIELD_EMPTY = _("If the field is a control field, the subfield should be empty"); >- var MSG_MMT_CONTROL_FIELD = _("A control field cannot be used with a regular field."); >- var MSG_MMT_SOURCE_SUBFIELD = _("The source subfield should be filled for update."); >- var MSG_MMT_SOURCE_FIELD = _("The source field should be filled."); >- var MSG_MMT_EVERY = _("Every"); >- var MSG_MMT_ALL = _("All"); >- var MSG_MMT_CONFIRM_DEL_TEMPLATE = _("Are you sure you wish to delete this template?"); >- var MSG_MMT_CONFIRM_DEL_TEMPLATE_ACTION = _("Are you sure you wish to delete this template action?"); >- var MSG_MMT_EDIT_ACTION = _("Edit action %s"); >- var MSG_MMT_UPDATE_ACTION = _("Update action"); >- var MSG_MMT_CONDITIONAL_FIELD_REQUIRED = _("The conditional field should be filled."); >- var MSG_MMT_CONDITIONAL_COMPARISON_REQUIRED = _("The conditional comparison operator should be filled."); >- var MSG_MMT_CONDITIONAL_VALUE_REQUIRED = _("The conditional value should be filled."); >- var MSG_MMT_CONDITIONAL_VALUE_REGEX_REQUIRED = _("The conditional regular expression should be filled."); > var mmtas = [% ActionsLoop.json | $raw %] > </script> >- [% Asset.js("js/marc_modification_templates.js") | $raw %] > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >index bde38033df..4f33c33ccd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js >@@ -1,3 +1,4 @@ >+/* global __ */ > $(document).ready(function() { > window.modaction_legend_innerhtml = $("#modaction_legend").text(); > window.action_submit_value = $("#action_submit").val(); >@@ -13,50 +14,50 @@ $(document).ready(function() { > var action = $("#action").val(); > if ( action == 'move_field' || action == 'copy_field' || action == 'copy_and_replace_field') { > if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) { >- alert( MSG_MMT_SUBFIELDS_MATCH ); >+ alert( __("Both subfield values should be filled or empty.") ); > return false; > } > if ( $("#to_field").val().length <= 0 ) { >- alert( MSG_MMT_DESTINATION_REQUIRED ); >+ alert( __("The destination should be filled.") ); > return false; > } > if ( ( $("#to_field").val() < 10 && $("#to_subfield").val().length > 0 ) || >- ( $("#from_field").val() < 10 && $("#from_subfield").val().length > 0 ) ) { >- alert( MSG_MMT_CONTROL_FIELD_EMPTY ); >- return false; >+ ( $("#from_field").val() < 10 && $("#from_subfield").val().length > 0 ) ) { >+ alert( __("If the field is a control field, the subfield should be empty") ); >+ return false; > } > if ( ( $("#from_field").val() < 10 && $("#to_field").val() >= 10 ) || > ( $("#to_field").val() < 10 && $("#from_field").val() >= 10 ) ) { >- alert( MSG_MMT_CONTROL_FIELD ); >+ alert( __("A control field cannot be used with a regular field.") ); > return false; >- } >+ } > } > if ( action == 'update_field' ) { > if ( $("#from_subfield").val().length <= 0 ) { >- alert( MSG_MMT_SOURCE_SUBFIELD ); >+ alert( __("The source subfield should be filled for update.") ); > return false; > } > } > if ( $("#from_field").val().length <= 0 ) { >- alert( MSG_MMT_SOURCE_FIELD ); >+ alert( __("The source field should be filled.") ); > return false; > } > if ( $("#conditional").val() == 'if' || $("#conditional").val() == 'unless' ) { > if ( $("#conditional_field").val() == '' ) { >- alert( MSG_MMT_CONDITIONAL_FIELD_REQUIRED ); >+ alert( __("The conditional field should be filled.") ); > return false; > } > if ( $("#conditional_comparison").val() == '' ) { >- alert( MSG_MMT_CONDITIONAL_COMPARISON_REQUIRED ); >+ alert( __("The conditional comparison operator should be filled.") ); > return false > } > if ( $("#conditional_value").val() == '' && > ( $("#conditional_comparison").val() == 'equals' || $("#conditional_comparison").val() == 'not_equals' ) ) { > if ( document.getElementById('conditional_regex').checked == true ) { >- alert( MSG_MMT_CONDITIONAL_VALUE_REGEX_REQUIRED ); >+ alert( __("The conditional regular expression should be filled.") ); > return false; > } else { >- alert( MSG_MMT_CONDITIONAL_VALUE_REQUIRED ); >+ alert( __("The conditional value should be filled.") ); > return false; > } > } >@@ -112,9 +113,9 @@ $(document).ready(function() { > function updateAllEvery(){ > if ( $("#conditional_field").is(":visible") ) { > if ( $("#conditional_field").val() == $("#from_field").val() && $("#from_field").val().length > 0 ) { >- $("#field_number option[value='0']").html( MSG_MMT_EVERY ); >+ $("#field_number option[value='0']").html( __("Every") ); > } else { >- $("#field_number option[value='0']").html( MSG_MMT_ALL ); >+ $("#field_number option[value='0']").html( __("All") ); > } > } > } >@@ -256,11 +257,11 @@ function clearFormElements(divId) { > } > > function confirmDeleteAction() { >- return confirm( MSG_MMT_CONFIRM_DEL_TEMPLATE_ACTION ); >+ return confirm( __("Are you sure you wish to delete this template action?") ); > } > > function confirmDelete() { >- return confirm( MSG_MMT_CONFIRM_DEL_TEMPLATE ); >+ return confirm( __("Are you sure you wish to delete this template?") ); > } > > var modaction_legend_innerhtml; >@@ -306,10 +307,10 @@ function editAction( mmta ) { > document.getElementById('description').value = mmta['description']; > > window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML; >- document.getElementById('modaction_legend').innerHTML = MSG_MMT_EDIT_ACTION.format(mmta['ordering']); >+ document.getElementById('modaction_legend').innerHTML = __("Edit action %s").format(mmta['ordering']); > > window.action_submit_value = document.getElementById('action_submit').value; >- document.getElementById('action_submit').value = MSG_MMT_UPDATE_ACTION; >+ document.getElementById('action_submit').value = __("Update action"); > } > > function cancelEditAction() { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26065
:
107430
| 107550