pidgin: ac556715: More improvements to create_nsis_transla...

datallah at pidgin.im datallah at pidgin.im
Tue May 18 23:32:40 EDT 2010


-----------------------------------------------------------------
Revision: ac55671526c467bd565efcd2f668ae32e25ea7e7
Ancestor: 08766d9b997786acf12cc9335f8a119fe1004761
Author: datallah at pidgin.im
Date: 2010-05-19T02:50:02
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ac55671526c467bd565efcd2f668ae32e25ea7e7

Modified files:
        pidgin/win32/nsis/create_nsis_translations.pl

ChangeLog: 

More improvements to create_nsis_translations.pl - I have more to do, but I'm
afraid that these are going to be less likely to be applicable upstream.
 * Add all the current NSIS translations to the map
 * Add the LCID to the language map (not currently used)
 * Only include translations that are >= 50% translated

-------------- next part --------------
============================================================
--- pidgin/win32/nsis/create_nsis_translations.pl	19b565f60586a107353ecfee3bce5d093cf2c9fb
+++ pidgin/win32/nsis/create_nsis_translations.pl	dc753440f44bf0ba985918b8ad67c0ee12fabd13
@@ -86,70 +86,81 @@ print "                Working dir '$tmp
 print "                Working dir '$tmp_dir'\n";
 
 # Commented out locales that are not available in nsis
