From 6ecd08fb2da70d6aecea84fa929cbc66621812ff Mon Sep 17 00:00:00 2001
From: Owen Leonard
Date: Fri, 15 Aug 2025 16:18:46 +0000
Subject: [PATCH] Bug 40610: Update OPAC templates to improve ease of
translation
This patch updates the markup structure of some OPAC include files in
order to make the translation process easier.
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
> perl misc/translator/translate update fr-FR
- Open the corresponding .po file for the strings pulled from
the include file and locate the updated strings.
- misc/translator/po/fr-FR-messages.po
- opac-tmpl/bootstrap/en/includes/biblio-title.inc lines 4 & 5
- opac-tmpl/bootstrap/en/includes/date-format.inc lines 4, 6, 8
- opac-tmpl/bootstrap/en/includes/holds-table.inc lines 132 & 135
- opac-tmpl/bootstrap/en/includes/masthead.inc line 498
- misc/translator/po/fr-FR/fr-FR-opac-bootstrap.po
- opac-tmpl/bootstrap/en/includes/biblio-title-head.inc
- opac-tmpl/bootstrap/en/includes/holds-table.inc line 129 & 141
- Edit the "msgstr" string however you want (it's just for testing).
- Remove the "fuzzy, " text if it's there.
- Install the updated translation:
> perl mis/translator/translate install fr-FR
- Switch to your translated language in the OPAC.
- Confirm that the strings you translated show up correctly on these
pages:
- The page title when viewing a bibliographic record detail page for
a record without a title.
- On a user summary page, under the hold tab:
- A hold that is waiting
- A hold that is in transit
- In Administration -> Identity providers define a new identity provider
(it doesn't have to be functional).
- In the OPAC, test that the "Log in with [identity provider]" link is
correct in each of the three login forms:
- The modal triggered from the link in the header
- The form in the right-hand sidebar
- The form you see if you navigate directly to a user-related page
e.g. /cgi-bin/koha/opac-user.pl
- The changes to date-format.inc are only visible if JS is turned off
because Flatpickr hides the format hint when it loads.
Sponsored-by: Athens County Public Libraries
---
.../bootstrap/en/includes/biblio-title-head.inc | 3 ++-
.../opac-tmpl/bootstrap/en/includes/biblio-title.inc | 2 +-
.../opac-tmpl/bootstrap/en/includes/date-format.inc | 12 +++++++++++-
.../opac-tmpl/bootstrap/en/includes/holds-table.inc | 12 +++++++-----
.../opac-tmpl/bootstrap/en/includes/masthead.inc | 2 +-
.../opac-tmpl/bootstrap/en/modules/opac-auth.tt | 2 +-
.../opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +-
7 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title-head.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title-head.inc
index 1ef7664a317..64d0ae93d6f 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title-head.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title-head.inc
@@ -1,7 +1,8 @@
+[% PROCESS 'i18n.inc' %]
[% IF ( biblio.title ) %]
[% biblio.title | html %]
[% ELSE %]
- No title
+ [% t("No title") | html %]
[% END %]
[%~ SET subtitles = biblio.subtitle.split(' \| ') ~%]
[%~ FOREACH subtitle IN subtitles ~%]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc
index d37640599f1..1151a00e70f 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc
@@ -2,7 +2,7 @@
[%- IF ( link ) -%]
[% PROCESS 'show-biblio-title' %]
[%- ELSIF (deleted) -%]
- (Deleted bibliographic record) [%- PROCESS 'show-biblio-title' -%]
+ [% t("(Deleted bibliographic record)") | html %] [%- PROCESS 'show-biblio-title' -%]
[%- ELSE -%]
[%- PROCESS 'show-biblio-title' -%]
[%- END -%]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc
index f651b74eb0c..c31490acadc 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc
@@ -1 +1,11 @@
-[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSE %](YYYY-MM-DD)[% END %]
+[% FILTER collapse %]
+
+ [% IF ( dateformat == "us" ) %]
+ [% t("(MM/DD/YYYY)") | html %]
+ [% ELSIF ( dateformat == "metric" ) %]
+ [% t("(DD/MM/YYYY)") | html %]
+ [% ELSE %]
+ [% t("(YYYY-MM-DD)") | html %]
+ [% END %]
+
+[% END %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc
index 1bafd09778d..8af1f45138c 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc
@@ -88,7 +88,7 @@
[% IF ( HOLD.expirationdate ) %]
[% HOLD.expirationdate | $KohaDates %]
[% ELSE %]
- Never expires
+ Never expires
[% END %]
[% ELSE %]
-
@@ -143,17 +143,19 @@
[% IF ( HOLD.is_waiting ) %]
[% IF ( HOLD.is_at_destination ) %]
- Item waiting at [% HOLD.branch.branchname | html %]
+ Item waiting at [% HOLD.branch.branchname | html %]
[% IF ( HOLD.desk_id ) %], [% HOLD.desk.desk_name | html %],[% END %]
[% IF ( HOLD.waitingdate ) %]
- since [% HOLD.waitingdate | $KohaDates %]
+ [% tp("On hold since [waiting date]", "since") | html %]
+ [% HOLD.waitingdate | $KohaDates %]
[% IF HOLD.expirationdate %]
- until [% HOLD.expirationdate | $KohaDates %]
+ [% tp("On hold until [expiration date]", "until") | html %]
+ [% HOLD.expirationdate | $KohaDates %]
[% END %]
[% END %]
[% ELSE %]
- Item in transit to [% Branches.GetName( HOLD.branchcode ) | html %]
+ Item in transit to [% Branches.GetName( HOLD.branchcode ) | html %]
[% END %]
[% ELSE %]
[% IF ( HOLD.is_in_transit ) %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
index c136dfeb29a..b018deb213e 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc
@@ -495,7 +495,7 @@
[% ELSE %]
[% END %]
- Log in with [% provider.description | html %]
+ [% tx("Log in with {identity_provider}", { identity_provider = provider.description } ) | html %]
[% END %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt
index 6d6c135cc1a..2c61dbf1573 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt
@@ -182,7 +182,7 @@
[% ELSE %]
[% END %]
- Log in with [% provider.description | html %]
+ [% tx("Log in with {identity_provider}", { identity_provider = provider.description } ) | html %]
[% END %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt
index c41dc43e9f3..6a2cb42f3ab 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt
@@ -189,7 +189,7 @@
[% ELSE %]
[% END %]
- Log in with [% provider.description | html %]
+ [% tx("Log in with {identity_provider}", { identity_provider = provider.description } ) | html %]
[% END %]
--
2.39.5