Bugzilla – Attachment 73913 Details for
Bug 15395
Internationalization: plural forms, context, and more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15395: Fix for libintl-perl >= 1.25
Bug-15395-Fix-for-libintl-perl--125.patch (text/plain), 2.92 KB, created by
Julian Maurice
on 2018-04-10 06:27:38 UTC
(
hide
)
Description:
Bug 15395: Fix for libintl-perl >= 1.25
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2018-04-10 06:27:38 UTC
Size:
2.92 KB
patch
obsolete
>From ca8a854cf95f24c37fc83740953cc6f47ea0a9a3 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Mon, 19 Feb 2018 13:35:14 +0100 >Subject: [PATCH] Bug 15395: Fix for libintl-perl >= 1.25 > >Since 1.25, LANGUAGE environment variable is ignored unless LANG is set >to a valid locale. >This patch sets LANG to a valid locale and calls setlocale. If no valid >locale can be found, a warning message is written in logs. > >See https://rt.cpan.org/Public/Bug/Display.html?id=81315 >and also https://github.com/gflohr/libintl-perl/commit/5910980b6e >--- > Koha/I18N.pm | 44 +++++++++++++++++++++++++++----------------- > 1 file changed, 27 insertions(+), 17 deletions(-) > >diff --git a/Koha/I18N.pm b/Koha/I18N.pm >index 95c82ff4f4..e2b88b7beb 100644 >--- a/Koha/I18N.pm >+++ b/Koha/I18N.pm >@@ -24,7 +24,7 @@ use C4::Languages; > use C4::Context; > > use Encode; >-use Locale::Messages qw(:locale_h nl_putenv); >+use Locale::Messages qw(:locale_h nl_putenv setlocale LC_MESSAGES); > use Koha::Cache::Memory::Lite; > > use parent 'Exporter'; >@@ -50,24 +50,34 @@ sub init { > my $cache = Koha::Cache::Memory::Lite->get_instance(); > my $cache_key = 'i18n:initialized'; > unless ($cache->get_from_cache($cache_key)) { >- my $langtag = C4::Languages::getlanguage; >- my @subtags = split /-/, $langtag; >- my ($language, $region) = @subtags; >- if ($region && length $region == 4) { >- $region = $subtags[2]; >- } > Locale::Messages->select_package('gettext_pp'); >- my $locale = $language; >- if ($region) { >- $locale .= '_' . $region; >+ my @system_locales = grep { chomp; not (/^C/ || $_ eq 'POSIX') } qx/locale -a/; >+ if (@system_locales) { >+ # LANG needs to be set to a valid locale, >+ # otherwise LANGUAGE is ignored >+ nl_putenv('LANG=' . $system_locales[0]); >+ setlocale(LC_MESSAGES, ''); >+ >+ my $langtag = C4::Languages::getlanguage; >+ my @subtags = split /-/, $langtag; >+ my ($language, $region) = @subtags; >+ if ($region && length $region == 4) { >+ $region = $subtags[2]; >+ } >+ my $locale = $language; >+ if ($region) { >+ $locale .= '_' . $region; >+ } >+ >+ nl_putenv("LANGUAGE=$locale"); >+ nl_putenv('OUTPUT_CHARSET=UTF-8'); >+ >+ my $directory = _base_directory(); >+ textdomain($textdomain); >+ bindtextdomain($textdomain, $directory); >+ } else { >+ warn "No locale installed. Localization cannot work and is therefore disabled"; > } >- nl_putenv("LANGUAGE=$locale"); >- nl_putenv("LANG=$locale"); >- nl_putenv('OUTPUT_CHARSET=utf-8'); >- >- my $directory = _base_directory(); >- textdomain($textdomain); >- bindtextdomain($textdomain, $directory); > > $cache->set_in_cache($cache_key, 1); > } >-- >2.14.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15395
:
45797
|
45798
|
45799
|
46337
|
50023
|
50024
|
50025
|
50026
|
61873
|
61874
|
61875
|
61876
|
61934
|
61935
|
61977
|
62008
|
62041
|
62326
|
62327
|
62328
|
62329
|
62330
|
62331
|
62332
|
62333
|
62335
|
62709
|
65894
|
70974
|
70975
|
70976
|
71940
|
71941
|
71942
|
71943
|
71944
|
71945
|
71946
|
71947
|
71948
|
71949
|
71950
|
71951
|
71952
|
73901
|
73902
|
73903
|
73904
|
73905
|
73906
|
73907
|
73908
|
73909
|
73910
|
73911
|
73912
|
73913
|
76328
|
76329
|
76330
|
77475
|
77476
|
81152
|
81153
|
81154
|
81155
|
81156
|
81157
|
81158
|
81159
|
81167
|
81734
|
81735
|
81736
|
81737
|
81738
|
81739
|
81741
|
81742
|
81743