+# Map value is ["NSISFilename", "Encoding", "LCID"]
 my %localeNames = (
-  "af" =>	["Afrikaans", "WINDOWS-1252"],
+  "af" =>	["Afrikaans", "WINDOWS-1252", "1078"],
 #  "am" =>	["Amharic", "UTF-8"],
-  "ar" =>	["Arabic", "WINDOWS-1256"],
-  "bg" =>	["Bulgarian", "WINDOWS-1251"],
-  "br" =>	["Breton", "WINDOWS-1252"],
-  "ca" =>	["Catalan", "WINDOWS-1252"],
-  "cs" =>	["Czech", "WINDOWS-1250"],
-  "da" =>	["Danish", "WINDOWS-1252"],
-  "de" =>	["German", "WINDOWS-1252"],
+  "ar" =>	["Arabic", "WINDOWS-1256", "1025"],
+  "be" =>	["Belarusian", "WINDOWS-1251", "1059"],
+  "bg" =>	["Bulgarian", "WINDOWS-1251", "1026"],
+  "bs" =>	["Bosnian", "WINDOWS-1250", "5146"],
+  "br" =>	["Breton", "WINDOWS-1252", "1150"],
+  "ca" =>	["Catalan", "WINDOWS-1252", "1027"],
+  "cs" =>	["Czech", "WINDOWS-1250", "1029"],
+  "cy" =>	["Welsh", "WINDOWS-1252", "1160"],
+  "da" =>	["Danish", "WINDOWS-1252", "1030"],
+  "de" =>	["German", "WINDOWS-1252", "1031"],
 #  "dz" =>	["Dzongkha", "UTF-8"],
-  "el" =>	["Greek", "WINDOWS-1253"],
-  "en" =>	["English", "WINDOWS-1252"],
-  "es" =>	["Spanish", "WINDOWS-1252"],
-  "eu" =>	["Basque", "WINDOWS-1252"],
-  "fa" =>	["Farsi", "WINDOWS-1256"],
-  "fi" =>	["Finnish", "WINDOWS-1252"],
-  "fr" =>	["French", "WINDOWS-1252"],
-  "ga" =>	["Irish", "WINDOWS-1252"],
-  "gl" =>	["Galician", "WINDOWS-1252"],
+  "el" =>	["Greek", "WINDOWS-1253", "1032"],
+  "en" =>	["English", "WINDOWS-1252", "1033"],
+  "eo" =>	["Esperanto", "WINDOWS-1252", "9998"],
+  "es" =>	["Spanish", "WINDOWS-1252", "1034"],
+  "et" =>	["Estonian", "WINDOWS-1257", "1061"],
+  "eu" =>	["Basque", "WINDOWS-1252", "1069"],
+  "fa" =>	["Farsi", "WINDOWS-1256", "1065"],
+  "fi" =>	["Finnish", "WINDOWS-1252", "1035"],
+  "fr" =>	["French", "WINDOWS-1252", "1036"],
+  "ga" =>	["Irish", "WINDOWS-1252", "2108"],
+  "gl" =>	["Galician", "WINDOWS-1252", "1110"],
 #  "gu" =>	["Gujarati", "UTF-8"],
-  "he" =>	["Hebrew", "WINDOWS-1255"],
+  "he" =>	["Hebrew", "WINDOWS-1255", "1037"],
 #  "hi" =>	["Hindi", "UTF-8"],
-  "hr" =>	["Croatian", "WINDOWS-1250"],
-  "hu" =>	["Hungarian", "WINDOWS-1250"],
-  "id" =>	["Indonesian", "WINDOWS-1252"],
-  "it" =>	["Italian", "WINDOWS-1252"],
-  "ja" =>	["Japanese", "CP932"],
+  "hr" =>	["Croatian", "WINDOWS-1250", "1050"],
+  "hu" =>	["Hungarian", "WINDOWS-1250", "1038"],
+  "id" =>	["Indonesian", "WINDOWS-1252", "1057"],
+  "is" =>	["Icelandic", "WINDOWS-1252", "15"], #This should be 1039!
+  "it" =>	["Italian", "WINDOWS-1252", "1040"],
+  "ja" =>	["Japanese", "CP932", "1041"],
 #  "ka" =>	["Georgian", "UTF-8"],
-  "ko" =>	["Korean", "CP949"],
-  "ku" =>	["Kurdish", "WINDOWS-1254"],
-  "lt" =>	["Lithuanian", "WINDOWS-1257"],
-  "mk" =>	["Macedonian", "WINDOWS-1251"],
+  "ko" =>	["Korean", "CP949", "1042"],
+  "ku" =>	["Kurdish", "WINDOWS-1254", "9999"],
+  "lb" =>	["Luxembourgish", "WINDOWS-1252", "4103"],
+  "lt" =>	["Lithuanian", "WINDOWS-1257", "1063"],
+  "lv" =>	["Latvian", "WINDOWS-1257", "1062"],
+  "mk" =>	["Macedonian", "WINDOWS-1251", "1071"],
 #  "ml" =>	["Malayalam", "UTF-8"],
 #  "mr" =>	["Marathi", "UTF-8"],
-  "ms" =>	["Malay", "WINDOWS-1252"],
-  "nb" =>	["Norwegian", "WINDOWS-1252"],
+  "mn" =>	["Mongolian", "WINDOWS-1251", "1104"],
+  "ms" =>	["Malay", "WINDOWS-1252", "1086"],
+  "nb" =>	["Norwegian", "WINDOWS-1252", "1044"],
 #  "ne" =>	["Nepal", "UTF-8"],
-  "nl" =>	["Dutch", "WINDOWS-1252"],
-  "nn" =>	["NorwegianNynorsk", "WINDOWS-1252"],
+  "nl" =>	["Dutch", "WINDOWS-1252", "1043"],
+  "nn" =>	["NorwegianNynorsk", "WINDOWS-1252", "2068"],
 #  "oc" =>	["Occitan", "WINDOWS-1252"],
 #  "pa" =>	["Punjabi", "UTF-8"],
-  "pl" =>	["Polish", "WINDOWS-1250"],
-  "pt" =>	["Portuguese", "WINDOWS-1252"],
-  "pt_BR" =>	["PortugueseBR", "WINDOWS-1252"],
-  "ro" =>	["Romanian", "WINDOWS-1250"],
-  "ru" =>	["Russian", "WINDOWS-1251"],
- # "rw" =>	["Kinyarwanda", "UTF-8"],
-  "sk" =>	["Slovak", "WINDOWS-1250"],
-  "sl" =>	["Slovenian", "WINDOWS-1250"],
+  "pl" =>	["Polish", "WINDOWS-1250", "1045"],
+  "pt" =>	["Portuguese", "WINDOWS-1252", "2070"],
+  "pt_BR" =>	["PortugueseBR", "WINDOWS-1252", "1046"],
+  "ro" =>	["Romanian", "WINDOWS-1250", "1048"],
+  "ru" =>	["Russian", "WINDOWS-1251", "1049"],
+#  "rw" =>	["Kinyarwanda", "UTF-8"],
+  "sk" =>	["Slovak", "WINDOWS-1250", "1051"],
+  "sl" =>	["Slovenian", "WINDOWS-1250", "1060"],
 #  "so" =>	["Somali", "UTF-8"],
-  "sq" =>	["Albanian", "WINDOWS-1252"],
-  "sr" =>	["Serbian", "WINDOWS-1251"],
-  "sr\@latin" =>	["SerbianLatin", "WINDOWS-1250"],
-  "sv" =>	["Swedish", "WINDOWS-1252"],
+  "sq" =>	["Albanian", "WINDOWS-1252", "1052"],
+  "sr" =>	["Serbian", "WINDOWS-1251", "3098"],
+  "sr\@latin" =>	["SerbianLatin", "WINDOWS-1250", "2074"],
+  "sv" =>	["Swedish", "WINDOWS-1252", "1053"],
 #  "ta" =>	["Tamil", "UTF-8"],
-  "th" =>	["Thai", "WINDOWS-874"],
-  "tr" =>	["Turkish", "WINDOWS-1254"],
-  "uk" =>	["Ukrainian", "WINDOWS-1251"],
+  "th" =>	["Thai", "WINDOWS-874", "1054"],
+  "tr" =>	["Turkish", "WINDOWS-1254", "1055"],
+  "uk" =>	["Ukrainian", "WINDOWS-1251", "1058"],
+  "uz" =>	["Uzbek", "WINDOWS-1252", "1091"],
 #  "ur" =>	["Urdu", "UTF-8"],
 #  "vi" =>	["Vietnamese", "WINDOWS-1258"],
 #  "wa" =>	["Walloon", "WINDOWS-1252"],
-  "zh" =>	["SimpChinese", "WINDOWS-936"],
-  "zh" =>	["TradChinese", "CP950"],
+  "zh_CN" =>	["SimpChinese", "WINDOWS-936", "2052"],
+  "zh_TW" =>	["TradChinese", "CP950", "1028"],
 );
 
 my @localeKeys = keys(%localeNames);
