Bug 33237 - If TranslateNotices is off, use the default language includes in slips
Summary: If TranslateNotices is off, use the default language includes in slips
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major
Assignee: Hammat wele
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords: rel_23_11_candidate
Depends on:
Blocks: 36732 36733 36815 36520
  Show dependency treegraph
 
Reported: 2023-03-15 16:23 UTC by Caroline Cyr La Rose
Modified: 2024-07-25 11:11 UTC (History)
13 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This patch set cleans up the way languages are chosen and used in includes when printing slips. Previously, if the system preference 'TranslateNotices' was turned off (meaning the patron had their language set to 'Default'), the includes texts would be in English, even if the library had written their notices in a different language e.g. French. With this patch set, the language used for includes will always match the language used for creating the notice itself, regardless of whether 'TranslateNotices' is turned on or off. This patch set also makes important changes to the logic used to set the language. With this patch, the notice will: 1. use patron's preferred language 2. if patron's preferred language is 'default', use the first language in 'language' system preference. This patch set also adds the display of 'Default language' to the language that will be marked as 'Default' in the notices editor tool so that the librarian writing a notice will know exactly which language will be used when printing slips. Please note that due to these changes it is no longer possible to print the slip in any installed language simply by switching the staff interface language before printing! Bug 36733 has been added as a follow-up for restoring this functionality.
Version(s) released in:
24.05.00,23.11.07
Circulation function:


Attachments
Screenshot of ACCOUNT_CREDIT with untranslated parts in yellow (47.95 KB, image/png)
2023-03-16 17:56 UTC, Caroline Cyr La Rose
Details
Bug 33237: If TranslateNotices is off, use the interface language includes in slips (3.42 KB, patch)
2023-03-27 21:07 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 33237: If TranslateNotices is off, use the interface language includes in slips (3.48 KB, patch)
2024-03-26 17:55 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Tidy (1.01 KB, patch)
2024-03-26 17:55 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Unit tests (3.35 KB, patch)
2024-04-08 16:44 UTC, Hammat wele
Details | Diff | Splinter Review
Bug 33237: TMP Fix for Budget test failing in main (1.32 KB, patch)
2024-04-23 12:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Restore final fallback (1.43 KB, patch)
2024-04-23 12:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (QA follow-up) Clarify tests (5.02 KB, patch)
2024-04-23 12:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: TMP Fix for Budget test failing in main (1.32 KB, patch)
2024-04-23 15:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Restore final fallback (1.43 KB, patch)
2024-04-23 15:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (QA follow-up) Clarify tests and Mock (162.49 KB, patch)
2024-04-23 15:16 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: If TranslateNotices is off, use the interface language includes in slips (3.55 KB, patch)
2024-04-24 13:46 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Tidy (1.07 KB, patch)
2024-04-24 13:46 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Unit tests (3.42 KB, patch)
2024-04-24 13:47 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Restore final fallback (1.43 KB, patch)
2024-04-24 13:47 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (QA follow-up) Clarify tests and Mock (162.49 KB, patch)
2024-04-24 13:47 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: Add display of which language default language is expected (4.71 KB, patch)
2024-04-24 13:47 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: If TranslateNotices is off, use the interface language includes in slips (3.55 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Tidy (1.07 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Unit tests (3.42 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (follow-up) Restore final fallback (1.49 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (QA follow-up) Clarify tests and Mock (162.56 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: Add display of which language default language is expected (5.53 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: Rearrange unit tests and ensure consistency (9.54 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: Move and simplify langauge selection logic (2.33 KB, patch)
2024-04-24 15:45 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33237: (QA follow-up) Remove hardcoded kohadevbox path (1.24 KB, patch)
2024-05-17 06:34 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 2023-03-15 16:23:13 UTC
Most of our clients use Koha in one language only (French) and their patrons are also all french-speakers. So they don't use TranslateNotices, since they don't need to print slips in different languages.

However, if TranslateNotices is off, the translations for "includes" (in my specific example, account types), are not taken into consideration and print in English. Same if TranslateNotices is on, but the patron's language is Default.

In those cases, shouldn't it use the interface language rather than just print in English?

To replicate:
1. Install the other language (i used fr-CA here)
     1.1. 

     gulp po:update fr-CA

     ./misc/translator/translate install fr-CA

     1.2. In Administration > Global system preferences, search for language and check the added language

2. Create a manual invoice in a patron's account and pay it

3. From the Transactions tab, click 'Print' next to the payment line

   --> On the printed slip, the title is "Payment receipt" (OK)

4. Switch interface to other language

5. Redo step 3

   --> On the printed slip, the title is still "Payment receipt" (not ok)

6. In Administration > Global system preferences, enable TranslateNotices

7. Go to Tools > Notices and slips > ACCOUNT_CREDIT and copy the content of the letter into all the languages

8. Redo step 3 (you should still be in the other language interface)

   --> On the printed slip, the title is still "Payment receipt" (not ok?)

9. Edit the patron's account and change the preferred language to the other language

10. Redo step 3

    --> On the printed slip, the title is "Paiement receipt" (OK)


On step 3, the account type is in English in the English interface (OK)

On step 5, the account type is in English in the other interface, with TranslateNotices off, I feel like the slip should take the interface into account in this case for the include...

On step 8, TranslateNotices is on, but the patron's language is Default, I feel like this should also take into account the interface language...

On step 10, TranslateNotices is on and patron language is set, these are currently the only settings which allow to have the accounttypes in the other language.
Comment 1 Caroline Cyr La Rose 2023-03-15 16:52:16 UTC
I consider this a bug (especially the one where TranslateNotices is off). If I'm the outlier, then I'd like to propose that we add a default language choice in the patron categories (like we do for messaging preferences) so that we don't have to change the preferred language for each and every new patron.

Since "default" is basically "English", unilingual non-english libraries absolutely need to change the patron's preferred language, they can't leave it at default.
Comment 3 Katrin Fischer 2023-03-16 14:34:19 UTC
Hm, I think the interface language is the best we could do in these cases and should work for our libraries as well. Our OPACs are usually at least English and German, but notices are often German only. The current behavior would therefore give us some trouble, but interface language should work ok.

Another alternative might be to use the "first" language in the language selection as default for these cases.

You can reorder them and the first in the list is, I think, also the fallback in other cases. So that might also work.
Comment 4 Caroline Cyr La Rose 2023-03-16 14:44:52 UTC
So if TranslateNotices is off, use interface language

if TranslateNotices is on, use first language as "default"

Would that be ok?
Comment 5 Caroline Cyr La Rose 2023-03-16 17:55:21 UTC
--> check patron's preferred language
--> if patron's preferred language is "default", check interface language
--> if no interface (for overdue_notices for example), check first language in "language" system preference

No need to check for TranslateNotices since borrowers.lang is always filled no matter what. If the pref is off, all the patrons' preferred languages will be "default".

Note that this bug is not for the notice templates. This already works well. It's only for the "includes" included in the templates. In my example, I used ACCOUNT_CREDIT template which uses accounts.inc to print the credit or debit account type. These are all translated in koha-tmpl/intranet-tmpl/prog/{lang}/includes/accounts.inc but only the english file is used in the slips, making all accounttypes (payment, lost item, manual fee, etc.) print in english no matter the language of the template. I added a screenshot of ACCOUNT_CREDIT with the parts that are currently not translated unless TranslateNotices is on and the patron has the correct preferred language in yellow.
Comment 6 Caroline Cyr La Rose 2023-03-16 17:56:12 UTC
Created attachment 148281 [details]
Screenshot of ACCOUNT_CREDIT with untranslated parts in yellow
Comment 7 Hammat wele 2023-03-27 21:07:02 UTC
Created attachment 148785 [details] [review]
Bug 33237: If TranslateNotices is off, use the interface language includes in slips

This patch set the language used in slips folloinw this logic:
   --> uses patron's preferred language
   --> if patron's preferred language is 'default', use the interface language
   --> if there is no interface (for overdue_notices for example), use the first language in 'language' system preference

To Test:
1. Install the other language (i used fr-CA here)
     1.1.

     gulp po:update fr-CA

     ./misc/translator/translate install fr-CA

     1.2. In Administration > Global system preferences, search for language and check the added language

2. Create a manual invoice in a patron's account and pay it

3. From the Transactions tab, click 'Print' next to the payment line
   --> On the printed slip, there's the word 'Payment' in English (OK)

4. Switch interface to other language

5. Redo step 3
   --> On the printed slip, the word 'Payment' is still in English (not ok)

6. In Administration > Global system preferences, enable TranslateNotices

7. Go to Tools > Notices and slips > ACCOUNT_CREDIT and copy the content of the letter into all the languages

8. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is still in English (not ok)

9. Edit the patron's account and change the preferred language to the other language

10. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement) (OK)

11. Apply the patch

12. Reset config
    12.1. Edit the patron's account and change back the preferred language to 'default'
    12.2. In Administration > Global system preferences, disable TranslateNotices

13. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

14. Switch interface to the english language

15. Redo step 3
   --> On the printed slip, the word 'Payment' is in English

16. In Administration > Global system preferences, enable TranslateNotices

17. Edit the patron's account and change the preferred language to the other language

18. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)
Comment 8 Martin Renvoize (ashimema) 2024-03-26 16:09:18 UTC
Sorry, can we get some unit tests here.
Comment 9 Nick Clemens (kidclamp) 2024-03-26 17:55:17 UTC
Created attachment 163952 [details] [review]
Bug 33237: If TranslateNotices is off, use the interface language includes in slips

This patch set the language used in slips folloinw this logic:
   --> uses patron's preferred language
   --> if patron's preferred language is 'default', use the interface language
   --> if there is no interface (for overdue_notices for example), use the first language in 'language' system preference

To Test:
1. Install the other language (i used fr-CA here)
     1.1.

     gulp po:update fr-CA

     ./misc/translator/translate install fr-CA

     1.2. In Administration > Global system preferences, search for language and check the added language

2. Create a manual invoice in a patron's account and pay it

3. From the Transactions tab, click 'Print' next to the payment line
   --> On the printed slip, there's the word 'Payment' in English (OK)

4. Switch interface to other language

5. Redo step 3
   --> On the printed slip, the word 'Payment' is still in English (not ok)

6. In Administration > Global system preferences, enable TranslateNotices

7. Go to Tools > Notices and slips > ACCOUNT_CREDIT and copy the content of the letter into all the languages

8. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is still in English (not ok)

9. Edit the patron's account and change the preferred language to the other language

10. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement) (OK)

11. Apply the patch

12. Reset config
    12.1. Edit the patron's account and change back the preferred language to 'default'
    12.2. In Administration > Global system preferences, disable TranslateNotices

13. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

14. Switch interface to the english language

15. Redo step 3
   --> On the printed slip, the word 'Payment' is in English

16. In Administration > Global system preferences, enable TranslateNotices

17. Edit the patron's account and change the preferred language to the other language

18. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Nick Clemens (kidclamp) 2024-03-26 17:55:19 UTC
Created attachment 163953 [details] [review]
Bug 33237: (follow-up) Tidy

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 11 Nick Clemens (kidclamp) 2024-03-26 17:56:08 UTC
(In reply to Martin Renvoize from comment #8)
> Sorry, can we get some unit tests here.

Signed off as test plan works, but Martin is correct, unit tests would be useful
Comment 12 Hammat wele 2024-04-08 16:44:14 UTC
Created attachment 164521 [details] [review]
Bug 33237: (follow-up) Unit tests
Comment 13 Martin Renvoize (ashimema) 2024-04-16 06:59:20 UTC
Thanks for adding the unit test Hammut... but I'm afraid I can't seem to get it to pass on ktd.. I'll investigate a little but I have a feeling it's got something to do with installed languages in that environment.. we don't install any by default but this would require we do.. or at least we install the translated notice for those particular test cases.
Comment 14 Jonathan Druart 2024-04-16 07:07:31 UTC
Yes, I would move this logic in a dedicated subroutine. It will isolate it and make it easier to test ("sub effective_language_for_notices"?)
Comment 15 Jonathan Druart 2024-04-16 07:08:42 UTC
my $lang       = 'en'; 

This is also not needed and confusing as you are actually removing the fallback to "en".

I would re-add it, after the if/else block, add `$lang //= 'en';`
Comment 16 Martin Renvoize (ashimema) 2024-04-23 11:33:50 UTC
OK, now that I've dug through the test I'm a lot less sure this bug makes sense.

You are setting the language to low down in my opinion.. we should be setting it from GetPreparedLetter.. otherwise you're going to end up with mixed language notices aren't you?

Surely it's about picking the right notice template in the first place rather than just the processing step... in the current iteration you could end up with an English notice with includes that come out in french.. that feels strange to me.
Comment 17 Martin Renvoize (ashimema) 2024-04-23 11:41:25 UTC
Right... I see.. it's about what 'default' means.. right?

Either way, we need a clear and correct test and that's not the case here as it stands.
Comment 18 Martin Renvoize (ashimema) 2024-04-23 12:45:33 UTC
Created attachment 165382 [details] [review]
Bug 33237: TMP Fix for Budget test failing in main
Comment 19 Martin Renvoize (ashimema) 2024-04-23 12:45:36 UTC
Created attachment 165383 [details] [review]
Bug 33237: (follow-up) Restore final fallback

This restores the final fallback to 'en' as mentioned by Jonathan
Comment 20 Martin Renvoize (ashimema) 2024-04-23 12:45:39 UTC
Created attachment 165384 [details] [review]
Bug 33237: (QA follow-up) Clarify tests

This patch tries to clarify the tests a little and expand their
coverage.

I've added notes where I think we still need a little work, especially
in regards to having them pass in the jenkins runs as we don't have
translations installed there and thus at the moment the tests will fail
without manual intervention to install the translated includes.
Comment 21 Martin Renvoize (ashimema) 2024-04-23 13:02:12 UTC
My conclusion here is that we shouldn't be using interface language at all.. we can't reliably tell that 'interface' and 'default' are written in matching languages.

I think we have to assume that 'default' matches 'first in list of translated languages'.

I think we should be doing the language code manipulation inside GetPreparredLetter and passing that along to the tt processor for includes.
Comment 22 Martin Renvoize (ashimema) 2024-04-23 15:16:20 UTC
Created attachment 165404 [details] [review]
Bug 33237: TMP Fix for Budget test failing in main
Comment 23 Martin Renvoize (ashimema) 2024-04-23 15:16:23 UTC
Created attachment 165405 [details] [review]
Bug 33237: (follow-up) Restore final fallback

This restores the final fallback to 'en' as mentioned by Jonathan
Comment 24 Martin Renvoize (ashimema) 2024-04-23 15:16:27 UTC
Created attachment 165406 [details] [review]
Bug 33237: (QA follow-up) Clarify tests and Mock

This patch tries to clarify the tests a little and expand their
coverage whilst also adding some defualt translated includes to the test
area and mocking the config to allow the tests to run without installing
translations.
Comment 25 Martin Renvoize (ashimema) 2024-04-23 15:25:02 UTC
Right.. we can drop the TMP fix patch once those have been corrected upstream in main.


I also think the Restore final fallback isn't really required but I did it whilst I was in here as Jonathan mentioned it.

The final patch is the important one as it brings us a step closer to the end goal by getting the tests working without having to manually install a translation.

However, I'm now strongly of the opinion we should not be doing the interface level check and instead use the highest priority language in the system preferences as the 'default'.


My understanding of how 'default' is used is that the 'default' notice is generally written in the primary language of the system and so it would match the top pick for interface language selection and possible not match the selected interface language of the moment.

Use cases:
1) US English only.  Default == English + Includes should be English
2) Single translation only (French Canadian). Default == French Canadian + Includes should also be French Canadian.
3) Multiple languages. Default template written in French Canadian, the Include should also use French Canadian (even if the staff user clicking to print has switched to Italian) otherwise we have the main notice in French Candian with the Include parts in Itelian.

Right now. case 3 fails.

I also think we could re-arrange the tests a bit to clean up.. I think we could/should be testing Template selection _+ include selection in the same places.. i.e each time we check the 'title' we would also check the 'content' to ensure they match consistently.. rather than the current check of template selection followed by a section for include selection checking.
Comment 26 Martin Renvoize (ashimema) 2024-04-23 15:26:41 UTC
Can I get some real-life users to comment on my thoughts regarding point three in the above comment
Comment 27 Caroline Cyr La Rose 2024-04-23 15:34:36 UTC
I CC'd a couple of people who I know use/support Koha in other languages. I will also send an email to the French mailing list to get their opinions.
Comment 28 Martin Renvoize (ashimema) 2024-04-23 16:19:43 UTC
For bonus points I'm tempted to display a 'Expected language' field for the default notices in the editor to show the output of the highest priority language when more than one is installed.  This clarifying to staff what language we're expecting
Comment 29 Philip Orr 2024-04-24 07:50:59 UTC
From my experience with German public libraries, the user would assume the 'Default' contents of a notice will be written in German.
TBH our libraries generally haven't been using TranslateNotices, maybe my feedback is not so important. :)
But if they were to activate the syspref, I would expect the 'default' template (for instance for overdues) to be in German and the includes to be in German as well. Martin, for your case 3 I agree with you. The used language for includes and for the 'default' notice content should match. But a display of 'effective language' would really be the best thing for the user as you said.
Or: add a checkbox to syspref "Languages" for "Default language for notices". :)
Comment 30 Martin Renvoize (ashimema) 2024-04-24 13:46:55 UTC
Created attachment 165455 [details] [review]
Bug 33237: If TranslateNotices is off, use the interface language includes in slips

This patch set the language used in slips folloinw this logic:
   --> uses patron's preferred language
   --> if patron's preferred language is 'default', use the interface language
   --> if there is no interface (for overdue_notices for example), use the first language in 'language' system preference

To Test:
1. Install the other language (i used fr-CA here)
     1.1.

     gulp po:update fr-CA

     ./misc/translator/translate install fr-CA

     1.2. In Administration > Global system preferences, search for language and check the added language

2. Create a manual invoice in a patron's account and pay it

3. From the Transactions tab, click 'Print' next to the payment line
   --> On the printed slip, there's the word 'Payment' in English (OK)

4. Switch interface to other language

5. Redo step 3
   --> On the printed slip, the word 'Payment' is still in English (not ok)

6. In Administration > Global system preferences, enable TranslateNotices

7. Go to Tools > Notices and slips > ACCOUNT_CREDIT and copy the content of the letter into all the languages

8. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is still in English (not ok)

9. Edit the patron's account and change the preferred language to the other language

10. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement) (OK)

