Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools/create_nsis_translations.pl
blob: cc3e390d1b0d1bd94ae3af936e26f4e6e2e10b32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/perl

# You must 'cd' to the top directory of GCompris before you run it

use strict;

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);

my %localeNames = (
  "af", "Afrikaans",
#  "am", "Amharic",
  "ar", "Arabic",
  "bg",	"Bulgarian",
  "br",	"Breton",
  "ca",	"Catalan",
  "cs",	"Czech",
  "da", "Danish",
  "de", "German",
#  "dz",	"Dzongkha",
  "el", "Greek",
  "es", "Spanish",
  "eu",	"Basque",
#  "fa", "Persian",
  "fi", "Finnish",
  "fr", "French",
  "ga", "Irish",
#  "gu",	"Gujarati",
  "he",	"Hebrew",
#  "hi",	"Hindi",
  "hr",	"Croatian",
  "hu",	"Hungarian",
  "id",	"Indonesian",
  "it", "Italian",
  "ja",	"Japanese",
#  "ka", "Georgian",
  "ko", "Korean",
  "lt",	"Lithuanian",
  "mk",	"Macedonian",
#  "ml",	"Malayalam",
#  "mr",	"Marathi",
  "ms",	"Malay",
  "nb",	"Norwegian",
#  "ne",	"Nepal",
  "nl",	"Dutch",
  "nn",	"NorwegianNynorsk",
#  "oc",	"Occitan",
#  "pa",	"Punjabi",
  "pl",	"Polish",
  "pt",	"Portuguese",
  "pt_BR", "PortugueseBR",
  "ro",	"Romanian",
  "ru",	"Russian",
 # "rw",	"Kinyarwanda",
  "sk",	"Slovak",
  "sl",	"Slovenian",
#  "so",	"Somali",
  "sq",	"Albanian",
  "sr",	"Serbian",
  "sv",	"Swedish",
#  "ta",	"Tamil",
  "th",	"Thai",
  "tr",	"Turkish",
  "uk", "Ukrainian",
#  "ur",	"Urdu",
#  "vi",	"Vietnamese",
#  "wa",	"Walloon",
  "zh",	"SimpChinese",
  "zh", "TradChinese"
);

my @localeKeys = keys(%localeNames);

# Lets insert the default languages
# in the installer file which means replacing:
#   @INSERTMACRO_MUI_LANGUAGE@
# By the list of locales:
#   !insertmacro MUI_LANGUAGE "French"

my $muiLanguages;
foreach my $lang (@localeKeys) {
    $muiLanguages .= "  !insertmacro MUI_LANGUAGE \"$localeNames{$lang}\"\n";
}

# The specific GCompris translation for the installer
# replacing:
#   @GCOMPRIS_MACRO_INCLUDE_LANGFILE@
# By the list of locales:
#   !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE "ALBANIAN" "${GCOMPRIS_NSIS_INCLUDE_PATH}\translations\albanian.nsh"

my $gcomprisLanguages;
foreach my $lang (@localeKeys) {
    $gcomprisLanguages .= "  !insertmacro GCOMPRIS_MACRO_INCLUDE_LANGFILE".
     " \"$localeNames{$lang}\"".
     "\"\${GCOMPRIS_NSIS_INCLUDE_PATH}\\translations\\$lang.nsh\"\n";
}

# We have all the data, let's replace it
my $gcomprisInstaller;
open (MYFILE, 'gcompris-installer.nsi');
while (<MYFILE>) {
    if ($_ =~ /\@INSERTMACRO_MUI_LANGUAGE\@/)
    {
	print "Processing \@INSERTMACRO_MUI_LANGUAGE\@\n";
	$gcomprisInstaller .= $muiLanguages;
    }
    elsif ($_ =~ /\@GCOMPRIS_MACRO_INCLUDE_LANGFILE\@/)
    {
	print "Processing \@GCOMPRIS_MACRO_INCLUDE_LANGFILE\@\n";
	$gcomprisInstaller .= $gcomprisLanguages;
    }
    else
    {
	$gcomprisInstaller .= "$_";
    }
}
close (MYFILE);

# Rewrite the file with the replaced data
open (MYFILE, '>gcompris-installer.nsi');
print MYFILE "$gcomprisInstaller";
close (MYFILE);

# Create each nsh translation file

print "Creating each nsh file\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";
    }
    close DESC;
}