Bug 37781 - Add translation context for "On" (when used alone)
Summary: Add translation context for "On" (when used alone)
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Caroline Cyr La Rose
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-29 19:01 UTC by Caroline Cyr La Rose
Modified: 2024-09-16 08:54 UTC (History)
2 users (show)

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


Attachments
Bug 37781: Add translation context for "On" (when used alone) (2.82 KB, patch)
2024-08-29 20:41 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 37781: Add translation context for "On" (when used alone) (3.90 KB, patch)
2024-09-04 14:51 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 37781: Add translation context for "On" (when used alone) (3.91 KB, patch)
2024-09-09 03:59 UTC, David Nind
Details | Diff | Splinter Review
Bug 37781: Add translation context for "On" (when used alone) (3.98 KB, patch)
2024-09-09 11:37 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 Caroline Cyr La Rose 2024-08-29 19:01:48 UTC
There are two places (according to the translation tool) that have the string "On" used alone. The two cases have different contexts:

In smtp_servers.tt, "On" is used in opposition to "Off" for the debugging mode.

In itemsearch.tt, "On" is used for a date, "After [date]", "Before [date]", "On [date]"

In French these would be two different words, but as it is, the same string is used in both cases.
Comment 1 Katrin Fischer 2024-08-29 19:08:22 UTC
+1
Comment 2 Caroline Cyr La Rose 2024-08-29 20:41:19 UTC
Created attachment 170881 [details] [review]
Bug 37781: Add translation context for "On" (when used alone)

This patch adds context to the string "On" used alone in the item search
page, to mean "On a specific date".

To test:
1. Update translation files

gulp po:update --lang fr-CA

2. Check the staff-prog.po file and search for "On".

vi misc/translator/po/fr-CA-staff-prog.po

/"On"

--> It should be in three places, two in itemsearch.tt and one in smtp_servers.tt

38415 #. For the first occurrence,
38416 #. SCRIPT
38417 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:327
38418 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
38419 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
38420 #, c-format
38421 msgid "On"
38422 msgstr "Sur "

3. Apply patch
4. Reupdate po files

gulp po:update --lang fr-CA

5. Check the messages.po file and search for "On"

--> There should be a msgctxt line that adds context to the "On" (please ignore the translated msgstr, I have no idea how it decides what to put in there!)

6266 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
6267 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
6268 #, fuzzy
6269 msgctxt "On specific date"
6270 msgid "On"
6271 msgstr "Oman"

6. Also check the item search page
   --> It should still work and the "On" in the last borrowed date drop-down should still say "On"

7. Optionally, translate the string and remove the "#fuzzy", install the translation and check the item search page
   --> It should use the string you put in
Comment 3 Caroline Cyr La Rose 2024-08-29 21:00:54 UTC
I made a patch for the itemsearch.tt page, but I need help for the smtp_servers.tt page.

I tried to change 

return _("On");

for 

return _("On","Active");
return _p("Active", "On");
return _p('Active', 'On');
return __p("Active","On");
return __p('Active','On');
...

All of these effectively remove the string from fr-CA-staff-prog.po, but they don't add it back with the context in messages.po or message-js.po.
Comment 4 Jonathan Druart 2024-09-03 08:09:00 UTC
If you are in a .tt files writing JS code, you cannot use the JS functions defined in i18n.js (__, __p, etc.)
Only strings within _() will be picked.

You can however use the TT plugin: tp("Active", "On")

Full code would be:

  "data": function( row, type, val, meta ) {
      if ( row.debug ) {
          return "[% tp("Active", "On") | html %]";
      }
      else {
          return "[% tp("Active", "Off") | html %]";
      }
  },

% gulp po:update --lang fr-FR

% git grep -C 2 'msgctxt "Active"' fr-FR*
fr-FR-messages.po-#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:404
fr-FR-messages.po-#, fuzzy
fr-FR-messages.po:msgctxt "Active"
fr-FR-messages.po-msgid "On"
fr-FR-messages.po-msgstr "Oman"
fr-FR-messages.po-
fr-FR-messages.po-#: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:407
fr-FR-messages.po:msgctxt "Active"
fr-FR-messages.po-msgid "Off"
fr-FR-messages.po-msgstr ""

(No idea where "Oman" is coming from!)
Comment 5 Caroline Cyr La Rose 2024-09-04 14:51:48 UTC
Created attachment 171033 [details] [review]
Bug 37781: Add translation context for "On" (when used alone)

This patch adds context to the string "On" used alone in the item search
page, to mean "On a specific date".

To test:
1. Update translation files

gulp po:update --lang fr-CA

2. Check the staff-prog.po file and search for "On".

vi misc/translator/po/fr-CA-staff-prog.po

