Bug 22490 - Some strings in JavaScript files are untranslatable
Summary: Some strings in JavaScript files are untranslatable
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Julian Maurice
QA Contact: Katrin Fischer
URL:
Keywords:
: 22601 (view as bug list)
Depends on: 22114 22904 24046
Blocks:
  Show dependency treegraph
 
Reported: 2019-03-11 11:20 UTC by Josef Moravec
Modified: 2023-12-28 20:43 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.04


Attachments
Bug 22490: Some strings in JavaScript files are untranslatable (5.12 KB, patch)
2022-04-25 14:51 UTC, Jérémy Breuillard
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (12.97 KB, patch)
2022-04-26 14:13 UTC, Jérémy Breuillard
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (14.08 KB, patch)
2022-04-27 14:24 UTC, Jérémy Breuillard
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (11.53 KB, patch)
2022-04-28 07:50 UTC, Jérémy Breuillard
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (11.24 KB, patch)
2022-04-28 09:16 UTC, Jérémy Breuillard
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (14.53 KB, patch)
2023-02-17 15:42 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (14.60 KB, patch)
2023-02-17 16:49 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 22490: Some strings in JavaScript files are untranslatable (14.63 KB, patch)
2023-02-24 14:58 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Josef Moravec 2019-03-11 11:20:14 UTC
You can find them easily with these commands:

git grep "_(" koha-tmpl/intranet-tmpl/prog/js

git grep "_(" koha-tmpl/opac-tmpl/bootstrap/js

They should be fixed, see https://wiki.koha-community.org/wiki/Coding_Guidelines#JS5:_Enabling_translation_of_language_strings_in_linked_JavaScript
Comment 1 Fridolin Somers 2019-03-28 09:04:59 UTC
*** Bug 22601 has been marked as a duplicate of this bug. ***
Comment 2 Fridolin Somers 2019-03-28 11:11:48 UTC
I will create a xxx-strings.inc for each js
Comment 3 Jonathan Druart 2019-06-23 15:47:06 UTC
A Koha test must be provided here.
Comment 4 Jonathan Druart 2019-12-11 09:37:54 UTC
Won't be a problem with bug 21156.
Comment 5 Jonathan Druart 2019-12-11 09:38:17 UTC
Lowering severity.
Comment 6 Fridolin Somers 2020-01-30 06:53:20 UTC
Bug 24046 fixed "Activate filters"
Comment 7 Jérémy Breuillard 2022-04-25 14:51:00 UTC Comment hidden (obsolete)
Comment 8 Jérémy Breuillard 2022-04-26 14:13:59 UTC Comment hidden (obsolete)
Comment 9 Jérémy Breuillard 2022-04-27 14:24:06 UTC Comment hidden (obsolete)
Comment 10 Jérémy Breuillard 2022-04-28 07:50:04 UTC Comment hidden (obsolete)
Comment 11 Jérémy Breuillard 2022-04-28 09:16:45 UTC
Created attachment 134207 [details] [review]
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
Comment 12 Josef Moravec 2022-05-20 06:43:00 UTC
There are some more strings on master in these files:

koha-tmpl/intranet-tmpl/prog/js/datatables.js (1 string)
koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js (2 more strings)

Found by:
git grep '[^_]_(' koha-tmpl/intranet-tmpl/prog/js


Also there are dummy functions defined in koha-tmpl/intranet-tmpl/prog/js/onboarding.js and koha-tmpl/intranet-tmpl/prog/js/staff-global.js.

I am not sure what was this function meant to be for, but I believe it 'legitimate' the '_' function in javascript runtime
Comment 13 Julian Maurice 2023-02-17 15:42:56 UTC
Created attachment 146854 [details] [review]
Bug 22490: Some strings in JavaScript files are untranslatable

Javascript function `_` works only if used in template file (.tt or
.inc).
In .js files we should use `__`

This patch updates .js files to use `__` instead of `_`

Test Plan:
1. Do not apply the patch yet
2. Run `npx gulp po:update --lang fr-FR` (choose another language
   if you prefer)
3. Open misc/translator/po/fr-FR-messages-js.po and search "Please
   select a CSV (.csv) or ODS (.ods) spreadsheet file"
4. Notice that the references above only mention biblio_framework.js
5. If not already translated, translate it
6. Run misc/translator/translate install fr-FR
7. Go to staff interface and change language to fr-FR
8. Go to Administration » Authority types and click on "Actions ->
   Import"
9. In the modal window, click on "Import" without selecting a file. You
   should see an alert with the non-translated text
