Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBruno Coudoin <bruno.coudoin@free.fr>2009-07-24 22:08:09 (GMT)
committer Bruno Coudoin <bruno.coudoin@free.fr>2009-07-24 22:12:41 (GMT)
commit59a4960281f00a970b9f30efde72cfa95a4a2853 (patch)
treef299827472fc2d2c912c15befb78412d483d92da /tools
parent04674b8e2492d75317a40b9e7734aff503d65d92 (diff)
Improved the create_nsis_translations.pl. Added the GPL header.
Added command line parameter and usage for this script.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/create_nsis_translations.pl99
1 files changed, 87 insertions, 12 deletions
diff --git a/tools/create_nsis_translations.pl b/tools/create_nsis_translations.pl
index 119bfe8..db44483 100755
--- a/tools/create_nsis_translations.pl
+++ b/tools/create_nsis_translations.pl
@@ -1,14 +1,89 @@
#!/usr/bin/perl
-
-# You must 'cd' to the top directory of GCompris before you run it
+#
+# create_nsis_translations.pl
+#
+# Copyright (C) 2000-2009 Bruno Coudoin
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
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);
+sub usage {
+ print 'create_nsis_translations.pl translations installer tmp_dir
+ translations
+ This is an input file that contains all the
+ translated strings. If must be formated as a GNU/Linux
+ desktop file and contains multiple strings entry.
+ For example you must have:
+ toBe=To be or not to be
+ toBe[fr]=Etre ou ne pas etre
+
+ installer
+ This is your nsis installer source file. You must include
+ in it the marker @INSERT_TRANSLATIONS@ before you use any
+ translation string.
+ After that you can use the variable $(toBe) in your file.
+
+ tmp_dir
+ This is a directory in which temporary files needed for
+ the translation system.
+ It will be created if non existant.
+ You can remove it once you have created your installer.
+';
+}
+
+my $translations;
+if (! $ARGV[0] || ! -f $ARGV[0])
+{
+ usage();
+}
+else
+{
+ $translations = $ARGV[0];
+}
+
+shift;
+my $installer;
+if (! $ARGV[0] || ! -f $ARGV[0])
+{
+ usage();
+}
+else
+{
+ $installer = $ARGV[0];
+}
+
+shift;
+my $tmp_dir;
+if (! $ARGV[0] )
+{
+ usage();
+}
+else
+{
+ $tmp_dir = $ARGV[0];
+
+ if ( ! -d $tmp_dir )
+ {
+ mkdir $tmp_dir or die "ERROR: '$tmp_dir' $!\n";
+ }
+}
+
+print "Processing translation file '$translations'\n";
+print " NSIS source file '$installer'\n";
+print " Working dir '$tmp_dir'\n";
# Commented out locales that are not available in nsis
my %localeNames = (
@@ -82,7 +157,7 @@ print "Parsing nsis_translations.desktop\n";
my %result;
# Create a hash of the keys to translate
-open (MYFILE, 'nsis_translations.desktop');
+open (MYFILE, $translations);
while (<MYFILE>) {
chomp $_;
if ($_ =~ /Encoding=UTF-8/)
@@ -194,7 +269,7 @@ foreach my $lang (@localeKeys) {
# We have all the data, let's replace it
my $gcomprisInstaller;
-open (MYFILE, 'gcompris-installer.nsi');
+open (MYFILE, $installer);
while (<MYFILE>) {
if ($_ =~ /\@INSERT_TRANSLATIONS\@/)
{
@@ -210,7 +285,7 @@ while (<MYFILE>) {
close (MYFILE);
# Rewrite the file with the replaced data
-open (MYFILE, '>gcompris-installer.nsi');
+open (MYFILE, ">$installer");
print MYFILE "$gcomprisInstaller";
close (MYFILE);
@@ -219,7 +294,7 @@ close (MYFILE);
#
print "Creating the nsh default file\n";
-open (DESC, ">nsis/translations/en.nsh");
+open (DESC, ">$tmp_dir/en.nsh");
print DESC ";; Auto generated file by create_nsis_translations.pl\n";
foreach my $keyEn (keys(%$text_en)) {
my $line = $result{'en'}{$keyEn};
@@ -231,7 +306,7 @@ close DESC;
print "Creating the nsh locale files\n";
foreach my $lang (@localeKeys) {
if ( $lang eq "en" ) { next; }
- open (DESC, ">nsis/translations/$lang.nsh");
+ open (DESC, ">$tmp_dir/$lang.nsh");
print DESC ";; Auto generated file by create_nsis_translations.pl\n";
my $text_locale = $result{"$lang"};