2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 my $lastcompletelangiso_var;
23 my $completelangiso_var = $ENV{COMPLETELANGISO_VAR
};
24 my $help_langs_var = $ENV{HELP_LANGS
};
26 if ( !defined $completelangiso_var) {
27 print STDERR
"ERROR: No language defined!\n";
31 if (!args_require_build
()) {
32 print STDERR
"No new languages, or config. Keeping old file\n";
36 my @completelangiso = split " +", $completelangiso_var;
37 my @helplangs = split " +", $help_langs_var;
39 open OUTFILE
, ">$outfile" or die "$0 ERROR: cannot open $outfile for writing!\n";
41 print OUTFILE
"// generated file, do not edit\n\n";
42 print OUTFILE
"// languages used for last time generation\n";
43 print OUTFILE
"// completelangiso: $completelangiso_var\n\n";
44 print OUTFILE
"// help_langs: $help_langs_var\n\n";
45 write_ITERATE_ALL_LANG
();
48 write_DIR_ISOLANGUAGE_ALL_LANG_2
();
49 write_DIR_ISOLANGUAGE_ALL_LANG
();
50 write_DIR_ISOLANGUAGE_ALL_LANG_LPROJ
();
51 write_EXTRA_ALL_LANG
();
52 write_EXTRA_ALL_LANG_BUT_EN_US
();
53 write_MO_ALL_LANG_EXCEPT_EN_US_AND_QTZ
();
54 write_EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG
();
55 write_RESFILE_ALL_LANG
();
56 write_README_ALL_LANG
();
57 write_README_TXT_ALL_LANG
();
58 write_FILE_ALL_LANG_LETTER
();
62 rename $outfile, $destfile;
64 sub write_ITERATE_ALL_LANG
66 print OUTFILE
"#define ITERATE_ALL_LANG_FILE(gid,dir,macro,name,ext) ";
67 foreach $lang (@helplangs) {
68 my $shortlang = $lang;
69 $shortlang = "en" if $shortlang eq "en-US";
70 my $speciallang = $lang;
71 $speciallang =~ s/-/_/;
72 print OUTFILE
"\\\nFile CONCAT3(gid_File_,gid,_$speciallang)";
73 print OUTFILE
"\\\n\tDir = CONCAT3(gid_Dir_,dir,_$speciallang);";
74 print OUTFILE
"\\\n\tmacro;";
75 print OUTFILE
"\\\n\tName = STRING(CONCAT3(name,_$lang,ext)); ";
76 print OUTFILE
"\\\nEnd ";
81 print OUTFILE
"#define ITERATE_ALL_LANG_DIR_LPROJ(gid,parent) ";
82 foreach $lang (@helplangs) {
83 my $shortlang = $lang;
84 $shortlang = "en" if $shortlang eq "en-US";
85 my $speciallang = $lang;
86 $speciallang =~ s/-/_/;
87 print OUTFILE
"\\\nDirectory CONCAT3(gid_Dir_,gid,_$speciallang)";
88 print OUTFILE
"\\\n\tParentID = CONCAT2(gid_Dir_,parent);";
89 print OUTFILE
"\\\n\tDosName = \"$shortlang.lproj\"; ";
90 print OUTFILE
"\\\nEnd ";
98 print OUTFILE
"#define ALL_LANG(ident, resid) ";
99 foreach $lang (@completelangiso) {
100 print OUTFILE
"\\\n\tident ($lang) = resid";
101 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
103 print OUTFILE
"\n\n";
106 sub write_OTHER_LANGS
108 print OUTFILE
"#define OTHER_LANGS ";
109 foreach $lang (@completelangiso) {
110 next if ( $lang eq "en-US");
111 print OUTFILE
"\\\n\tDosName ($lang) = \"$lang\"";
112 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
114 print OUTFILE
"\n\n";
117 sub write_DIR_ISOLANGUAGE_ALL_LANG_2
119 print OUTFILE
"#define DIR_ISOLANGUAGE_ALL_LANG_2 ";
120 print OUTFILE
"\\\n\tDosName (en-US) = \"en-US\"; \\\n\t";
121 print OUTFILE
"OTHER_LANGS";
122 print OUTFILE
"\n\n";
125 sub write_DIR_ISOLANGUAGE_ALL_LANG
127 print OUTFILE
"#define DIR_ISOLANGUAGE_ALL_LANG ";
128 print OUTFILE
"\\\n\tDosName (en-US) = \"en\"; \\\n\t";
129 print OUTFILE
"OTHER_LANGS";
130 print OUTFILE
"\n\n";
133 sub write_DIR_ISOLANGUAGE_ALL_LANG_LPROJ
135 print OUTFILE
"#define DIR_ISOLANGUAGE_ALL_LANG_LPROJ ";
136 foreach $lang (@completelangiso) {
137 my $speciallang = $lang;
138 if ( $speciallang eq "en-US" ) { $speciallang = "en"; }
139 print OUTFILE
"\\\n\tDosName ($lang) = \"$speciallang.lproj\"";
140 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
142 print OUTFILE
"\n\n";
145 sub write_EXTRA_ALL_LANG
147 print OUTFILE
"#define EXTRA_ALL_LANG(name,ext) ";
148 foreach $lang (@completelangiso) {
149 print OUTFILE
"\\\n\tName ($lang) = CONFIGLANGFILENAME(name,_$lang,ext)";
150 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
152 print OUTFILE
"\n\n";
155 sub write_EXTRA_ALL_LANG_BUT_EN_US
157 print OUTFILE
"#define EXTRA_ALL_LANG_BUT_EN_US(name,ext) ";
159 foreach $lang (@completelangiso) {
160 if ($lang ne "en-US") {
161 print OUTFILE
"; " unless $first;
164 "\\\n\tName ($lang) = CONFIGLANGFILENAME(name,_$lang,ext)";
167 print OUTFILE
"\n\n";
170 sub write_MO_ALL_LANG_EXCEPT_EN_US_AND_QTZ
172 print OUTFILE
"#define MO_ALL_LANG_EXCEPT_EN_US_AND_QTZ(name) ";
174 foreach $lang (@completelangiso) {
175 if (($lang ne "en-US") and ($lang ne "qtz")) {
176 print OUTFILE
"; " unless $first;
178 my $SRC_ROOT = $ENV{"SRC_ROOT"};
179 my $langdir = `$SRC_ROOT/solenv/bin/localestr $lang`;
182 "\\\n\tName ($lang) = STRING(CONCAT3($langdir/LC_MESSAGES/,name,.mo))";
185 print OUTFILE
"\n\n";
188 sub write_EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG
191 print OUTFILE
"#define EXTRA_ALL_GOOD_HELP_LOCALIZATIONS_LANG(name) ";
192 foreach $lang (@helplangs) {
193 print OUTFILE
";" unless $first;
195 print OUTFILE
"\\\n\tName ($lang) = EXTRAFILELISTNAME(HelpTarget/,name,/$lang)";
197 print OUTFILE
"\n\n";
200 sub write_RESFILE_ALL_LANG
202 print OUTFILE
"#define RESFILE_ALL_LANG(name) ";
203 foreach $lang (@completelangiso) {
204 print OUTFILE
"\\\n\tName ($lang) = RESFILENAME(name,$lang)";
205 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
207 print OUTFILE
"\n\n";
210 sub write_README_ALL_LANG
212 print OUTFILE
"#define README_ALL_LANG(key, name) ";
213 foreach $lang (@completelangiso) {
214 print OUTFILE
"\\\n\tkey ($lang) = READMEFILENAME(name,_$lang)";
215 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
217 print OUTFILE
"\n\n";
220 sub write_README_TXT_ALL_LANG
222 print OUTFILE
"#define README_TXT_ALL_LANG(key, name, ext) ";
223 foreach $lang (@completelangiso) {
224 print OUTFILE
"\\\n\tkey ($lang) = READMETXTFILENAME(name,_$lang,ext)";
225 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
227 print OUTFILE
"\n\n";
230 sub write_FILE_ALL_LANG_LETTER
232 print OUTFILE
"#define FILE_ALL_LANG_LETTER(name, ext) ";
233 foreach $lang (@completelangiso) {
234 print OUTFILE
"\\\n\tName ($lang) = CONFIGLANGFILENAME(name,$lang,ext)";
235 print OUTFILE
"; " if ( $lang ne $completelangiso[$#completelangiso]);
237 print OUTFILE
"\n\n";
240 sub args_require_build
244 $destfile = shift @ARGV if ($opt eq '-o');
245 $config_stamp = shift @ARGV if ($opt eq '-c');
247 usage
() if (!defined ($destfile) || !defined ($config_stamp));
248 $outfile = "$destfile.tmp";
250 if ( -f
"$destfile" ) {
251 # changed script - run always
252 return 1 if (stat($0))[9] > (stat("$destfile"))[9] ;
254 # changed config timestamp - run always
255 if (-f
"$config_stamp") {
256 return 1 if (stat($config_stamp))[9] > (stat($destfile))[9];
259 open OLDFILE
, "$destfile" or die "$0 - ERROR: $outfile exists but isn't readable.\n";
260 while ( $line = <OLDFILE
> ) {
261 if ( $line =~ /^\/\
/.*completelangiso:/ ) {
262 $lastcompletelangiso_var = $line;
263 chomp $lastcompletelangiso_var;
264 $lastcompletelangiso_var =~ s/^\/\/.*completelangiso
:\s
*//;
271 return 0 if ( "$completelangiso_var" eq "$lastcompletelangiso_var" );
278 print STDERR
"Generate language dependent macros use in *.scp files\n";
279 print STDERR
"perl $0 -o <outputfile> -c <config_stamp_file>\n";