Mercurial > pidgin.yaz
comparison pidgin/win32/nsis/create_nsis_translations.pl @ 30396:62f0988c666c
Final piece of getting the installer translations integrated with the regular
po files. This is a variation of the instructions at:
http://nsis.sourceforge.net/Creating_language_files_and_integrating_with_MUI
Using a Perl tool that the gcompris folks wrote.
The NSIS LangStrings needed to have the underscores removed because .desktop
files variable names may not contain underscores.
Currently only translations with >=50% coverage will be present in the installer
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 19 May 2010 03:26:05 +0000 |
parents | 5edd3992f59d |
children |
comparison
equal
deleted
inserted
replaced
30395:5edd3992f59d | 30396:62f0988c666c |
---|---|
286 | 286 |
287 $gcomprisLanguages .= " !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE". | 287 $gcomprisLanguages .= " !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE". |
288 " \"ENGLISH\"". | 288 " \"ENGLISH\"". |
289 " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\en.nsh\"\n"; | 289 " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\en.nsh\"\n"; |
290 | 290 |
291 my $selectTranslationFunction = ' | |
292 !macro SELECT_TRANSLATION_SECTION LANG_NAME LANG_CODE | |
293 StrCmp "$LANGUAGE" "${LANG_${LANG_NAME}}" 0 end_${LANG_CODE} | |
294 !insertmacro SelectSection ${SecLang_${LANG_CODE}} | |
295 Goto done | |
296 end_${LANG_CODE}: | |
297 !macroend | |
298 ; Convert the current $LANGUAGE to a language code that we can use for translation mo selection | |
299 ; If there\'s a better way to do this, I\'d love to know it | |
300 !macro SELECT_TRANSLATION_FUNCTION | |
301 '; | |
302 | |
291 # | 303 # |
292 # Two pass are needed: | 304 # Two pass are needed: |
293 # - create the utf8 file | 305 # - create the utf8 file |
294 # - transform it to the proper windows locale | 306 # - transform it to the proper windows locale |
295 # | 307 # |
329 if (($found_key_count * 1.0 / $total_key_count) >= 0.5) { | 341 if (($found_key_count * 1.0 / $total_key_count) >= 0.5) { |
330 $muiLanguages .= " !insertmacro MUI_LANGUAGE \"$localeNames{$lang}[0]\"\n"; | 342 $muiLanguages .= " !insertmacro MUI_LANGUAGE \"$localeNames{$lang}[0]\"\n"; |
331 $gcomprisLanguages .= " !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE". | 343 $gcomprisLanguages .= " !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE". |
332 " \"". uc($localeNames{$lang}[0]) . "\"". | 344 " \"". uc($localeNames{$lang}[0]) . "\"". |
333 " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n"; | 345 " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n"; |
346 $selectTranslationFunction .= " !insertmacro SELECT_TRANSLATION_SECTION". | |
347 " \"" . uc($localeNames{$lang}[0]) . "\" \"$lang\"\n"; | |
334 } else { | 348 } else { |
335 print "Ignoring language $lang because it is less than 50% translated ($found_key_count of $total_key_count).\n"; | 349 print "Ignoring language $lang because it is less than 50% translated ($found_key_count of $total_key_count).\n"; |
336 continue; | 350 next; |
337 } | 351 } |
338 | 352 |
339 | 353 |
340 # iconv conversion | 354 # iconv conversion |
341 system("iconv -f UTF-8 -t $localeNames{$lang}[1] $tmp_dir/$lang.nsh.utf8 > $tmp_dir/$lang.nsh"); | 355 system("iconv -f UTF-8 -t $localeNames{$lang}[1] $tmp_dir/$lang.nsh.utf8 > $tmp_dir/$lang.nsh"); |
344 die("ERROR: Failed to run: iconv -f UTF-8 -t $localeNames{$lang}[1] $lang.nsh.utf8 > $lang.nsh\n"); | 358 die("ERROR: Failed to run: iconv -f UTF-8 -t $localeNames{$lang}[1] $lang.nsh.utf8 > $lang.nsh\n"); |
345 } | 359 } |
346 #`rm $tmp_dir/$lang.nsh.utf8`; | 360 #`rm $tmp_dir/$lang.nsh.utf8`; |
347 | 361 |
348 } | 362 } |
363 | |
364 $selectTranslationFunction .= ' | |
365 done: | |
366 !macroend | |
367 '; | |
349 | 368 |
350 # We have all the data, let's replace it | 369 # We have all the data, let's replace it |
351 my $gcomprisInstaller; | 370 my $gcomprisInstaller; |
352 open (MYFILE, $installer); | 371 open (MYFILE, $installer); |
353 while (<MYFILE>) { | 372 while (<MYFILE>) { |
354 if ($_ =~ /\@INSERT_TRANSLATIONS\@/) | 373 if ($_ =~ /\@INSERT_TRANSLATIONS\@/) |
355 { | 374 { |
356 print "Processing \@INSERT_TRANSLATIONS\@\n"; | 375 print "Processing \@INSERT_TRANSLATIONS\@\n"; |
357 $gcomprisInstaller .= $muiLanguages; | 376 $gcomprisInstaller .= $muiLanguages; |
358 $gcomprisInstaller .= $gcomprisLanguages; | 377 $gcomprisInstaller .= $gcomprisLanguages; |
378 $gcomprisInstaller .= $selectTranslationFunction; | |
359 } | 379 } |
360 else | 380 else |
361 { | 381 { |
362 $gcomprisInstaller .= "$_"; | 382 $gcomprisInstaller .= "$_"; |
363 } | 383 } |