[Bug 24661] New: Inclusion of locale-related javascript files is broken
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Bug ID: 24661 Summary: Inclusion of locale-related javascript files is broken Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: ASSIGNED Severity: normal Priority: P5 - low Component: I18N/L10N Assignee: julian.maurice@biblibre.com Reporter: julian.maurice@biblibre.com QA Contact: testopia@bugs.koha-community.org CC: frederic@tamil.fr Depends on: 21156 Bug 21156 adds 2 js files (Gettext.js, i18n.js) + 1 generated js file (locale_data.js). On master, their URL are broken and the files are not loaded. Steps to reproduce: 1. Checkout master 2. Open Firefox/Chrome devtools, network tab, and go to any page in the staff interface (except the main page) 3. You should see 3 404 errors for the files mentioned above. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21156 [Bug 21156] Internationalization: plural forms, context, and more for JS files -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |oleonard@myacpl.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #1 from Julian Maurice <julian.maurice@biblibre.com> --- Created attachment 98913 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98913&action=edit Bug 24661: Fix inclusion of locale-related javascript files Bug 21156 adds 2 js files (Gettext.js, i18n.js) + 1 generated js file (locale_data.js). Their URL are broken and the files are not loaded. Use Template::Toolkit plugin Asset to include these files, and exclude locale_data.js when language is english, because obviously translations are not needed in this case. Test plan: 1. Just make sure the files mentioned above are loaded correctly when in English and in other languages as well -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |24662 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24662 [Bug 24662] Remove global variables MSG_* from datatables.inc -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #98913|0 |1 is obsolete| | --- Comment #2 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 98930 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=98930&action=edit Bug 24661: Fix inclusion of locale-related javascript files 2 js files (Gettext.js, i18n.js) + 1 generated js file (locale_data.js) were added by bug 21156. Their URL are broken and the files are not loaded. Use Template::Toolkit plugin Asset to include these files, and exclude locale_data.js when language is english, because obviously translations are not needed in this case. Test plan: 1. Just make sure the files mentioned above are loaded correctly when in English and in other languages as well Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com --- Comment #3 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Thanks for the quick fix Julian.. works as expected.. going for a fast QA on this one! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |martin.renvoize@ptfs-europe |y.org |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |20.05.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #4 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice work everyone! Pushed to master for 20.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bgkriegel@gmail.com --- Comment #5 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- (In reply to Martin Renvoize from comment #4)
Nice work everyone!
Pushed to master for 20.05
Too fast! I was about to sign this :) Anyway, I found the following, not related with this bug, that pops doing a language update (also create and install) to do the testing: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:569: warning: unterminated string koha-tmpl/intranet-tmpl/prog/js/checkouts.js:858: warning: unterminated string koha-tmpl/intranet-tmpl/prog/js/checkouts.js:904: warning: unterminated string koha-tmpl/intranet-tmpl/prog/js/checkouts.js:911: warning: unterminated string koha-tmpl/intranet-tmpl/prog/js/checkouts.js:1095: warning: RegExp literal terminated too early -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #6 from Julian Maurice <julian.maurice@biblibre.com> --- It looks like xgettext does not like ES6 template literals. https://savannah.gnu.org/bugs/?50920
From what I understand, support for template literals was added in gettext 0.20 (still not packaged in debian) but is still buggy in latest released version 0.20.1 and a fix is present in master.
-- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #7 from Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> --- (In reply to Julian Maurice from comment #6)
It looks like xgettext does not like ES6 template literals.
https://savannah.gnu.org/bugs/?50920
From what I understand, support for template literals was added in gettext 0.20 (still not packaged in debian) but is still buggy in latest released version 0.20.1 and a fix is present in master.
Then we have a little problem with that. Current (19.10/18.04) ubuntu has 0.19.8.1 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #8 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Bernardo Gonzalez Kriegel from comment #7)
Then we have a little problem with that. Current (19.10/18.04) ubuntu has 0.19.8.1
Yes, same version in Debian unstable, so we're stuck with this version for some time. One possible workaround is to declare translatable strings as soon as possible in the file (before the first template literal), since xgettext parse these strings correctly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl --- Comment #9 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Warning from qa tools: File not found : /js/locale_data.js at /usr/share/koha/Koha/Template/Plugin/Asset.pm line 84. koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc: [% Asset.js(lang _ '/js/locale_data.js') | $raw %] Cannot find this file. Not sure if this construction works in template toolkit btw. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #10 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Marcel de Rooy from comment #9)
Warning from qa tools: File not found : /js/locale_data.js at /usr/share/koha/Koha/Template/Plugin/Asset.pm line 84.
koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc: [% Asset.js(lang _ '/js/locale_data.js') | $raw %] Cannot find this file. Not sure if this construction works in template toolkit btw.
The construction is fine btw. Not sure why qa tools doesnt like it.. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #11 from Julian Maurice <julian.maurice@biblibre.com> ---
The construction is fine btw. Not sure why qa tools doesnt like it..
Probably because lang is not defined so it looks for absolute path /js/locale_data.js Not sure why qa tools has to process templates. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #12 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- (In reply to Julian Maurice from comment #11)
The construction is fine btw. Not sure why qa tools doesnt like it..
Probably because lang is not defined so it looks for absolute path /js/locale_data.js Not sure why qa tools has to process templates.
It's coming from xt/tt_valid.t (or similar code from the qa script) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #13 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Jenkins has a lot of those lines, coming from xt/author/translatable-templates.t, I do not get the warnings when run locally however, which is a bit weird. https://jenkins.koha-community.org/job/Koha_Master_D9/1172/consoleFull What about the following changes? diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index 1ad6197288..94f86ad2f6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -26,6 +26,7 @@ var Koha = {}; </script> +[% SET lang = 'en' UNLESS lang.defined %] [% IF lang != 'en' %] [% Asset.js(lang _ '/js/locale_data.js') | $raw %] [% END %] -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #14 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Or even [% IF lang.defined AND lang != 'en' %] -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #15 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Jonathan Druart from comment #14)
Or even
[% IF lang.defined AND lang != 'en' %]
I never used the .defined VMethod of Template::Toolkit, but it should be ok. I'm not sure it is even needed. I think you can simply write [% IF lang && lang != 'en' %] Since no language code can evaluate to false -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #16 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Julian Maurice from comment #15)
(In reply to Jonathan Druart from comment #14)
Or even
[% IF lang.defined AND lang != 'en' %]
I never used the .defined VMethod of Template::Toolkit, but it should be ok. I'm not sure it is even needed. I think you can simply write
[% IF lang && lang != 'en' %]
Since no language code can evaluate to false
Looks good to me, nice and terse. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #17 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Julian Maurice from comment #6)
It looks like xgettext does not like ES6 template literals.
https://savannah.gnu.org/bugs/?50920
From what I understand, support for template literals was added in gettext 0.20 (still not packaged in debian) but is still buggy in latest released version 0.20.1 and a fix is present in master.
Hmm.. do we need to discuss this bit a bit further... are you suggesting a coding guideline fix or am I misunderstanding? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=24725 --- Comment #18 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- (In reply to Martin Renvoize from comment #17)
(In reply to Julian Maurice from comment #6)
It looks like xgettext does not like ES6 template literals.
https://savannah.gnu.org/bugs/?50920
From what I understand, support for template literals was added in gettext 0.20 (still not packaged in debian) but is still buggy in latest released version 0.20.1 and a fix is present in master.
Hmm.. do we need to discuss this bit a bit further... are you suggesting a coding guideline fix or am I misunderstanding?
See bug 24725. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #19 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Jonathan Druart from comment #18)
(In reply to Martin Renvoize from comment #17)
(In reply to Julian Maurice from comment #6)
It looks like xgettext does not like ES6 template literals.
https://savannah.gnu.org/bugs/?50920
From what I understand, support for template literals was added in gettext 0.20 (still not packaged in debian) but is still buggy in latest released version 0.20.1 and a fix is present in master.
Hmm.. do we need to discuss this bit a bit further... are you suggesting a coding guideline fix or am I misunderstanding?
See bug 24725.
Awesome, thanks Jonathan :) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #20 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 99586 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=99586&action=edit Bug 24661: (RM follow-up) Check lang is defined This adds a check that the lang variable is defined before testing against it. In normal operation this is likely a no-op, but it is required for compiling templates during QA. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Bug 24661 depends on bug 21156, which changed state. Bug 21156 Summary: Internationalization: plural forms, context, and more for JS files https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21156 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Joy Nelson <joy@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |RESOLVED Resolution|--- |FIXED CC| |joy@bywatersolutions.com --- Comment #21 from Joy Nelson <joy@bywatersolutions.com> --- not pushed to 19.11.x due to dependencies -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Bug 24661 depends on bug 21156, which changed state. Bug 21156 Summary: Internationalization: plural forms, context, and more for JS files https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21156 What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Joy Nelson <joy@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |--- Version(s)|20.05.00 |20.05.00, 19.11.04 released in| | Status|RESOLVED |REOPENED --- Comment #22 from Joy Nelson <joy@bywatersolutions.com> --- Pushed to 19.11.x for 19.11.04 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24661 --- Comment #23 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- There is a variable name collision with "lang" in some scripts: It's passed to all templates by C4::Templates to pass the language of the UI 84 $self->lang($lang); And, for instance, in controller like members/memberentry.pl 790 $template->param(%data); I know what we do in memberentry.pl is ugly, but fixing it will require some deep change it seems. Maybe the easiest would be to rename the "global" $lang with something like $ui_lang? The error in the log is: File not found : default/js/locale_data.js at /kohadevbox/koha/Koha/Template/Plugin/Asset.pm line 84. because borrowers.lang is "default" by default. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org