Re: Bug#160284: ITP: po-debconf -- Manage translated Debconf templates files with gettext
Hi,
At Fri, 13 Sep 2002 00:50:36 +0200,
Marcin Owsiany wrote:
> $ du -sh /usr/lib/gconv
> 4.4M /usr/lib/gconv
> $ dpkg -S /usr/lib/gconv
> libc6: /usr/lib/gconv
>
> Aah! I always thought this was in locales package.
A good news! Recently I tested using iconv(1) with renaming
/usr/share/i18n/charmaps (in "locales" package) to something
else and I found iconv(1) works well.
> : @specials = qw(C en_US); # anything else?
> : $locale = $ENV{'LC_CTYPE'} || $ENV{'LANG'};
Exactly speaking, what we need to know is not locale name but
encoding name. For example, if we assume that debconf templates
will be stored in UTF-8, encoding conversion will be needed for
all non-UTF-8 locales. Current version of debconf stores templates
in popular encoding for each language (EUC-JP for Japanese, KOI8-R
for Russian,...) and encoding conversion will be needed when
the language is used with different encodings (UTF-8 for Japanese,
ISO-8859-5 for Russian,...).
In short, we need encoding information (ISO-8859-1, EUC-JP, KOI8-R,
UTF-8,...) in the locale, not language (en, ja, fr, ru,...) nor
locale (en_US, ja_JP.eucJP, fr_FR@euro,...).
This is achieved by nl_langinfo(CODESET) in C language or
"/usr/bin/locale charmap" in shell script. Now, since debconf
is written in Perl, the following code will work well.
open(HANDLE, "/usr/bin/locale charmap|");
$localeencoding = <HANDLE>;
close(HANDLE);
Next problem is to determine whether we need encoding conversion
or not.
> : if (grep $locale =~ /^$_/ @specials) {
If we will use UTF-8 for storing all debconf templates, then
the test will "$localeencoding eq 'UTF-8'". However, if in the
current situation, we will need a table of encodings for languages.
%table = {
"ja" => "EUC-JP",
"ru" => "KOI8-R",
....
};
$language = $ENV{'LC_ALL'} || $ENV{'LC_MESSAGES'} || $ENV{'LANG'};
$language =~ s/_.*//;
$templateencoding = $table{$language};
if ($localeencoding ne $templateencoding) {
NEED_CONVERSION;
}
However, if we migrate to gettext, then we don't need all of such
codes because gettext does this automatically. Is it possible?
---
Tomohiro KUBOTA <kubota@debian.org>
http://www.debian.or.jp/~kubota/
"Introduction to I18N" http://www.debian.org/doc/manuals/intro-i18n/
Reply to: