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