11. Apply the patch

12. Reset config
    12.1. Edit the patron's account and change back the preferred language to 'default'
    12.2. In Administration > Global system preferences, disable TranslateNotices

13. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

14. Switch interface to the english language

15. Redo step 3
   --> On the printed slip, the word 'Payment' is in English

16. In Administration > Global system preferences, enable TranslateNotices

17. Edit the patron's account and change the preferred language to the other language

18. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 31 Martin Renvoize (ashimema) 2024-04-24 13:46:58 UTC
Created attachment 165456 [details] [review]
Bug 33237: (follow-up) Tidy

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 32 Martin Renvoize (ashimema) 2024-04-24 13:47:01 UTC
Created attachment 165457 [details] [review]
Bug 33237: (follow-up) Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 33 Martin Renvoize (ashimema) 2024-04-24 13:47:05 UTC
Created attachment 165458 [details] [review]
Bug 33237: (follow-up) Restore final fallback

This restores the final fallback to 'en' as mentioned by Jonathan
Comment 34 Martin Renvoize (ashimema) 2024-04-24 13:47:08 UTC
Created attachment 165459 [details] [review]
Bug 33237: (QA follow-up) Clarify tests and Mock

This patch tries to clarify the tests a little and expand their
coverage whilst also adding some defualt translated includes to the test
area and mocking the config to allow the tests to run without installing
translations.
Comment 35 Martin Renvoize (ashimema) 2024-04-24 13:47:11 UTC
Created attachment 165460 [details] [review]
Bug 33237: Add display of which language default language is expected

