From f04c2718efb772f2c004bb1dd641064742db9d75 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Mon, 25 Apr 2022 15:03:32 +0200 Subject: [PATCH] Bug 22490: Some strings in JavaScript files are untranslatable This patch updates the translation functions of the strings in Javascript files Test Plan: 1) Find a string in a popup or from a Javascript file who is still not translated or 1) Home > Administration > Authority types 2) Make sure to have at least one Authority type saved 3) Click on Action > Import 4) Import button without adding any file to trigger the popup 5) The string inside the popup appears without translation 6) Apply patch and repeat from 3) to 5) : now the string is translated --- cataloguing/value_builder/dateaccessioned.pl | 2 +- cataloguing/value_builder/unimarc_leader.pl | 2 +- koha-tmpl/intranet-tmpl/js/Gettext.js | 8 ++++---- koha-tmpl/intranet-tmpl/prog/js/authtype.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cataloguing/value_builder/dateaccessioned.pl b/cataloguing/value_builder/dateaccessioned.pl index 9d7da193c7..b2b0d4aff8 100755 --- a/cataloguing/value_builder/dateaccessioned.pl +++ b/cataloguing/value_builder/dateaccessioned.pl @@ -50,7 +50,7 @@ function Click$function_name(event) { function set_to_today( id, force ) { /* The force parameter is used in Click but not in Focus ! */ - if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; } + if (! id) { alert(__("Bad id ") + id + __(" sent to set_to_today()")); return 0; } if (\$("#" + id).val() == '' || force ) { \$("#" + id).val("$date"); } diff --git a/cataloguing/value_builder/unimarc_leader.pl b/cataloguing/value_builder/unimarc_leader.pl index 838f5a88f0..2232e33667 100755 --- a/cataloguing/value_builder/unimarc_leader.pl +++ b/cataloguing/value_builder/unimarc_leader.pl @@ -36,7 +36,7 @@ sub plugin_javascript { function Blur$function_name(subfield_managed) { var leader_length = document.getElementById(\"$field_number\").value.length; if (leader_length != 24 && leader_length !=0) { - alert(_('leader has an incorrect size: ' + leader_length + ' instead of 24 chars')); + alert(__('leader has an incorrect size: ' + leader_length + ' instead of 24 chars')); } return 1; } diff --git a/koha-tmpl/intranet-tmpl/js/Gettext.js b/koha-tmpl/intranet-tmpl/js/Gettext.js index ce6bf96877..9f63bc7e31 100644 --- a/koha-tmpl/intranet-tmpl/js/Gettext.js +++ b/koha-tmpl/intranet-tmpl/js/Gettext.js @@ -35,7 +35,7 @@ Javascript Gettext - Javascript implemenation of GNU Gettext API. var gt = new Gettext(params); // create a shortcut if you'd like function _ (msgid) { return gt.gettext(msgid); } - alert(_("some string")); + alert(__("some string")); // or use fully named method alert(gt.gettext("some string")); // change to use a different "domain" @@ -71,7 +71,7 @@ Javascript Gettext - Javascript implemenation of GNU Gettext API. return this.gt.gettext(msgid); }; MyNamespace.MyClass.prototype.something = function () { - var myString = this._("this will get translated"); + var myString = this.__("this will get translated"); }; // ////////////////////////////////////////////////////////// @@ -81,7 +81,7 @@ Javascript Gettext - Javascript implemenation of GNU Gettext API. function _ (msgid) { return myGettext.gettext(msgid); } - alert( _("text") ); + alert( __("text") ); // ////////////////////////////////////////////////////////// // Data structure of the json data @@ -1210,7 +1210,7 @@ It's still recommended to use the statically defined