[gcompris] Completed the integration of the create_nsis_translation.pl script
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: svn-commits-list gnome org
- Subject: [gcompris] Completed the integration of the create_nsis_translation.pl script
- Date: Wed, 22 Jul 2009 00:04:50 +0000 (UTC)
commit e19b035ed943ae1ce278cb7a306d269b75ae906b
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Wed Jul 22 02:02:39 2009 +0200
Completed the integration of the create_nsis_translation.pl script
that does the export of nsis installer strings to translate to the po
files.
gcompris-installer.nsi.in | 2 -
nsis/langmacros.nsh | 6 ++--
nsis_translations.desktop.in | 12 +++---
tools/create_nsis_translations.pl | 73 ++++++++++++++++++++++++++++++++-----
4 files changed, 72 insertions(+), 21 deletions(-)
---
diff --git a/gcompris-installer.nsi.in b/gcompris-installer.nsi.in
index 60ce894..db5989b 100644
--- a/gcompris-installer.nsi.in
+++ b/gcompris-installer.nsi.in
@@ -103,8 +103,6 @@ SetDateSave on
!include "${GCOMPRIS_NSIS_INCLUDE_PATH}\langmacros.nsh"
- !define GCOMPRIS_DEFAULT_LANGFILE "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\english.nsh"
-
@GCOMPRIS_MACRO_INCLUDE_LANGFILE@
;--------------------------------
diff --git a/nsis/langmacros.nsh b/nsis/langmacros.nsh
index 0dfdd97..4a6b46e 100755
--- a/nsis/langmacros.nsh
+++ b/nsis/langmacros.nsh
@@ -29,11 +29,11 @@
; String labels should match those from the default language file.
; Startup checks
- !insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT InstallerIsRunning ${CUR_LANG}
- !insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT GcomprisIsRunning ${CUR_LANG}
+ !insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT InstallerIsRunning ${CUR_LANG}
+ !insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT GcomprisIsRunning ${CUR_LANG}
; License Page
- !insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT GcomprisLicenseButton ${CUR_LANG}
+ !insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT GcomprisLicenseButton ${CUR_LANG}
!insertmacro GCOMPRIS_MACRO_LANGSTRING_INSERT GcomprisLicenseBottomText ${CUR_LANG}
; Installer Finish Page
diff --git a/nsis_translations.desktop.in b/nsis_translations.desktop.in
index beb5d49..18e597f 100644
--- a/nsis_translations.desktop.in
+++ b/nsis_translations.desktop.in
@@ -1,11 +1,11 @@
[Desktop Entry]
Encoding=UTF-8
_InstallerIsRunning=The installer is already running.
-_GcomprisisRunning=An instance of GCompris is currently running. Exit GCompris and then try again.
+_GcomprisIsRunning=An instance of GCompris is currently running. Exit GCompris and then try again.
_GcomprisLicenseButton=Next >
_GcomprisLicenseBottomText=GCompris is released under the GNU General Public License (GPL). The license is provided here for information purposes only. \$_CLICK
-_GcomprisFinishVisitWebSite=Visit the Windows GCompris Web Page
-_GcomprisPromptWipeout=Your old GCompris directory is about to be deleted. Would you like to continue?$\\r$\\rNote: Any non-standard plugins that you may have installed will be deleted.$\\rGCompris user settings will not be affected.
-_GcomprisPromptDirExists=The installation directory you specified already exists. Any contents$\\rwill be deleted. Would you like to continue?
-_unGCOMPRISUninstallError1=the uninstaller could not find registry entries for GCompris.$\\rIt is likely that another user installed this application.
-_unGCOMPRISUninstallError2=You do not have permission to uninstall this application.
+_GcomprisFinishVisitWebSite=Visit the GCompris Web Site
+_GcomprisPromptWipeout=Your old GCompris directory is about to be deleted. Would you like to continue?$\r$\rNote: Any non-standard plugins that you may have installed will be deleted.$\rGCompris user settings will not be affected.
+_GcomprisPromptDirExists=The installation directory you specified already exists. Any contents$\rwill be deleted. Would you like to continue?
+_unGcomprisUninstallError1=the uninstaller could not find registry entries for GCompris.$\rIt is likely that another user installed this application.
+_unGcomprisUninstallError2=You do not have permission to uninstall this application.
diff --git a/tools/create_nsis_translations.pl b/tools/create_nsis_translations.pl
index cc3e390..f2e8b0a 100755
--- a/tools/create_nsis_translations.pl
+++ b/tools/create_nsis_translations.pl
@@ -3,12 +3,14 @@
# You must 'cd' to the top directory of GCompris before you run it
use strict;
+use Data::Dumper;
my $gcompris_root_dir = ".";
my $ALL_LINGUAS_STR = `grep "ALL_LINGUAS=" $gcompris_root_dir/configure.in | cut -d= -f2`;
$ALL_LINGUAS_STR =~ s/\"//g;
my @ALL_LINGUAS = split(' ', $ALL_LINGUAS_STR);
+# Commented out locales that are not available in nsis
my %localeNames = (
"af", "Afrikaans",
# "am", "Amharic",
@@ -90,11 +92,13 @@ foreach my $lang (@localeKeys) {
# By the list of locales:
# !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "ALBANIAN" "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\albanian.nsh"
-my $gcomprisLanguages;
+my $gcomprisLanguages = " !define GCOMPRIS_DEFAULT_LANGFILE" .
+ " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\en.nsh\"\n\n";
+
foreach my $lang (@localeKeys) {
$gcomprisLanguages .= " !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE".
" \"$localeNames{$lang}\"".
- "\"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n";
+ " \"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n";
}
# We have all the data, let's replace it
@@ -123,21 +127,70 @@ open (MYFILE, '>gcompris-installer.nsi');
print MYFILE "$gcomprisInstaller";
close (MYFILE);
+#
# Create each nsh translation file
+#
+print "Parsing nsis_translations.desktop\n";
+
+# Create the holder for the results
+# %result{"locale"}{"stringname"} = result line
+my %result;
+
+# Create a hash of the keys to translate
+open (MYFILE, 'nsis_translations.desktop');
+while (<MYFILE>) {
+ chomp $_;
+ if ($_ =~ /Encoding=UTF-8/)
+ {
+ next;
+ }
+ elsif ($_ =~ /^(\w+)=(.*)/)
+ {
+ my $line = "!define $1 \"$2\"\n";
+ $result{"en"}{"$1"} = $line;
+ }
+ elsif ($_ =~ /^(\w+)\[(\w+)\]=(.*)/)
+ {
+ my $line = "!define $1 \"$3\"\n";
+ $result{"$2"}{"$1"} = $line;
+ }
+}
+close (MYFILE);
-print "Creating each nsh file\n";
+print "Creating the nsh default file\n";
+my $text_en = $result{"en"};
+open (DESC, ">nsis/translations/en.nsh");
+print DESC ";; Auto generated file by create_nsis_translations.pl\n";
+foreach my $keyEn (keys(%$text_en)) {
+ my $line = $result{'en'}{$keyEn};
+ $line =~ s/!define /!insertmacro GCOMPRIS_MACRO_DEFAULT_STRING /;
+ print DESC $line;
+}
+close DESC;
+print "Creating the nsh locale files\n";
foreach my $lang (@localeKeys) {
open (DESC, ">nsis/translations/$lang.nsh");
print DESC ";; Auto generated file by create_nsis_translations.pl\n";
- # Extract the string to translate from the nsis_translations file
- my @text = `grep "\\\[$lang\\\]" $gcompris_root_dir/nsis_translations.desktop`;
-
- foreach my $line (@text) {
- chomp $line;
- my @keyval = split("=", $line);
- print DESC "@keyval[0]=\"@keyval[1]\"\n";
+ my $text_locale = $result{"$lang"};
+ foreach my $keyEn (keys(%$text_en)) {
+ my $found = 0;
+ foreach my $keyLocale (keys(%$text_locale)) {
+ # Fine, we found a translation
+ if ( $keyLocale eq $keyEn )
+ {
+ print DESC "$result{$lang}{$keyLocale}";
+ $found = 1;
+ last;
+ }
+ }
+ # English keys are the reference.
+ # If not found they are inserted
+ if ( ! $found )
+ {
+ print DESC "$result{'en'}{$keyEn}";
+ }
}
close DESC;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]