From 95377e23ad7fdb22ab767a8800c59663b195eff0 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 13 Feb 2012 00:36:11 +0000 Subject: allow area selection in translations git-svn-id: svn://tug.org/texlive/trunk@25377 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/trans.pl | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'Master/tlpkg/TeXLive/trans.pl') diff --git a/Master/tlpkg/TeXLive/trans.pl b/Master/tlpkg/TeXLive/trans.pl index c110b72922b..2409b392e16 100644 --- a/Master/tlpkg/TeXLive/trans.pl +++ b/Master/tlpkg/TeXLive/trans.pl @@ -32,11 +32,12 @@ if (defined($::opt_lang)) { } else { if ($^O =~ /^MSWin(32|64)$/i) { # trying to deduce automatically the country code - my $foo = TeXLive::TLWinGoo::reg_country(); - if ($foo) { - $::lang = $foo; + my ($lang, $area) = TeXLive::TLWinGoo::reg_country(); + if ($lang) { + $::lang = $lang; + $::area = $area; } else { - debug("Didn't get any usuful code from reg_country: $foo...\n"); + debug("Didn't get any usuful code from reg_country.\n"); } } else { # we load POSIX and locale stuff @@ -47,18 +48,22 @@ if (defined($::opt_lang)) { my ($lang,$area,$codeset); if ($loc =~ m/^([^_.]*)(_([^.]*))?(\.([^@]*))?(@.*)?$/) { $lang = defined($1)?$1:""; - $area = defined($3)?$3:""; + # lower case the area code + $area = defined($3)?lc($3):""; if ($lang eq "zh") { if ($area =~ m/^(TW|HK)$/i) { - $lang = "zh-tw"; + $lang = "zh"; + $area = "tw"; } else { # fallback to zh-cn for anything else, that is # zh-cn, zh-sg, zh, and maybe something else - $lang = "zh-cn"; + $lang = "zh"; + $area = "cn"; } } } $::lang = $lang if ($lang); + $::area = $area if ($area); } } @@ -100,12 +105,26 @@ sub __ ($@) { } if (($::lang ne "en") && ($::lang ne "C")) { - if (! -r "$::installerdir/tlpkg/translations/$::lang.po") { - tlwarn ("\n Sorry, no translations available for $::lang; falling back to English. + my $code = $::lang; + $code .= "_$::area" if defined($::area); + my $found = 0; + if (-r "$::installerdir/tlpkg/translations/$code.po") { + $found = 1; + # set $::lang to the actually used one + $::lang = $code; + } else { + # retry without area code + if (! -r "$::installerdir/tlpkg/translations/$::lang.po") { + tlwarn ("\n Sorry, no translations available for $code (nor $::lang); falling back to English. Make sure that you have the package \"texlive-msg-translations\" installed. (If you'd like to help translate the installer's messages, please see http://tug.org/texlive/doc.html#install-tl-xlate for information.)\n\n"); - } else { + } else { + debug ("translation: falling back to $::lang, not available: $code\n"); + $found = 1; + } + } + if ($found) { # merge the translated strings into the text string open(LANG, "<$::installerdir/tlpkg/translations/$::lang.po"); my $msgid; -- cgit v1.2.3