[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Wishlist for woody+1



Hi,

At Sun, 2 Jun 2002 03:00:53 +0900,
Junichi Uekawa wrote:

> So, could you give a hand in #148490 ?
> I'm not that fluent in perl, and I don't really grok some pieces
> of debconf.

The following script might help you.
Please ask me if you have any questions on this script.

----------------------------------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


---
Tomohiro KUBOTA <kubota@debian.org>
http://www.debian.or.jp/~kubota/
"Introduction to I18N"  http://www.debian.org/doc/manuals/intro-i18n/


-- 
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: