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>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 00bb254149)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Owen Leonard 2025-06-06 14:36:38 +00:00 committed by Paul Derscheid
parent f60f9c624e
commit 120a4f86c6
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 7 additions and 3 deletions

View File

@ -43,8 +43,9 @@
[% Asset.js("lib/maskito/maskito.core.js") | $raw %]
[% Asset.js("lib/maskito/maskito.kit.js") | $raw %]
<script>
flatpickr.l10ns.default.weekdays = flatpickr_weekdays;
flatpickr.l10ns.default.months = flatpickr_months;
flatpickr.l10ns.default.weekdays = flatpickr_weekdays;
flatpickr.l10ns.default.months = flatpickr_months;
flatpickr.l10ns.default.rangeSeparator = flatpickr_rangeSeparator;
let flatpickr_defaults = {
allowInput: true,
dateFormat: "Y-m-d",

View File

@ -1,4 +1,4 @@
/* global debug sentmsg __ dateformat_pref flatpickr_dateformat_string bidi calendarFirstDayOfWeek */
/* global debug sentmsg __ dateformat_pref flatpickr_dateformat_string bidi calendarFirstDayOfWeek __p */
/* exported DateTime_from_syspref flatpickr_weekdays flatpickr_months */
var MSG_PLEASE_ENTER_A_VALID_DATE = __(
"Please enter a valid date (should match %s)."
@ -141,6 +141,9 @@ jQuery.validator.addMethod(
}
);
var flatpickr_rangeSeparator =
" " + __p("As in, from date1 to date2", "to") + " ";
var flatpickr_weekdays = {
shorthand: [
__("Sun"),