#! /usr/local/bin/perl -w
BEGIN {
my
$package
;
if
($0 =~ /_pp\.t$/) {
$package
=
'gettext_pp'
;
}
else
{
$package
=
'gettext_xs'
;
}
my
$selected
= Locale::Messages->select_package (
$package
);
if
(
$selected
ne
$package
&&
'gettext_xs'
eq
$package
) {
print
"1..0 # Skip: Locale::$package not available here.\n"
;
exit
0;
}
plan
tests
=> NUM_TESTS;
}
foreach
my
$var
(
keys
%ENV
) {
if
(
'LC_'
eq
substr
$var
, 0, 3) {
Locale::Messages::nl_putenv (
"$var"
);
}
}
Locale::Messages::nl_putenv (
"LANGUAGE=de_AT"
);
Locale::Messages::nl_putenv (
"LC_ALL=de_AT"
);
Locale::Messages::nl_putenv (
"LANG=de_AT"
);
Locale::Messages::nl_putenv (
"LC_MESSAGES=de_AT"
);
my
$missing_locale
= Locale::Messages::setlocale (POSIX::LC_ALL() =>
''
) ?
''
:
'locale de_AT missing'
;
Locale::Messages::setlocale (POSIX::LC_ALL() =>
'C'
);
my
$locale_dir
= $0;
$locale_dir
=~ s,[^\\/]+$,, or
$locale_dir
=
'.'
;
$locale_dir
.=
'/LocaleData'
;
my
$textdomain
=
'existing'
;
Locale::Messages::nl_putenv (
"LANG=whatever"
);
Locale::Messages::nl_putenv (
"LC_ALL=de_DE"
);
Locale::Messages::nl_putenv (
"LC_MESSAGES=whatever"
);
Locale::Messages::nl_putenv (
"LANGUAGE=ab_CD:ef_GH:de_AT:de"
);
Locale::Messages::nl_putenv (
"OUTPUT_CHARSET=iso-8859-1"
);
Locale::Messages::setlocale (POSIX::LC_ALL(),
''
);
my
$bound_dir
= bindtextdomain
$textdomain
=>
$locale_dir
;
ok
defined
$bound_dir
;
ok (File::Spec->catdir (
$bound_dir
), File::Spec->catdir (
$locale_dir
));
my
$bound_domain
= textdomain
$textdomain
;
ok
defined
$bound_domain
;
ok
$bound_domain
,
$textdomain
;
skip
$missing_locale
, gettext (
'January'
),
'Jänner'
;
my
$translation
= gettext (
'January'
);
Locale::Messages::nl_putenv (
"LANGUAGE=ab_CD:ef_GH:de:de_AT"
);
skip
$missing_locale
, gettext (
'February'
),
'Februar'
;
Locale::Messages::nl_putenv (
"LANGUAGE"
);
Locale::Messages::nl_putenv (
"LC_ALL=de_DE.utf-8"
);
Locale::Messages::setlocale (POSIX::LC_ALL(),
''
);
skip
$missing_locale
, gettext (
'February'
),
'Februar'
;
Locale::Messages::nl_putenv (
"LANGUAGE=de_AT.utf-8"
);
Locale::Messages::nl_putenv (
"LC_ALL=de_DE.utf-8"
);
Locale::Messages::setlocale (POSIX::LC_ALL(),
''
);
skip
$missing_locale
, gettext (
'February'
),
'Feber'
;