See bug 30958 and bug 23713: The construct with the 0 will break on translation as it's removed in the translated templates: > The problematic line (below) in the English template is: > var OD_password_required = [% IF > Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %]0[% END %]; > > Which is translated to the following in the en-NZ (and other languages) > template: > var OD_password_required = [% IF > Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %][% END %]; We should verify that there are not more occurences of the bad pattern or improve our translation scripts: (In reply to Owen Leonard from comment #3) > There are a couple of other instances that I saw which should also be > addressed. I searched the NZ templates for "1[% ELSE %][% END %]"
Created attachment 136408 [details] [review] Bug 30991: Fix remaining instances of [% ELSE %]0[% END %] in templates The construct of [% ELSE %]0[% END %] breaks translations as it is translated as [% ELSE %][% END %]. Note: No 0 in the ELSE statement. This patchset either removes occurances of a lone 0 in template ELSE statements, or splits it over multiple lines so the 0 is not removed in the translated templates. Test plan: 1. Install the en-NZ translation 2. Search the translated templates for '[% ELSE %][% END %]' and confirm there are are instances of that 3. Apply patch 4. Update your en-NZ translation 5. Repeat step 2 and confirm there are no more instances of [% ELSE %][% END %] in the translated templates Note: I removed the [% ELSE %] statement from opac-bottom.inc as that statement was empty in the en translation so it didn't look to be needed. Sponsored-by: Catalyst IT, New Zealand
Created attachment 136429 [details] [review] Bug 30991: Fix remaining instances of [% ELSE %]0[% END %] in templates The construct of [% ELSE %]0[% END %] breaks translations as it is translated as [% ELSE %][% END %]. Note: No 0 in the ELSE statement. This patchset either removes occurances of a lone 0 in template ELSE statements, or splits it over multiple lines so the 0 is not removed in the translated templates. Test plan: 1. Install the en-NZ translation 2. Search the translated templates for '[% ELSE %][% END %]' and confirm there are are instances of that 3. Apply patch 4. Update your en-NZ translation 5. Repeat step 2 and confirm there are no more instances of [% ELSE %][% END %] in the translated templates Note: I removed the [% ELSE %] statement from opac-bottom.inc as that statement was empty in the en translation so it didn't look to be needed. Sponsored-by: Catalyst IT, New Zealand Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 136554 [details] [review] Bug 30991: Fix remaining instances of [% ELSE %]0[% END %] in templates The construct of [% ELSE %]0[% END %] breaks translations as it is translated as [% ELSE %][% END %]. Note: No 0 in the ELSE statement. This patchset either removes occurances of a lone 0 in template ELSE statements, or splits it over multiple lines so the 0 is not removed in the translated templates. Test plan: 1. Install the en-NZ translation 2. Search the translated templates for '[% ELSE %][% END %]' and confirm there are are instances of that 3. Apply patch 4. Update your en-NZ translation 5. Repeat step 2 and confirm there are no more instances of [% ELSE %][% END %] in the translated templates Note: I removed the [% ELSE %] statement from opac-bottom.inc as that statement was empty in the en translation so it didn't look to be needed. Sponsored-by: Catalyst IT, New Zealand Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Pushed to master for 22.11. Nice work everyone, thanks!
Backported to 22.05.x for 22.05.04
conflicts when trying to apply to 21.11.x. please provide backport if needed.
I do understand what we are doing on bug 23713. But here we are simply splitting the rule on different lines. That is not fixing the problem in the long term.
I mean, it's not solid for future changes, another author can put the statement back on one line.
(In reply to Jonathan Druart from comment #8) > I mean, it's not solid for future changes, another author can put the > statement back on one line. Maybe this would be a little more solid? - var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired') %]1[% ELSE %]0[% END %]; + [%- IF Koha.Preference('OverDrivePasswordRequired') -%] + var OD_password_required = 1; + [%- ELSE -%] + var OD_password_required = 0; + [%- END -%] I have an open issue with those 0 too: Bug 31563 - Numbers on claims tab not showing in translated templates
Comment on attachment 136554 [details] [review] Bug 30991: Fix remaining instances of [% ELSE %]0[% END %] in templates Review of attachment 136554 [details] [review]: ----------------------------------------------------------------- ::: koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ +1307,5 @@ > + [%- IF Koha.Preference('OverDrivePasswordRequired') -%] > + var OD_password_required = 1; > + [%- ELSE -%] > + var OD_password_required = 0; > + [%- END -%] I know it's after the fact, but would something like the following be a viable alternative with the translation tools? var OD_password_required = [% IF Koha.Preference('OverDrivePasswordRequired'); '1'; ELSE; '0'; END; %];