Bug 37926 - Bookings - "to" untranslatable
Summary: Bookings - "to" untranslatable
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Owen Leonard
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-13 20:53 UTC by Caroline Cyr La Rose
Modified: 2025-08-13 19:41 UTC (History)
6 users (show)

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


Attachments
Bug 37926: Allow for translation of "to" in date range selection (3.44 KB, patch)
2025-06-09 11:57 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 37926: Allow for translation of "to" in date range selection (3.43 KB, patch)
2025-06-10 13:08 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 37926: Allow for translation of "to" in date range selection (3.48 KB, patch)
2025-06-12 20:09 UTC, David Flater
Details | Diff | Splinter Review
Bug 37926: Allow for translation of "to" in date range selection (3.58 KB, patch)
2025-08-04 08:27 UTC, Marcel de Rooy
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-09-13 20:53:37 UTC
When placing a booking, where we choose the dates of the booking, the "to" between the two dates is not translatable.

To get there:

1. In a detailed record, click on the Items tab on the left

2. Where it says Bookable, choose Yes and click Update

3. Click Place booking

4. Find and select a patron to enable the other fields

5. Under Booking dates, choose two dates
   --> Dates are displayed as date1 to date2

6. Translate the interface

gulp po:update --lang fr-CA

./misc/translator/translate update fr-CA

7. In the system preference StaffInterfaceLanguage, select the other language and click Save all I18N/L10N preferences

8. Change the interface in the other language

9. Redo steps 3 to 5
   --> Dates are still displayed as date1 to date2


I searched the various po files, but I didn't take the time to check all occurrences of "to", obviously. I mostly searched for "%s to %s" and modals/place_booking.inc.
Comment 1 Owen Leonard 2025-06-09 11:57:03 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2025-06-10 13:08:34 UTC
Created attachment 183129 [details] [review]
Bug 37926: Allow for translation of "to" in date range selection

When a calendar widget has been initiated as a date range selector (as
it is when creating a new booking), the selected dates are added to the
input field as "0000-00-00 to 0000-00-00". This "to" needs to be
translatable.

To test, apply the patch and test that the correct strings are
translatable. In this example I'm testing fr-FR:

- Update a translation:
 > gulp po:update --lang fr-FR
 > cd misc/translator
 > perl translate update fr-FR

- Open the corresponding .po file for the strings pulled from
  JavaScript  e.g.  misc/translator/po/fr-FR-messages-js.po
  - Locate strings pulled from intranet-tmpl/prog/js/calendar.js for
    translation, e.g.:

    #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:144
    msgctxt "As in, from date1 to date2"
    msgid "to"
    msgstr ""

    - Edit the "msgstr" string however you want (it's just for testing)
    - Install the updated translation:

    > perl translate install fr-FR

- In the staff interface, locate an bibliographic record with items and
  change the "Bookable" option from the item details screen.
- Switch to your updated translation in the staff interface.
- Click the "Place booking" button.
- Fill out all the fields in the "Place booking" modal.
- After you select a date range, the "Booking dates" input field should
  show your translated text.

Sponsored-by: Athens County Public Libraries
Comment 3 David Flater 2025-06-12 20:09:51 UTC
Created attachment 183216 [details] [review]
Bug 37926: Allow for translation of "to" in date range selection

When a calendar widget has been initiated as a date range selector (as
it is when creating a new booking), the selected dates are added to the
input field as "0000-00-00 to 0000-00-00". This "to" needs to be
translatable.

To test, apply the patch and test that the correct strings are
translatable. In this example I'm testing fr-FR:

- Update a translation:
 > gulp po:update --lang fr-FR
 > cd misc/translator
 > perl translate update fr-FR

- Open the corresponding .po file for the strings pulled from
  JavaScript  e.g.  misc/translator/po/fr-FR-messages-js.po
  - Locate strings pulled from intranet-tmpl/prog/js/calendar.js for
    translation, e.g.:

    #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:144
    msgctxt "As in, from date1 to date2"
    msgid "to"
    msgstr ""

    - Edit the "msgstr" string however you want (it's just for testing)
    - Install the updated translation:

    > perl translate install fr-FR

- In the staff interface, locate an bibliographic record with items and
  change the "Bookable" option from the item details screen.
- Switch to your updated translation in the staff interface.
- Click the "Place booking" button.
- Fill out all the fields in the "Place booking" modal.
- After you select a date range, the "Booking dates" input field should
  show your translated text.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Flater <flaterdavid@gmail.com>
Comment 4 Marcel de Rooy 2025-08-01 09:26:09 UTC
Hi Owen,

How is this __p call supposed to work:
+    " " + __p("As in, from date1 to date2", "to") + " ";

The As in.. is provided as context? How does that match work?
How should the translation file look ?
Comment 5 Owen Leonard 2025-08-01 11:19:07 UTC
>   - Locate strings pulled from intranet-tmpl/prog/js/calendar.js for
>     translation, e.g.:
> 
>     #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:144
>     msgctxt "As in, from date1 to date2"
>     msgid "to"
>     msgstr ""
Comment 6 Marcel de Rooy 2025-08-04 08:26:08 UTC
(In reply to Owen Leonard from comment #5)
> >   - Locate strings pulled from intranet-tmpl/prog/js/calendar.js for
> >     translation, e.g.:
> > 
> >     #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:144
> >     msgctxt "As in, from date1 to date2"
> >     msgid "to"
> >     msgstr ""

Ok, thanks. So if someone wants to use this translation on another page in a date range context, he should know that he needs to add this specific context string "As in, from date1 to date2". As the use of these context translations increases, we will probably need some more direction on how to formulate them for efficient use.
Comment 7 Marcel de Rooy 2025-08-04 08:27:23 UTC
Created attachment 185087 [details] [review]
Bug 37926: Allow for translation of "to" in date range selection

When a calendar widget has been initiated as a date range selector (as
it is when creating a new booking), the selected dates are added to the
input field as "0000-00-00 to 0000-00-00". This "to" needs to be
translatable.

To test, apply the patch and test that the correct strings are
translatable. In this example I'm testing fr-FR:

- Update a translation:
 > gulp po:update --lang fr-FR
 > cd misc/translator
 > perl translate update fr-FR

- Open the corresponding .po file for the strings pulled from
  JavaScript  e.g.  misc/translator/po/fr-FR-messages-js.po
  - Locate strings pulled from intranet-tmpl/prog/js/calendar.js for
    translation, e.g.:

    #: koha-tmpl/intranet-tmpl/prog/js/calendar.js:144
    msgctxt "As in, from date1 to date2"
    msgid "to"
    msgstr ""

    - Edit the "msgstr" string however you want (it's just for testing)
    - Install the updated translation:

    > perl translate install fr-FR

- In the staff interface, locate an bibliographic record with items and
  change the "Bookable" option from the item details screen.
- Switch to your updated translation in the staff interface.
- Click the "Place booking" button.
- Fill out all the fields in the "Place booking" modal.
- After you select a date range, the "Booking dates" input field should
  show your translated text.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Flater <flaterdavid@gmail.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Lucas Gass (lukeg) 2025-08-13 19:41:22 UTC
Nice work everyone!

Pushed to main for 25.11