Bug 29588 - Yesterday and tomorrow in datepicker don't translate
Summary: Yesterday and tomorrow in datepicker don't translate
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Martin Renvoize
URL:
Keywords: rel_21_11_candidate
Depends on: 29478
Blocks:
  Show dependency treegraph
 
Reported: 2021-11-28 22:41 UTC by Katrin Fischer
Modified: 2022-12-12 21:23 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes "or", "Yesterday", "Today" and "Tomorrow" in the flatpickr date selector so they can be translated. (This was because __ was used when _ should have been used (__ is for .js files only)).
Version(s) released in:
22.05.00,21.11.02


Attachments
Bug 29588: (bug 29478 follow-up) Make strings translatable (1.73 KB, patch)
2021-11-30 11:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29588: (bug 29478 follow-up) Make strings translatable (1.78 KB, patch)
2021-12-01 10:48 UTC, David Nind
Details | Diff | Splinter Review
Bug 29588: (bug 29478 follow-up) Make strings translatable (1.84 KB, patch)
2021-12-01 13:16 UTC, Thibaud Guillot
Details | Diff | Splinter Review
Bug 29588: (bug 29478 follow-up) Make strings translatable (1.90 KB, patch)
2021-12-14 14:36 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2021-11-28 22:41:02 UTC
Tomorrow, Yesterday and or in the new Flatpickr datepicker don't translate.

Today does, I am not sure why. I think it should be either only one underscore in an .inc file or it's something else. I tried updating the po files locally, but the strings didn't show up.

++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
@@ -34,6 +34,7 @@
 <!-- / calendar.inc -->
 [% Asset.js("js/calendar.js") | $raw %]
 [% Asset.js("lib/flatpickr/flatpickr.min.js") | $raw %]
+[% Asset.js("lib/flatpickr/shortcut-buttons-flatpickr.min.js") | $raw %]
 <script>
     flatpickr.l10ns.default.weekdays = flatpickr_weekdays;
     flatpickr.l10ns.default.months   = flatpickr_months;
@@ -84,6 +85,38 @@
                 $(on_close_focus).focus();
             }
         },
