Re: debconf w/ charset encoding support
On Tue, 17 Sep 2002 14:30:14 -0400
Joey Hess <joeyh@debian.org> wrote:
> Of course there is no change in behavior for the old Description-de type
> fields that lack any encoding information. This is exactly as broken as
> it has always been. :-)
There is a list posted in the bug entry, to assume the original unspecified
encoding, by Tomohiro Kubota.
Please use it.
----------------------------------from here
#!/usr/bin/perl
use Text::Iconv;
# Convert encoding of translated Debconf message (Description-* and so on)
# from commonly-used encoding for each language (for example, EUC-JP for
# Japanese) to the encoding specified by the current LC_CTYPE locale.
#
# $newtext = ToLocaleEncoding($text, $lang);
#
# $text translated Debconf message
# $lang language name in xx_YY or xx format
# $newtext converted Debconf message which can directly be output
# to the stream
#
# Note:
# 1. This function depends libtext-iconv-perl package.
# 2. The list of commonly-used encodings for Debconf templates
# is tentative.
# 3. Encodings for Debconf templates may be changed (to, for
# example, UTF-8) in future. Even in such a case, this function
# will be useful when using debconf in non-UTF-8 locales.
sub ToLocaleEncoding ($$) {
my ($localeencoding, $text, $lang, $conv, $result, $from, %template);
%template = (
# language name => encoding used for debconf template
"cs" => "ISO-8859-2",
"da" => "ISO-8859-1",
"de" => "ISO-8859-1",
"de_DE" => "ISO-8859-15",
"el" => "ISO-8859-7",
"en" => "ISO-8859-1",
"fi" => "ISO-8859-15",
"fr" => "ISO-8859-1",
"fr_FR" => "ISO-8859-15",
"fr_BE" => "ISO-8859-15",
"fr_LU" => "ISO-8859-15",
"hr" => "ISO-8859-2",
"hu" => "ISO-8859-2",
"id" => "ISO-8859-1",
"it" => "ISO-8859-1",
"it_IT" => "ISO-8859-15",
"ja" => "EUC-JP",
"ko" => "EUC-KR",
"nl" => "ISO-8859-15",
"no" => "ISO-8859-1",
"pl" => "ISO-8859-2",
"pt" => "ISO-8859-1",
"pt_PT" => "ISO-8859-15",
"ro" => "ISO-8859-2",
"ru" => "KOI8-R",
"sk" => "ISO-8859-2",
"sl" => "ISO-8859-2",
"th" => "TIS-620",
"zh_CN" => "GB2312",
"zh_HK" => "Big5HKSCS",
"zh_TW" => "Big5"
);
$text = $_[0];
$lang = $_[1];
open(HANDLE, "/usr/bin/locale charmap|");
$localeencoding = <HANDLE>;
close(HANDLE);
$from = $template{$lang};
if ($from eq "") {
$lang =~ s/\..*//;
$from = $template{$lang};
}
if ($from eq "") {
$lang =~ s/_.*//;
$from = $template{$lang};
}
if ($from eq "") {
$from = "ISO-8859-1";
}
if ($from eq $localeencoding) {return $text;}
$conv = Text::Iconv->new($from, $localeencoding);
$result = $conv->convert($text);
return $result;
}
print ToLocaleEncoding("translated-template-from-debconf","ja");
----------------------------------till here
--
dancer@debian.org http://www.netfort.gr.jp/~dancer
Reply to: