From 8760514ab2ffe2eb49ee2993eaa0933cfe2acca7 Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Mon, 27 Mar 2023 21:05:29 +0000 Subject: [PATCH] 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 --- C4/Letters.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index a0404ac7075..ae93126f7bb 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1669,7 +1669,18 @@ sub _process_tt { my $loops = $params->{loops}; my $objects = $params->{objects} || {}; my $substitute = $params->{substitute} || {}; - my $lang = defined($params->{lang}) && $params->{lang} ne 'default' ? $params->{lang} : 'en'; + my $lang = 'en'; + my $interface = C4::Context->interface; + if(defined($params->{lang}) && $params->{lang} ne 'default'){ + $lang = $params->{lang}; + } elsif($interface eq 'intranet' || $interface eq 'opac') { + #use interface language + $lang = C4::Languages::getlanguage(); + } else { + # Pick the first selected syspref language + my @languages = split /,/, C4::Context->preference('language'); + $lang = shift @languages; + } my ($theme, $availablethemes); my $htdocs = C4::Context->config('intrahtdocs'); -- 2.30.2