+        plugins: [
+          ShortcutButtonsPlugin({
+            button: [
+              {
+                label: __("Yesterday")
+              },
+              {
+                label: __("Today")
+              },
+              {
+                label: __("Tomorrow")
+              }
+            ],
+            label: "or",
Comment 1 Andrii Nugged 2021-11-29 20:14:47 UTC
> I tried updating the po files locally, but the strings didn't show up.

It's JS runtime translations, so it goes from ln-LN-messages-js.po to locale_data.js, but it's not detected by the parser (or we should do some magic?)... Let's call for JD for help :), we bumped a lot before release.

I did the update for .po manually and it worked (in ITEM EDIT page for example):


*** fi-FI-messages-js.po.orig
--- fi-FI-messages-js.po
***************
*** 1305,1314 ****
--- 1305,1323 ----
  msgid "Thursday"
  msgstr "Torstai"

+ #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:92
+ msgid "Yesterday"
+ msgstr "Eilen"
+
+ #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:95
  #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:111
  msgid "Today"
  msgstr "Tänään"

+ #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:98
+ msgid "Tomorrow"
+ msgstr "Huomenna"
+
  #: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:291
  #: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:658
  msgid "Today's checkouts"
Comment 2 Andrii Nugged 2021-11-29 20:16:32 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2021-11-29 20:21:07 UTC
(In reply to Andrew Nugged from comment #1)
> > I tried updating the po files locally, but the strings didn't show up.
> 
> It's JS runtime translations, so it goes from ln-LN-messages-js.po to
> locale_data.js, but it's not detected by the parser (or we should do some
> magic?)... Let's call for JD for help :), we bumped a lot before release.

Yes, but a git grep didn't bring the string up in any of the .po files.

The issue might be the file ending. This is an .inc, so it's not parsed as a .js but like a .tt file. This is .js code, but the translation tool doesn't know or expect it (is my guess)

> I did the update for .po manually and it worked (in ITEM EDIT page for
> example):
> 
> 
> *** fi-FI-messages-js.po.orig
> --- fi-FI-messages-js.po
> ***************
> *** 1305,1314 ****
> --- 1305,1323 ----
>   msgid "Thursday"
>   msgstr "Torstai"
> 
> + #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:92
> + msgid "Yesterday"
> + msgstr "Eilen"
> +
> + #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:95
>   #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:111
>   msgid "Today"
>   msgstr "Tänään"
> 
> + #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:98
> + msgid "Tomorrow"
> + msgstr "Huomenna"
> +
>   #: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:291
>   #: koha-tmpl/intranet-tmpl/prog/js/checkouts.js:658
>   msgid "Today's checkouts"
Comment 4 Katrin Fischer 2021-11-29 20:22:05 UTC
Try changing __ to _ maybe?
Comment 5 Andrii Nugged 2021-11-29 20:25:10 UTC
the parallel issue I found: these translations make flatpickr translated on the ITEM EDIT page accordingly to the current language,

but I found strange behavior on the USER EDIT page: it sticks to some language from available (randomly? I am researching) and is ignorant to the current chosen language (wth?)
Comment 6 Katrin Fischer 2021-11-29 20:28:33 UTC
That does sound odd, good luck for the bug hunting! It's a prominent spot, so I hope we can figure it out for .1
Comment 7 Jonathan Druart 2021-11-30 11:10:45 UTC
Created attachment 128102 [details] [review]
Bug 29588: (bug 29478 follow-up) Make strings translatable

"or", "Yesterday", "Today" and "Tomorrow" are not translatable, we are
using __ when _ should be used (__ is for .js files only).

Test plan:
0. Apply the patch
1. cd misc/translator && perl translate update fr-FR
2. Edit misc/translator/po/fr-FR-staff-prog.po
Search for "or", "Yesterday", "Today" and "Tomorrow" and translate them
3. cd misc/translator && perl translate install fr-FR
4. Enable fr-FR (syspref 'language')
5. Edit a patron and an item and confirm that the flatpickr widget has
the strings correctly translated
Comment 8 David Nind 2021-12-01 10:09:43 UTC
For whatever reason I couldn't get "Tomorrow" to translate. I tried it with fr-FR and de-DE - there was a translation for that already available, but it didn't change anything in the staff interface. (All the other ones worked as expected.)
Comment 9 Jonathan Druart 2021-12-01 10:20:30 UTC
(In reply to David Nind from comment #8)
> For whatever reason I couldn't get "Tomorrow" to translate. I tried it with
> fr-FR and de-DE - there was a translation for that already available, but it
> didn't change anything in the staff interface. (All the other ones worked as
> expected.)

Did you remove the fuzzy line?
It should look like that (fr-FR):

62284 #: koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc:38
62285 msgid "Tomorrow"
62286 msgstr "Demain"
Comment 10 David Nind 2021-12-01 10:46:13 UTC
(In reply to Jonathan Druart from comment #9)

> Did you remove the fuzzy line?
> It should look like that (fr-FR):

I didn't - this now works as expected now.

Thanks Jonathan!
Comment 11 David Nind 2021-12-01 10:48:46 UTC
Created attachment 128121 [details] [review]
Bug 29588: (bug 29478 follow-up) Make strings translatable

"or", "Yesterday", "Today" and "Tomorrow" are not translatable, we are
using __ when _ should be used (__ is for .js files only).

Test plan:
0. Apply the patch
1. cd misc/translator && perl translate update fr-FR
2. Edit misc/translator/po/fr-FR-staff-prog.po
Search for "or", "Yesterday", "Today" and "Tomorrow" and translate them
3. cd misc/translator && perl translate install fr-FR
4. Enable fr-FR (syspref 'language')
5. Edit a patron and an item and confirm that the flatpickr widget has
the strings correctly translated

Signed-off-by: David Nind <david@davidnind.com>
Comment 12 Thibaud Guillot 2021-12-01 13:16:48 UTC
Created attachment 128126 [details] [review]
Bug 29588: (bug 29478 follow-up) Make strings translatable

"or", "Yesterday", "Today" and "Tomorrow" are not translatable, we are
using __ when _ should be used (__ is for .js files only).

Test plan:
0. Apply the patch
1. cd misc/translator && perl translate update fr-FR
2. Edit misc/translator/po/fr-FR-staff-prog.po
Search for "or", "Yesterday", "Today" and "Tomorrow" and translate them
3. cd misc/translator && perl translate install fr-FR
4. Enable fr-FR (syspref 'language')
5. Edit a patron and an item and confirm that the flatpickr widget has
the strings correctly translated

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: ThibaudGLT <thibaud.guillot@biblibre.com>
Comment 13 Martin Renvoize 2021-12-14 14:36:43 UTC
Created attachment 128509 [details] [review]
Bug 29588: (bug 29478 follow-up) Make strings translatable

"or", "Yesterday", "Today" and "Tomorrow" are not translatable, we are
using __ when _ should be used (__ is for .js files only).

Test plan:
0. Apply the patch
1. cd misc/translator && perl translate update fr-FR
2. Edit misc/translator/po/fr-FR-staff-prog.po
Search for "or", "Yesterday", "Today" and "Tomorrow" and translate them
3. cd misc/translator && perl translate install fr-FR
4. Enable fr-FR (syspref 'language')
5. Edit a patron and an item and confirm that the flatpickr widget has
the strings correctly translated

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: ThibaudGLT <thibaud.guillot@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Martin Renvoize 2021-12-14 14:37:18 UTC
Man.. that's an easy hole to fall into!

Works as expected now, Passing QA
Comment 15 Fridolin Somers 2021-12-22 07:11:34 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 16 Kyle M Hall 2022-01-07 11:14:05 UTC
Pushed to 21.11.x for 21.11.02
Comment 17 Andrew Fuerste-Henry 2022-01-10 15:38:59 UTC
Missing dependency, not backported to 21.05.x