From 38566a861af1c1daf8fdf1a2b6137ae0c6391a7a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 17 Aug 2020 14:50:46 +0000 Subject: [PATCH] Bug 26229: Move translatable strings out of categories.tt and into categories.js This patch removes the definition of translatable strings out of templates and into the corresponding JavaScript file, using the new JS i81n function. To test: - Apply the patch, go to Administration -> Patron categories - Click "New category" - Enter some special characters in the "Category code" field, e.g. "%^&*" - Try to submit the form without filling in any other details. - The category code field should have a validation message, "Category code can only contain the following characters: letters, numbers, - and _." - The enrollment period fields should have a validation message, "Please choose an enrollment period in months OR by date." - Enter valid data and confirm that the form can be submitted. 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/categories.js for translation, e.g.: msgid "Please choose an enrollment period in months OR by date." 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 strings should appear. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../intranet-tmpl/prog/en/modules/admin/categories.tt | 2 -- koha-tmpl/intranet-tmpl/prog/js/categories.js | 10 ++++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index 0c836f418b..d83d7d27d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -624,8 +624,6 @@ [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] [% Asset.js("js/categories.js") | $raw %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/categories.js b/koha-tmpl/intranet-tmpl/prog/js/categories.js index 8031fff535..28f4ad700c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/categories.js +++ b/koha-tmpl/intranet-tmpl/prog/js/categories.js @@ -1,3 +1,5 @@ +/* global __ */ + jQuery.validator.addMethod( "letters_numbers", function(value,element){ var patt = /^[a-zA-Z0-9\-_]+$/g; if (patt.test(element.value)) { @@ -5,7 +7,7 @@ jQuery.validator.addMethod( "letters_numbers", function(value,element){ } else { return false; } - }, MSG_CATEGORYCODE_CHARS + }, __("Category code can only contain the following characters: letters, numbers, - and _.") ); jQuery.validator.addMethod( "enrollment_period", function(){ @@ -16,7 +18,7 @@ jQuery.validator.addMethod( "enrollment_period", function(){ } else { return true; } - }, MSG_ONE_ENROLLMENTPERIOD + }, __("Please choose an enrollment period in months OR by date.") ); @@ -91,10 +93,10 @@ $(document).ready(function() { }, messages: { enrolmentperiod: { - required: MSG_ONE_ENROLLMENTPERIOD + required: __("Please choose an enrollment period in months OR by date.") }, enrolmentperioddate: { - required: MSG_ONE_ENROLLMENTPERIOD + required: __("Please choose an enrollment period in months OR by date.") } } -- 2.39.5