From 1c6b339bbc2f9ee0624f7777e5950417a66a3286 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sat, 31 Jul 2010 15:46:43 +0000 Subject: i18n: use user friendly language names in GUI The GUI now uses the content of the Language field from the po file header if it is present and not empty for the language selection PopupWidget. If not present it uses the file name as before (e.g. ru_RU). Also update all the translation template and all the translation files. svn-id: r51542 --- tools/po2c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/po2c b/tools/po2c index 9dbc5e0fb7..10e15338c7 100755 --- a/tools/po2c +++ b/tools/po2c @@ -161,19 +161,29 @@ foreach my $l (keys(%msgs)) print "struct PoLangEntry {\n"; print "\tconst char *lang;\n"; print "\tconst char *charset;\n"; +print "\tconst char *langname;\n"; print "\tconst PoMessageEntry *msgs;\n"; print "};\n\n"; print "const PoLangEntry _translations[] = {\n"; foreach my $l (keys(%msgs)) { + # charset $header = $msgs{$l}->{""}; $header =~ /charset=([^\\]+)/; $charset = $1; - print "\t{ \"" . $l . "\", \"" . $charset . "\", _translation_${l} },\n"; + # user readable language name + $lang = "NULL"; + $header = $msgs{$l}->{""}; + $header =~ /Language:[\s]*([^\\]*)/; + unless ($1 eq "") + { + $lang = "\"" . $1 . "\""; + } + print "\t{ \"" . $l . "\", \"" . $charset . "\", " . $lang . ", _translation_${l} },\n"; } -print "\t{ NULL, NULL, NULL }\n};\n\n"; +print "\t{ NULL, NULL, NULL, NULL }\n};\n\n"; print "// code\n"; print << 'EOF'; @@ -255,6 +265,13 @@ const char *po2c_getlang(const int num) { assert(num < ARRAYSIZE(_translations)); return _translations[num].lang; } + +const char *po2c_getlangname(const int num) { + assert(num < ARRAYSIZE(_translations)); + if (_translations[num].langname != NULL) + return _translations[num].langname; + return _translations[num].lang; +} EOF exit 0; -- cgit v1.2.3