Bug 37303 - Fuzzy translations displayed on the UI
Summary: Fuzzy translations displayed on the UI
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-10 10:21 UTC by Jonathan Druart
Modified: 2024-07-10 15:18 UTC (History)
6 users (show)

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


Attachments
Bug 37303: Replace po2json with a JS version (9.78 KB, patch)
2024-07-10 10:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 37303: Replace po2json with a JS version (10.63 KB, patch)
2024-07-10 12:13 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2024-07-10 10:21:59 UTC
When using __() (ie. Gettext.js) we are seeing the translations that are marked as fuzzy. This is definitely not the expected behaviour.
It happens because (our version of) po2json are old and no longer maintained, and just embed them.
Comment 1 Jonathan Druart 2024-07-10 10:36:27 UTC
Created attachment 168712 [details] [review]
Bug 37303: Replace po2json with a JS version

When using __() (ie. Gettext.js) we are seeing the translations that are marked as fuzzy.
This is definitely not the expected behaviour.

It happens because (our version of) po2json are old and no longer maintained,
and just embed them.

It seems that the bin we have has been upgraded to a JS version
(different authors).

Test plan:
(replace LANG with your language code)
0. Do not apply this patch
Edit misc/translator/po/LANG-messages-js.po
Mark a string as fuzzy
Edit ./intranet-main.tt and add the following lines inside $(document).ready
  console.log(_("Your string"));
  console.log(__("Your string"));
Replace "Your string" with the string you are actually testing.

Update the templates: `koha-translate --update LANG --dev kohadev && restart_all`

Go to the Koha home page, open the console.

=> Notice that the second log in the console is displaying the fuzzy string.

1. Apply this patch
Install the new version of po2json using `yarn install`
Repeat the previous steps.

=> With this patch applied both logs show the English version of the
string.

Remove fuzzy, update the templates and try again.
Comment 2 Jonathan Druart 2024-07-10 10:36:55 UTC
This seems bad, how didn't we catch that before?
Comment 3 Aude Charillon 2024-07-10 11:09:02 UTC
I guess it only affects languages where not everything is translated - either due to lack of translators or because it's English to English (so no translation needed, in most cases). Speaking for the en-GB translation crew, we simply assumed it was our fault; that we'd messed up our file at some point in the past!
Comment 4 Julian Maurice 2024-07-10 11:49:54 UTC
Patch does not work for me. po2json expects 2 arguments (<input> <output>) and we only give one.
So the resulting locale_data.json looks like this:

var json_locale_data = {"Koha":yarn run v1.22.20
>>$ /home/koha/koha/node_modules/.bin/po2json /home/koha/koha/misc/translator/po/fr-FR-messages-js.po

>>output argument is required

>>Usage: po2json <input> <output> [options]
[... full of usage ...]
};
Comment 5 Julian Maurice 2024-07-10 11:55:02 UTC
Can't we add a "next if $po->fuzzy" in misc/translator/po2json ? It looks easier
Comment 6 Jonathan Druart 2024-07-10 12:04:27 UTC
(In reply to Julian Maurice from comment #5)
> Can't we add a "next if $po->fuzzy" in misc/translator/po2json ? It looks
> easier

Maybe, but I thought it was better to rely on a maintained library and remove the binary we embedded.
Comment 7 Jonathan Druart 2024-07-10 12:13:51 UTC
Created attachment 168713 [details] [review]
Bug 37303: Replace po2json with a JS version

When using __() (ie. Gettext.js) we are seeing the translations that are marked as fuzzy.
This is definitely not the expected behaviour.

It happens because (our version of) po2json are old and no longer maintained,
and just embed them.

It seems that the bin we have has been upgraded to a JS version
(different authors).

Test plan:
(replace LANG with your language code)
0. Do not apply this patch
Edit misc/translator/po/LANG-messages-js.po
Mark a string as fuzzy
Edit ./intranet-main.tt and add the following lines inside $(document).ready
  console.log(_("Your string"));
  console.log(__("Your string"));
Replace "Your string" with the string you are actually testing.

Update the templates: `koha-translate --update LANG --dev kohadev && restart_all`

Go to the Koha home page, open the console.

=> Notice that the second log in the console is displaying the fuzzy string.

1. Apply this patch
Install the new version of po2json using `yarn install`
Repeat the previous steps.

=> With this patch applied both logs show the English version of the
string.

Remove fuzzy, update the templates and try again.
Comment 8 Jonathan Druart 2024-07-10 12:14:16 UTC
There is a deprecation warning that should be removed.
Comment 9 Julian Maurice 2024-07-10 12:31:25 UTC
I compared locale_data.js before and after the patch:
with the patch:
* keys are not sorted (does not matter)
* header keys are lowercase (should not matter but needs to be tested)
* header values are trimmed (good)
Other than that they are identical
Comment 10 Julian Maurice 2024-07-10 12:33:48 UTC
(In reply to Julian Maurice from comment #9)
> Other than that they are identical
And other than the fact that fuzzy messages are not included, obviously :)