10. Apply the patch
11. Run `npx gulp po:update --lang fr-FR`
12. Open misc/translator/po/fr-FR-messages-js.po and search "Please
    select a CSV (.csv) or ODS (.ods) spreadsheet file"
13. Notice that the references above now also mention authtype.js
14. If the translation is marked as fuzzy, remove the fuzzy flag
15. Run misc/translator/translate install fr-FR
16. Go to staff interface again
17. Go to Administration » Authority types and click on "Actions ->
    Import"
18. In the modal window, click on "Import" without selecting a file. You
    should see an alert, this time with the translated text
Comment 14 Julian Maurice 2023-02-17 15:48:17 UTC
(In reply to Josef Moravec from comment #12)
> There are some more strings on master in these files:
> 
> koha-tmpl/intranet-tmpl/prog/js/datatables.js (1 string)
> koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js (2 more strings)
Fixed

> Also there are dummy functions defined in
> koha-tmpl/intranet-tmpl/prog/js/onboarding.js and
> koha-tmpl/intranet-tmpl/prog/js/staff-global.js.
> 
> I am not sure what was this function meant to be for, but I believe it
> 'legitimate' the '_' function in javascript runtime
It's used to detect translatable strings in .inc/.tt for the older translation system
Comment 15 Owen Leonard 2023-02-17 16:49:00 UTC
Created attachment 146868 [details] [review]
Bug 22490: Some strings in JavaScript files are untranslatable

Javascript function `_` works only if used in template file (.tt or
.inc).
In .js files we should use `__`

This patch updates .js files to use `__` instead of `_`

Test Plan:
1. Do not apply the patch yet
2. Run `npx gulp po:update --lang fr-FR` (choose another language
   if you prefer)
3. Open misc/translator/po/fr-FR-messages-js.po and search "Please
   select a CSV (.csv) or ODS (.ods) spreadsheet file"
4. Notice that the references above only mention biblio_framework.js
5. If not already translated, translate it
6. Run misc/translator/translate install fr-FR
7. Go to staff interface and change language to fr-FR
8. Go to Administration » Authority types and click on "Actions ->
   Import"
9. In the modal window, click on "Import" without selecting a file. You
   should see an alert with the non-translated text
10. Apply the patch
11. Run `npx gulp po:update --lang fr-FR`
12. Open misc/translator/po/fr-FR-messages-js.po and search "Please
    select a CSV (.csv) or ODS (.ods) spreadsheet file"
13. Notice that the references above now also mention authtype.js
14. If the translation is marked as fuzzy, remove the fuzzy flag
15. Run misc/translator/translate install fr-FR
16. Go to staff interface again
17. Go to Administration » Authority types and click on "Actions ->
    Import"
18. In the modal window, click on "Import" without selecting a file. You
    should see an alert, this time with the translated text

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 16 Katrin Fischer 2023-02-24 14:58:31 UTC
How did we miss all those?
Comment 17 Katrin Fischer 2023-02-24 14:58:58 UTC
Created attachment 147337 [details] [review]
Bug 22490: Some strings in JavaScript files are untranslatable

Javascript function `_` works only if used in template file (.tt or
.inc).
In .js files we should use `__`

This patch updates .js files to use `__` instead of `_`

Test Plan:
1. Do not apply the patch yet
2. Run `npx gulp po:update --lang fr-FR` (choose another language
   if you prefer)
3. Open misc/translator/po/fr-FR-messages-js.po and search "Please
   select a CSV (.csv) or ODS (.ods) spreadsheet file"
4. Notice that the references above only mention biblio_framework.js
5. If not already translated, translate it
6. Run misc/translator/translate install fr-FR
7. Go to staff interface and change language to fr-FR
8. Go to Administration » Authority types and click on "Actions ->
   Import"
9. In the modal window, click on "Import" without selecting a file. You
   should see an alert with the non-translated text
10. Apply the patch
11. Run `npx gulp po:update --lang fr-FR`
12. Open misc/translator/po/fr-FR-messages-js.po and search "Please
    select a CSV (.csv) or ODS (.ods) spreadsheet file"
13. Notice that the references above now also mention authtype.js
14. If the translation is marked as fuzzy, remove the fuzzy flag
15. Run misc/translator/translate install fr-FR
16. Go to staff interface again
17. Go to Administration » Authority types and click on "Actions ->
    Import"
18. In the modal window, click on "Import" without selecting a file. You
    should see an alert, this time with the translated text

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 18 Tomás Cohen Arazi 2023-02-24 19:56:12 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 19 Matt Blenkinsop 2023-02-28 10:15:48 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 20 Lucas Gass 2023-03-08 13:20:47 UTC
No patron-autocomplete.js in 22.05.x so this does not apply. No backport.