This patch adds the display of 'Default language' to the 'Default'
language in the notices editor tool.

This is so that librarians know which language they are expected to be
writing the notice in so we can remain consistent in both template and
include language used.
Comment 36 Martin Renvoize (ashimema) 2024-04-24 13:50:29 UTC
I've added the display of which language the system is expecting the default to be written in to allow consistency between template and include language.

I still think point three is valid and would like to tidy up the tests and remove the interface clause.

However, Magnus raised that perhaps these 'Default' templates may actually be deliberately bilingual.. in which case these patches will cause even more confusion and harm when using INCLUDES.
Comment 37 Martin Renvoize (ashimema) 2024-04-24 15:45:12 UTC
Created attachment 165473 [details] [review]
Bug 33237: If TranslateNotices is off, use the interface language includes in slips

This patch set the language used in slips folloinw this logic:
   --> uses patron's preferred language
   --> if patron's preferred language is 'default', use the interface language
   --> if there is no interface (for overdue_notices for example), use the first language in 'language' system preference

To Test:
1. Install the other language (i used fr-CA here)
     1.1.

     gulp po:update fr-CA

     ./misc/translator/translate install fr-CA

     1.2. In Administration > Global system preferences, search for language and check the added language

2. Create a manual invoice in a patron's account and pay it

