summaryrefslogtreecommitdiff
path: root/Master/tlpkg
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2012-02-13 00:36:11 +0000
committerNorbert Preining <preining@logic.at>2012-02-13 00:36:11 +0000
commit95377e23ad7fdb22ab767a8800c59663b195eff0 (patch)
treeecd8adb65cfc5ab7b1f22a46f52d1c7844b569fe /Master/tlpkg
parent07e1924e1f6dce1a28ea1f53358946d87e9ba46b (diff)
allow area selection in translations
git-svn-id: svn://tug.org/texlive/trunk@25377 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r--Master/tlpkg/TeXLive/TLWinGoo.pm16
-rw-r--r--Master/tlpkg/TeXLive/trans.pl39
2 files changed, 38 insertions, 17 deletions
diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm
index b4300ce5180..f49f8df771c 100644
--- a/Master/tlpkg/TeXLive/TLWinGoo.pm
+++ b/Master/tlpkg/TeXLive/TLWinGoo.pm
@@ -253,26 +253,28 @@ Two-letter country code representing the locale of the current user
sub reg_country {
my $value = $Registry -> {"CUser/Control Panel/International//Locale"};
- return 0 unless $value;
+ return unless $value;
# there might be trailing nulls on Vista
$value =~ s/\x00*$//;
$value = substr $value, -4;
- return 0 unless $value;
+ return unless $value;
my $lmkey = $Registry -> Open("HKEY_CLASSES_ROOT/MIME/Database/Rfc1766/",
{Access => KEY_READ()});
- return 0 unless $lmkey;
+ return unless $lmkey;
$lm = $lmkey->{"/$value"};
- return 0 unless $lm;
+ return unless $lm;
debug("found lang codes value = $value, lm = $lm...\n");
if ($lm) {
if ($lm =~ m/^zh-(tw|hk)$/i) {
- return ("zh-tw");
+ return ("zh", "tw");
} elsif ($lm =~ m/^zh/) {
# for anything else starting with zh return, that is zh, zh-cn, zh-sg
# and maybe something else
- return ("zh-cn");
+ return ("zh", "cn");
} else {
- return(substr $lm, 0, 2);
+ my $lang = lc(substr $lm, 0, 2);
+ my $area = lc(substr $lm, 4);
+ return($lang, $area);
}
}
}
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;