@@ -194,11 +205,6 @@ $muiLanguages = '
   !insertmacro MUI_LANGUAGE "English"
 ';
 
-foreach my $lang (@localeKeys) {
-    if ( $lang eq "en" ) { next; }
-    $muiLanguages .= "  !insertmacro MUI_LANGUAGE \"$localeNames{$lang}[0]\"\n";
-}
-
 # The specific GCompris translation for the installer
 # replacing:
 #   @GCOMPRIS_MACRO_INCLUDE_LANGFILE@
@@ -264,34 +270,6 @@ $gcomprisLanguages .= '
 !macroend
 ';
 
-foreach my $lang (@localeKeys) {
-    $gcomprisLanguages .= "  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE".
-     " \"$localeNames{$lang}[0]\"".
-     " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n";
-}
-
-# We have all the data, let's replace it
-my $gcomprisInstaller;
-open (MYFILE, $installer);
-while (<MYFILE>) {
-    if ($_ =~ /\@INSERT_TRANSLATIONS\@/)
-    {
-	print "Processing \@INSERT_TRANSLATIONS\@\n";
-	$gcomprisInstaller .= $muiLanguages;
-	$gcomprisInstaller .= $gcomprisLanguages;
-    }
-    else
-    {
-	$gcomprisInstaller .= "$_";
-    }
-}
-close (MYFILE);
-
-# Rewrite the file with the replaced data
-open (MYFILE, ">$installer");
-print MYFILE "$gcomprisInstaller";
-close (MYFILE);
-
 #
 # Create each nsh translation file
 #
@@ -306,6 +284,10 @@ close DESC;
 }
 close DESC;
 
+$gcomprisLanguages .= "  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE".
+    " \"ENGLISH\"".
+   " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\en.nsh\"\n";
+
 #
 # Two pass are needed:
 # - create the utf8 file
@@ -319,14 +301,18 @@ foreach my $lang (@localeKeys) {
     print DESC ";; Code Page: $localeNames{$lang}[1]\n";
 
     my $text_locale = $result{"$lang"};
+    my $total_key_count = 0;
+    my $found_key_count = 0;
     foreach my $keyEn (keys(%$text_en)) {
 	my $found = 0;
+	$total_key_count++;
 	foreach my $keyLocale (keys(%$text_locale)) {
 	    # Fine, we found a translation
 	    if ( $keyLocale eq $keyEn )
 	    {
 		print DESC "$result{$lang}{$keyLocale}";
 		$found = 1;
+		$found_key_count++;
 		last;
 	    }
 	}
@@ -339,6 +325,18 @@ foreach my $lang (@localeKeys) {
     }
     close DESC;
 
+    # If we have at least 50% of the keys found, include the language
+    if (($found_key_count * 1.0 / $total_key_count) >= 0.5) {
+        $muiLanguages .= "  !insertmacro MUI_LANGUAGE \"$localeNames{$lang}[0]\"\n";
+        $gcomprisLanguages .= "  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE".
+            " \"". uc($localeNames{$lang}[0]) . "\"".
+            " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n";
+    } else {
+        print "Ignoring language $lang because it is less than 50% translated ($found_key_count of $total_key_count).\n";
+        continue;
+    }
+
+
     # iconv conversion
     system("iconv -f UTF-8 -t $localeNames{$lang}[1] $tmp_dir/$lang.nsh.utf8 > $tmp_dir/$lang.nsh");
     if ($? ne 0)
@@ -348,3 +346,25 @@ foreach my $lang (@localeKeys) {
     #`rm $tmp_dir/$lang.nsh.utf8`;
 
 }
+
+# We have all the data, let's replace it
+my $gcomprisInstaller;
+open (MYFILE, $installer);
+while (<MYFILE>) {
+    if ($_ =~ /\@INSERT_TRANSLATIONS\@/)
+    {
+	print "Processing \@INSERT_TRANSLATIONS\@\n";
+	$gcomprisInstaller .= $muiLanguages;
+	$gcomprisInstaller .= $gcomprisLanguages;
+    }
+    else
+    {
+	$gcomprisInstaller .= "$_";
+    }
+}
+close (MYFILE);
+
+# Rewrite the file with the replaced data
+open (MYFILE, ">$installer");
+print MYFILE "$gcomprisInstaller";
+close (MYFILE);


More information about the Commits mailing list