1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24package installer::languages; 25 26use installer::converter; 27use installer::existence; 28use installer::exiter; 29use installer::globals; 30use installer::remover; 31use installer::ziplist; 32 33=head2 analyze_languagelist() 34 35 Convert $installer::globals::languagelist into $installer::globals::languageproduct. 36 37 That is now just a replacement of '_' with ','. 38 39 $installer::globals::languageproduct (specified by the -l option 40 on the command line) can contain multiple languages separated by 41 '_' to specify multilingual builds. 42 43 Separation by '#' to build multiple languages (single or 44 multilingual) in one make_installer.pl run is not supported 45 anymore. Call make_installer.pl with all languages separately instead: 46 make_installer.pl -l L1#L2 47 -> 48 make_installer.pl -l L1 49 make_installer.pl -l L2 50 51=cut 52sub analyze_languagelist() 53{ 54 my $languageproduct = $installer::globals::languagelist; 55 56 $languageproduct =~ s/\_/\,/g; # substituting "_" by ",", in case of dmake definition 01_49 57 58 if ($languageproduct =~ /\#/) 59 { 60 installer::exiter::exit_program( 61 "building more than one language (or language set) is not supported anymore\n" 62 ."please replace one call of 'make_installer.pl -l language1#language2'\n" 63 ."with two calls 'make_installer.pl -l language1' and 'make_installer.pl -l language2'", 64 "installer::language::analyze_languagelist"); 65 } 66 67 $installer::globals::languageproduct = $languageproduct; 68} 69 70 71 72 73#################################################### 74# Reading languages from zip list file 75#################################################### 76 77sub get_info_about_languages 78{ 79 my ( $allsettingsarrayref ) = @_; 80 81 my $languagelistref; 82 83 $languagelistref = installer::ziplist::getinfofromziplist($allsettingsarrayref, "languages"); 84 $installer::globals::languagelist = $$languagelistref; 85 86 if ( $installer::globals::languagelist eq "" ) # not defined on command line and not in product list 87 { 88 installer::exiter::exit_program("ERROR: Languages not defined on command line (-l) and not in product list!", "get_info_about_languages"); 89 } 90 91 # Adapting the separator format from zip list. 92 # | means new product, , (comma) means more than one language in one product 93 # On the command line, | is difficult to use. Therefore this script uses hashes 94 95 $installer::globals::languagelist =~ s/\|/\#/g; 96 97 analyze_languagelist(); 98} 99 100############################################################################# 101# Checking whether all elements of an array A are also member of array B 102############################################################################# 103 104sub all_elements_of_array1_in_array2 105{ 106 my ($array1, $array2) = @_; 107 108 my $array2_contains_all_elements_of_array1 = 1; 109 110 for ( my $i = 0; $i <= $#{$array1}; $i++ ) 111 { 112 if (! installer::existence::exists_in_array(${$array1}[$i], $array2)) 113 { 114 $array2_contains_all_elements_of_array1 = 0; 115 last; 116 } 117 } 118 119 return $array2_contains_all_elements_of_array1; 120} 121 122############################################# 123# All languages defined for one product 124############################################# 125 126sub get_all_languages_for_one_product 127{ 128 my ( $languagestring, $allvariables ) = @_; 129 130 my @languagearray = (); 131 132 my $last = $languagestring; 133 134 $installer::globals::ismultilingual = 0; # setting the global variable $ismultilingual ! 135 if ( $languagestring =~ /\,/ ) { $installer::globals::ismultilingual = 1; } 136 137 while ( $last =~ /^\s*(.+?)\,(.+)\s*$/) # "$" for minimal matching, comma separated list 138 { 139 my $first = $1; 140 $last = $2; 141 installer::remover::remove_leading_and_ending_whitespaces(\$first); 142 push(@languagearray, "$first"); 143 } 144 145 installer::remover::remove_leading_and_ending_whitespaces(\$last); 146 push(@languagearray, "$last"); 147 148 if ( $installer::globals::iswindowsbuild ) 149 { 150 my $furthercheck = 1; 151 152 # For some languages (that are not supported by Windows, english needs to be added to the installation set 153 # Languages saved in "@installer::globals::noMSLocaleLangs" 154 155 if ( all_elements_of_array1_in_array2(\@languagearray, \@installer::globals::noMSLocaleLangs) ) 156 { 157 my $officestartlanguage = $languagearray[0]; 158 unshift(@languagearray, "en-US"); # am Anfang einf�gen! 159 $installer::globals::ismultilingual = 1; 160 $installer::globals::added_english = 1; 161 $installer::globals::set_office_start_language = 1; 162 # setting the variable PRODUCTLANGUAGE, needed for Linguistic-ForceDefaultLanguage.xcu 163 $allvariables->{'PRODUCTLANGUAGE'} = $officestartlanguage; 164 $furthercheck = 0; 165 } 166 167 # In bilingual installation sets, in which english is the first language, 168 # the Office start language shall be the second language. 169 170 if ( $furthercheck ) 171 { 172 if (( $#languagearray == 1 ) && ( $languagearray[0] eq "en-US" )) 173 { 174 my $officestartlanguage = $languagearray[1]; 175 $installer::globals::set_office_start_language = 1; 176 # setting the variable PRODUCTLANGUAGE, needed for Linguistic-ForceDefaultLanguage.xcu 177 $allvariables->{'PRODUCTLANGUAGE'} = $officestartlanguage; 178 } 179 } 180 } 181 182 return \@languagearray; 183} 184 185#################################################################################### 186# FAKE: The languages string may contain only "de", "en-US", instead of "01", ... 187# But this has to be removed as soon as possible. 188# In the future the languages are determined with "en-US" instead "01" 189# already on the command line and in the zip list file. 190#################################################################################### 191 192sub fake_languagesstring 193{ 194 my ($stringref) = @_; 195 196 # ATTENTION: This function has to be removed as soon as possible! 197 198 $$stringref =~ s/01/en-US/; 199 $$stringref =~ s/03/pt/; 200 $$stringref =~ s/07/ru/; 201 $$stringref =~ s/30/el/; 202 $$stringref =~ s/31/nl/; 203 $$stringref =~ s/33/fr/; 204 $$stringref =~ s/34/es/; 205 $$stringref =~ s/35/fi/; 206 $$stringref =~ s/36/hu/; 207 $$stringref =~ s/37/ca/; 208 $$stringref =~ s/39/it/; 209 $$stringref =~ s/42/cs/; 210 $$stringref =~ s/43/sk/; 211 $$stringref =~ s/44/en-GB/; 212 $$stringref =~ s/45/da/; 213 $$stringref =~ s/46/sv/; 214 $$stringref =~ s/47/no/; 215 $$stringref =~ s/48/pl/; 216 $$stringref =~ s/49/de/; 217 $$stringref =~ s/55/pt-BR/; 218 $$stringref =~ s/66/th/; 219 $$stringref =~ s/77/et/; 220 $$stringref =~ s/81/ja/; 221 $$stringref =~ s/82/ko/; 222 $$stringref =~ s/86/zh-CN/; 223 $$stringref =~ s/88/zh-TW/; 224 $$stringref =~ s/90/tr/; 225 $$stringref =~ s/91/hi-IN/; 226 $$stringref =~ s/96/ar/; 227 $$stringref =~ s/97/he/; 228} 229 230########################################################## 231# Converting the language array into a string for output 232########################################################## 233 234sub get_language_string 235{ 236 my ($languagesref) = @_; 237 238 my $newstring = ""; 239 240 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) 241 { 242 $newstring = $newstring . ${$languagesref}[$i] . "_"; 243 } 244 245 # remove ending underline 246 247 $newstring =~ s/\_\s*$//; 248 249 return \$newstring; 250} 251 252########################################################## 253# Analyzing the languages in the languages array and 254# returning the most important language 255########################################################## 256 257sub get_default_language 258{ 259 my ($languagesref) = @_; 260 261 return ${$languagesref}[0]; # ToDo, only returning the first language 262} 263 264############################################################# 265# Contains the installation set one of the asian languages? 266############################################################# 267 268sub detect_asian_language 269{ 270 my ($languagesref) = @_; 271 272 my $containsasia = 0; 273 274 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) 275 { 276 my $onelang = ${$languagesref}[$i]; 277 $onelang =~ s/\s*$//; 278 279 for ( my $j = 0; $j <= $#installer::globals::asianlanguages; $j++ ) 280 { 281 my $asialang = $installer::globals::asianlanguages[$j]; 282 $asialang =~ s/\s*$//; 283 284 if ( $onelang eq $asialang ) 285 { 286 $containsasia = 1; 287 last; 288 } 289 } 290 291 if ( $containsasia ) { last; } 292 } 293 294 return $containsasia; 295} 296 297############################################################# 298# Contains the installation set only asian languages? 299############################################################# 300 301sub contains_only_asian_languages 302{ 303 my ($languagesref) = @_; 304 305 my $onlyasian = 1; 306 307 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) 308 { 309 my $onelang = ${$languagesref}[$i]; 310 $onelang =~ s/\s*$//; 311 312 if (! installer::existence::exists_in_array($onelang, \@installer::globals::asianlanguages)) 313 { 314 $onlyasian = 0; 315 last; 316 } 317 } 318 319 return $onlyasian; 320} 321 322################################################################ 323# Contains the installation set one of the western languages 324################################################################ 325 326sub detect_western_language 327{ 328 my ($languagesref) = @_; 329 330 my $containswestern = 1; 331 332 if ( contains_only_asian_languages($languagesref) ) { $containswestern = 0; } 333 334 return $containswestern; 335} 336 337################################################################ 338# Determining the language used by the Java installer 339################################################################ 340 341sub get_java_language 342{ 343 my ( $language ) = @_; 344 345 # my $javalanguage = ""; 346 347 # if ( $language eq "en-US" ) { $javalanguage = "en_US"; } 348 # elsif ( $language eq "ar" ) { $javalanguage = "ar_AR"; } 349 # elsif ( $language eq "bg" ) { $javalanguage = "bg_BG"; } 350 # elsif ( $language eq "ca" ) { $javalanguage = "ca_CA"; } 351 # elsif ( $language eq "cs" ) { $javalanguage = "cs_CS"; } 352 # elsif ( $language eq "da" ) { $javalanguage = "da_DA"; } 353 # elsif ( $language eq "de" ) { $javalanguage = "de"; } 354 # elsif ( $language eq "de" ) { $javalanguage = "de_DE"; } 355 # elsif ( $language eq "et" ) { $javalanguage = "et_ET"; } 356 # elsif ( $language eq "el" ) { $javalanguage = "el_EL"; } 357 # elsif ( $language eq "fi" ) { $javalanguage = "fi_FI"; } 358 # elsif ( $language eq "fr" ) { $javalanguage = "fr_FR"; } 359 # elsif ( $language eq "hu" ) { $javalanguage = "hu_HU"; } 360 # elsif ( $language eq "he" ) { $javalanguage = "he_HE"; } 361 # elsif ( $language eq "it" ) { $javalanguage = "it_IT"; } 362 # elsif ( $language eq "nl" ) { $javalanguage = "nl_NL"; } 363 # elsif ( $language eq "es" ) { $javalanguage = "es_ES"; } 364 # elsif ( $language eq "sv" ) { $javalanguage = "sv_SV"; } 365 # elsif ( $language eq "sk" ) { $javalanguage = "sk_SK"; } 366 # elsif ( $language eq "pl" ) { $javalanguage = "pl_PL"; } 367 # elsif ( $language eq "pt-BR" ) { $javalanguage = "pt_BR"; } 368 # elsif ( $language eq "ru" ) { $javalanguage = "ru_RU"; } 369 # elsif ( $language eq "tr" ) { $javalanguage = "tr_TR"; } 370 # elsif ( $language eq "ja" ) { $javalanguage = "ja"; } 371 # elsif ( $language eq "ja" ) { $javalanguage = "ja_JP"; } 372 # elsif ( $language eq "ko" ) { $javalanguage = "ko_KR"; } 373 # elsif ( $language eq "th" ) { $javalanguage = "th_TH"; } 374 # elsif ( $language eq "zh-CN" ) { $javalanguage = "zh_CN"; } 375 # elsif ( $language eq "zh-TW" ) { $javalanguage = "zh_TW"; } 376 377 # languages not defined yet 378 # if ( $javalanguage eq "" ) 379 # { 380 # $javalanguage = $language; 381 # $javalanguage =~ s/\-/\_/; 382 # } 383 384 $javalanguage = $language; 385 $javalanguage =~ s/\-/\_/; 386 387 return $javalanguage; 388} 389 3901; 391