3. From the Transactions tab, click 'Print' next to the payment line
   --> On the printed slip, there's the word 'Payment' in English (OK)

4. Switch interface to other language

5. Redo step 3
   --> On the printed slip, the word 'Payment' is still in English (not ok)

6. In Administration > Global system preferences, enable TranslateNotices

7. Go to Tools > Notices and slips > ACCOUNT_CREDIT and copy the content of the letter into all the languages

8. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is still in English (not ok)

9. Edit the patron's account and change the preferred language to the other language

10. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement) (OK)

11. Apply the patch

12. Reset config
    12.1. Edit the patron's account and change back the preferred language to 'default'
    12.2. In Administration > Global system preferences, disable TranslateNotices

13. Redo step 3 (you should still be in the other language interface)
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

14. Switch interface to the english language

15. Redo step 3
   --> On the printed slip, the word 'Payment' is in English

16. In Administration > Global system preferences, enable TranslateNotices

17. Edit the patron's account and change the preferred language to the other language

18. Redo step 3
   --> On the printed slip, the word 'Payment' is in the other language (Paiement)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 38 Martin Renvoize (ashimema) 2024-04-24 15:45:15 UTC
Created attachment 165474 [details] [review]
Bug 33237: (follow-up) Tidy

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 39 Martin Renvoize (ashimema) 2024-04-24 15:45:18 UTC
Created attachment 165475 [details] [review]
Bug 33237: (follow-up) Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 40 Martin Renvoize (ashimema) 2024-04-24 15:45:21 UTC
Created attachment 165476 [details] [review]
Bug 33237: (follow-up) Restore final fallback

