[Bug 42370] New: locale=C breaks on the fly translations
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42370 Bug ID: 42370 Summary: locale=C breaks on the fly translations Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: magnus@libriotech.no QA Contact: testopia@bugs.koha-community.org Preparations for testing in KTD: - Install a translation, for example swedish: $ sudo koha-translate -d kohadev -i sv-SE - Enable sv-SE for OPACLanguages. - Set opaclanguagesdisplay = Allow. - Go to the OPAC. - Choose Swedish as your language. - Make sure you are not logged in. - Verify that the word for "Card number" in the login form *is* translated. To reproduce the problem set your locale to C: - $ sudo dpkg-reconfigure locales Choose to generate sv_SE.UTF-8 (for me it was option 271) When asked "Default locale for the system environment" choose the C option, for me it was 2. - $ restart_all - Go to the OPAC and refresh the front page. - Make sure you are not logged in. - Make sure your installed translation is the active language. - Verify that "Card number" in the login form is *not* translated, but the rest of the page is. This problem affects all template strings that are translated on the fly, which means they are enclosed in t(), tx(), tn() etc in the templates. For us, the solution was to change the locale on the server, so this bug report might be a "won't fix", but maybe it will be a help to future searchers. It has been suggested that it would be a good idea to change this in Koha::I18N: # LANG needs to be set to a valid locale, # otherwise LANGUAGE is ignored $ENV{LANG} = $system_locales[0]; POSIX::setlocale( LC_MESSAGES, '' ); To this: # LANG needs to be set to a valid locale, # otherwise LANGUAGE is ignored $ENV{LANG} = $system_locales[0]; setlocale(LC_MESSAGES, $locale . '.utf8'); But I have not tested that properly. Another suggestion might be to have a warning on the "About Koha" page if the locale on the server is set to C. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42370 paxed <pasi.kallinen@koha-suomi.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pasi.kallinen@koha-suomi.fi --- Comment #1 from paxed <pasi.kallinen@koha-suomi.fi> --- Interestingly enough, this happens on our production system, but not on our testing environment. Both have the same locales. Perhaps it has something to do how often plack needs to reuse processes or something. I looked into this when we first encountered it a year or so ago, but never found out the reason why it was happening. I also hacked a patch that might help, but we haven't tested it - because it needs to go in production. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42370 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au --- Comment #2 from David Cook <dcook@prosentient.com.au> --- I am kind of curious. I spent a lot of time with locales with bug 36947. Note the following line in Koha/I18N.pm: my @system_locales = grep { chomp; not( /^C/ || $_ eq 'POSIX' ) } qx/locale -a/; So it looks like it's stuffing whatever locale it can find into $ENV{LANG}. According to https://perldoc.perl.org/POSIX, $loc = setlocale( LC_CTYPE, "" ); it seems like it's not being cleared but rather it's using whatever the environmental variable is set to? https://man7.org/linux/man-pages/man3/setlocale.3.html If locale is an empty string, "", each part of the locale that should be modified is set according to the environment variables. Anyway it's Friday and after 5 so I'm not going to be led down a rabbithole... hehe. Good luck! -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42370 --- Comment #3 from David Cook <dcook@prosentient.com.au> --- Also take a look at https://perldoc.perl.org/perllocale#ENVIRONMENT I think it will be helpful for you -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org