/"On"

   --> It should be in three places, two in itemsearch.tt and
       one in smtp_servers.tt

 #. For the first occurrence,
 #. SCRIPT
 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:327
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
 #, c-format
 msgid "On"
 msgstr "Sur "

3. Apply patch
4. Reupdate po files

gulp po:update --lang fr-CA

5. Check the messages.po file and search for "On"

    --> There should be a msgctxt line that adds context to the
        "On" (please ignore the translated msgstr, I have no idea
        how it decides what to put in there!)

 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:404
 #, fuzzy
 msgctxt "Active"
 msgid "On"
 msgstr "Oman"

 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
 #, fuzzy
 msgctxt "On specific date"
 msgid "On"
 msgstr "Oman"

6. Also check the item search page
   --> It should still work and the "On" in the last borrowed date
       drop-down should still say "On"

7. In the SMTP servers page, add a server and enable the "Debug" mode.
   --> In the list of servers, the Debug column should still say simply
       "On"

8. Optionally, translate the string and remove the "#fuzzy" line,
   install the translation and check the item search page
   --> It should use the string you put in

Bug 37781: Add translation context for "On" (when used alone)
Comment 6 Caroline Cyr La Rose 2024-09-04 14:54:09 UTC
Thanks Jonathan! 

I added the context like you said and it works (not sure where the Oman comes from either lol).

I had to do a little bit of more advanced git, hopefully I didn't lose anything and didn't make a mess of things either...
Comment 7 David Nind 2024-09-09 03:59:23 UTC
Created attachment 171169 [details] [review]
Bug 37781: Add translation context for "On" (when used alone)

This patch adds context to the string "On" used alone in the item search
page, to mean "On a specific date".

To test:
1. Update translation files

gulp po:update --lang fr-CA

2. Check the staff-prog.po file and search for "On".

vi misc/translator/po/fr-CA-staff-prog.po

/"On"

   --> It should be in three places, two in itemsearch.tt and
       one in smtp_servers.tt

 #. For the first occurrence,
 #. SCRIPT
 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:327
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
 #, c-format
 msgid "On"
 msgstr "Sur "

3. Apply patch
4. Reupdate po files

gulp po:update --lang fr-CA

5. Check the misc/translator/po/fr-CA-messages.po file and search for "On"

    --> There should be a msgctxt line that adds context to the
        "On" (please ignore the translated msgstr, I have no idea
        how it decides what to put in there!)

 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:404
 #, fuzzy
 msgctxt "Active"
 msgid "On"
 msgstr "Oman"

 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
 #, fuzzy
 msgctxt "On specific date"
 msgid "On"
 msgstr "Oman"

6. Also check the item search page
   --> It should still work and the "On" in the last borrowed date
       drop-down should still say "On"

7. In the SMTP servers page, add a server and enable the "Debug" mode.
   --> In the list of servers, the Debug column should still say simply
       "On"

8. Optionally, translate the string and remove the "#fuzzy" line,
   install the translation and check the item search page
   --> It should use the string you put in

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 Jonathan Druart 2024-09-09 11:37:24 UTC
Created attachment 171188 [details] [review]
Bug 37781: Add translation context for "On" (when used alone)

This patch adds context to the string "On" used alone in the item search
page, to mean "On a specific date".

To test:
1. Update translation files

gulp po:update --lang fr-CA

2. Check the staff-prog.po file and search for "On".

vi misc/translator/po/fr-CA-staff-prog.po

/"On"

   --> It should be in three places, two in itemsearch.tt and
       one in smtp_servers.tt

 #. For the first occurrence,
 #. SCRIPT
 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:327
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
 #, c-format
 msgid "On"
 msgstr "Sur "

3. Apply patch
4. Reupdate po files

gulp po:update --lang fr-CA

5. Check the misc/translator/po/fr-CA-messages.po file and search for "On"

    --> There should be a msgctxt line that adds context to the
        "On" (please ignore the translated msgstr, I have no idea
        how it decides what to put in there!)

 #: koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt:404
 #, fuzzy
 msgctxt "Active"
 msgid "On"
 msgstr "Oman"

 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:322
 #: koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt:324
 #, fuzzy
 msgctxt "On specific date"
 msgid "On"
 msgstr "Oman"

6. Also check the item search page
   --> It should still work and the "On" in the last borrowed date
       drop-down should still say "On"

7. In the SMTP servers page, add a server and enable the "Debug" mode.
   --> In the list of servers, the Debug column should still say simply
       "On"

8. Optionally, translate the string and remove the "#fuzzy" line,
   install the translation and check the item search page
   --> It should use the string you put in

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Katrin Fischer 2024-09-16 08:54:16 UTC
Pushed for 24.11!

Well done everyone, thank you!