This restores the final fallback to 'en' as mentioned by Jonathan

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 41 Martin Renvoize (ashimema) 2024-04-24 15:45:26 UTC
Created attachment 165477 [details] [review]
Bug 33237: (QA follow-up) Clarify tests and Mock

This patch tries to clarify the tests a little and expand their
coverage whilst also adding some defualt translated includes to the test
area and mocking the config to allow the tests to run without installing
translations.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 42 Martin Renvoize (ashimema) 2024-04-24 15:45:30 UTC
Created attachment 165478 [details] [review]
Bug 33237: Add display of which language default language is expected

This patch adds the display of 'Default language' to the 'Default'
language in the notices editor tool.

This is so that librarians know which language they are expected to be
writing the notice in so we can remain consistent in both template and
include language used.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 43 Martin Renvoize (ashimema) 2024-04-24 15:45:34 UTC
Created attachment 165479 [details] [review]
Bug 33237: Rearrange unit tests and ensure consistency

This patch re-arranges the unit tests and sets them to ensure we
consistently return the notice and notice includes in the same language.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 44 Martin Renvoize (ashimema) 2024-04-24 15:45:38 UTC
Created attachment 165480 [details] [review]
Bug 33237: Move and simplify langauge selection logic

This patch moves the language selection into GetPreparedLetter, drops
the interface check step and ensures the default template always uses
the default include language as per the OPACLanguages settings.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 45 Martin Renvoize (ashimema) 2024-04-24 15:49:41 UTC
I'm comfortable with this all now.. we have:

* Strong test coverage and don't require installation of translations
* Consistent behaviour across use cases
  - 'Default' = 'Top priority OPACLanguage' regardless of the interface used to trigger the notice or whether it's a fallback to the default notice because a localised version doesn't exist or TranslateNotices is disabled.
* Display of which language the default notice is expected to be written in.

Unit tests pass, QA scripts are happy and discussions have all reached conclusion on Mattermost and here.

Passing QA
Comment 46 Katrin Fischer 2024-04-26 18:25:04 UTC
I just wanted to ponder the change a bit since we had also had some trouble here. I will be back for this soon!
Comment 47 Katrin Fischer 2024-04-30 12:27:02 UTC
This patch made quite a u-turn from "use the interface language" in the second patch to dropping it totally out of the equation.
As we don't have an adjusted test plan - could you please explain/summarize the behavior in the release notes?

Some thoughts on this for (much?) later:

* We now rely on the language sequence being changed. This sequence defined, if I am not mistaken, which is the fallback language for missing templates, the display order, ... and? It might be worth adding a note/documentation about this to the system preference description at least. We never changed these settings, we will have to start doing so now.

* With the move from "hardcoded" notice templates to the nice configurable notices we had a slight regression for some libraries: Until then it was possible to print the slip in any installed language by switching the staff interface language. Now this no longer works. We rely on the settings in the patron record or the default sequence. It makes sense, but it's a change and there is no way to "simulate" the old behavior. Maybe it would be nice to have another way of selecting the language for printing something in from the GUI.
Comment 48 Katrin Fischer 2024-04-30 12:33:11 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 49 Martin Renvoize (ashimema) 2024-04-30 12:40:08 UTC
Follow-up bugs reported and linked to this one.
Comment 50 Katrin Fischer 2024-04-30 12:40:38 UTC
(In reply to Martin Renvoize from comment #49)
> Follow-up bugs reported and linked to this one.

Thank you!
Comment 51 Marcel de Rooy 2024-05-17 06:24:51 UTC
+    t::lib::Mocks::mock_config( 'intrahtdocs', '/kohadevbox/koha/t/mock_templates/intranet-tmpl' );

This should not have passed QA.
Hardcoded kohadevbox paths.
Will submit follow-up.
Comment 52 Marcel de Rooy 2024-05-17 06:34:51 UTC
Created attachment 166860 [details] [review]
Bug 33237: (QA follow-up) Remove hardcoded kohadevbox path

Test plan:
Run Letters.t (outside kohadevbox :)

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 53 Katrin Fischer 2024-05-17 07:23:37 UTC
Picked QA follow-up for main.
Comment 54 Katrin Fischer 2024-05-17 08:37:12 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 55 Fridolin Somers 2024-05-24 12:26:33 UTC
Not backported to 23.11.x
Comment 56 Katrin Fischer 2024-06-25 08:35:48 UTC
Can we have a backport for this please? 
I know that 22.11 is affected.
Comment 57 Fridolin Somers 2024-06-25 19:01:28 UTC
OK I have a look
Comment 58 Fridolin Somers 2024-06-27 08:02:50 UTC
Pushed to 23.11.x for 23.11.07
Comment 59 Wainui Witika-Park 2024-07-19 01:28:36 UTC
not backporting to 23.05.x unless requested