[PATCH,RFC] Fetch c-s translations from xkeyboard-config.
Hello,
Here is a patch that makes the c-s build fetch translations from
xkeyboard-config and put them into config. One issue is that it makes
it quite big (900KB), but that's probably not avoidable; it gets
compressed easily anyway.
To fetch the messages, I tried to use the msg* tools, but it was hairy
and probably slow (needs a msgunfmt then msgconv, then msggrep, then
what?). It seemed much simpler to just build-depend on locales-all and
use the thus-available en_US.UTF-8 locale to get gettext do everything
for us.
Samuel
Index: debian/control
===================================================================
--- debian/control (révision 58021)
+++ debian/control (copie de travail)
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Uploaders: Anton Zinoviev <zinoviev@debian.org>, Christian Perrier <bubulle@debian.org>
-Build-Depends-Indep: perl, libxml-parser-perl, xkb-data (>= 0.9)
+Build-Depends-Indep: perl, libxml-parser-perl, xkb-data (>= 0.9), locales-all
Build-Depends: debhelper (>= 5), po-debconf
Standards-Version: 3.7.3
Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/console-setup
Index: debian/rules
===================================================================
--- debian/rules (révision 58021)
+++ debian/rules (copie de travail)
@@ -29,9 +29,7 @@
next; \
} \
/## *KBDNAMES *##/ { \
- printf "kbdnames='\''"; \
system("cd Keyboard && ./kbdnames-maker MyKeyboardNames.pl"); \
- printf "'\''"; \
next; \
} \
{ \
Index: debian/config.proto
===================================================================
--- debian/config.proto (révision 58021)
+++ debian/config.proto (copie de travail)
@@ -321,6 +321,19 @@
locale=C
fi
+locale_lang=${locale/%_*}
+locale_notlang=${locale/#*_}
+locale_country=${locale_notlang/%.*}
+locale_modif=
+[ -z "${locale/*@*}" ] && locale_modif=${locale/#*@}
+
+eval kbdnames=\"\${kbdnames_${locale_lang}_${locale_country}__${locale_modif}}\"
+[ -z "$kbdnames" ] && eval kbdnames=\"\${kbdnames_${locale_lang}_${locale_country}}\"
+[ -z "$kbdnames" ] && eval kbdnames=\"\${kbdnames_${locale_lang}__${locale_modif}}\"
+[ -z "$kbdnames" ] && eval kbdnames=\"\${kbdnames_${locale_lang}}\"
+[ -z "$kbdnames" ] && kbdnames="$kbdnames_C"
+kbdnames="$(echo "$kbdnames" | iconv -f UTF-8)"
+
case "$locale" in
*KOI8*|*koi8*)
default_codeset=CyrKoi
Index: Keyboard/kbdnames-maker
===================================================================
--- Keyboard/kbdnames-maker (révision 58021)
+++ Keyboard/kbdnames-maker (copie de travail)
@@ -2,6 +2,8 @@
use warnings 'all';
use strict;
+use Locale::gettext;
+use POSIX;
BEGIN {
my $file;
@@ -13,6 +15,8 @@
do "$file";
}
+print "kbdnames_C='\n";
+
for my $model (keys %KeyboardNames::models) {
my $name = $KeyboardNames::models{$model};
print "model*$name*$model\n"
@@ -26,3 +30,46 @@
print "variant*$name*$variantname*$layout - $variant\n";
}
}
+
+print "'\n";
+
+# Make sure we output UTF-8
+$ENV{'LC_ALL'} = "en_US.UTF-8";
+binmode STDOUT, ":utf8";
+
+sub fixquotes {
+ my $s = shift;
+ $s =~ s/'/'"'"'/g;
+ return $s;
+}
+
+for my $mo (</usr/share/locale/*/LC_MESSAGES/xkeyboard-config.mo>) {
+ my $lang = $mo;
+ $lang =~ s:/usr/share/locale/(.*)/LC_MESSAGES/xkeyboard-config.mo:$1:;
+ print "# Generated for $lang from $mo\n";
+ $ENV{'LANGUAGE'} = $lang;
+ setlocale(LC_ALL,"");
+
+ $lang =~ s:\@:__:;
+ $lang =~ s:__Latn:__latin:; # special fixup for sr
+
+ print "kbdnames_$lang='\n";
+
+ my $d = Locale::gettext->domain("xkeyboard-config");
+
+ for my $model (keys %KeyboardNames::models) {
+ my $name = $KeyboardNames::models{$model};
+ print "model*$name*".fixquotes($d->get($model))."\n"
+ }
+ for my $layout (keys %KeyboardNames::layouts) {
+ my $name = $KeyboardNames::layouts{$layout};
+ my $local_layout = fixquotes($d->get($layout));
+ print "layout*$name*$local_layout\n";
+ print "variant*$name**$local_layout\n";
+ for my $variant (keys %{$KeyboardNames::variants{$name}}) {
+ my $variantname = $KeyboardNames::variants{$name}{$variant};
+ print "variant*$name*$variantname*$local_layout - ".fixquotes($d->get($variant))."\n";
+ }
+ }
+ print "'\n";
+}
Reply to: