19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::languages; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::converter; 27cdf0e10cSrcweiruse installer::existence; 28cdf0e10cSrcweiruse installer::exiter; 29cdf0e10cSrcweiruse installer::globals; 30cdf0e10cSrcweiruse installer::remover; 31cdf0e10cSrcweiruse installer::ziplist; 32852d2129SAndre Fischeruse Digest::MD5; 33852d2129SAndre Fischer 34852d2129SAndre Fischeruse strict; 35852d2129SAndre Fischer 36cdf0e10cSrcweir 3701a01bd6SAndre Fischer=head2 analyze_languagelist() 3801a01bd6SAndre Fischer 3901a01bd6SAndre Fischer Convert $installer::globals::languagelist into $installer::globals::languageproduct. 4001a01bd6SAndre Fischer 4101a01bd6SAndre Fischer That is now just a replacement of '_' with ','. 4201a01bd6SAndre Fischer 4301a01bd6SAndre Fischer $installer::globals::languageproduct (specified by the -l option 4401a01bd6SAndre Fischer on the command line) can contain multiple languages separated by 4501a01bd6SAndre Fischer '_' to specify multilingual builds. 4601a01bd6SAndre Fischer 4701a01bd6SAndre Fischer Separation by '#' to build multiple languages (single or 4801a01bd6SAndre Fischer multilingual) in one make_installer.pl run is not supported 4901a01bd6SAndre Fischer anymore. Call make_installer.pl with all languages separately instead: 5001a01bd6SAndre Fischer make_installer.pl -l L1#L2 5101a01bd6SAndre Fischer -> 5201a01bd6SAndre Fischer make_installer.pl -l L1 5301a01bd6SAndre Fischer make_installer.pl -l L2 5401a01bd6SAndre Fischer 5501a01bd6SAndre Fischer=cut 5601a01bd6SAndre Fischersub analyze_languagelist() 5701a01bd6SAndre Fischer{ 5801a01bd6SAndre Fischer my $languageproduct = $installer::globals::languagelist; 5901a01bd6SAndre Fischer 6001a01bd6SAndre Fischer $languageproduct =~ s/\_/\,/g; # substituting "_" by ",", in case of dmake definition 01_49 6101a01bd6SAndre Fischer 6201a01bd6SAndre Fischer if ($languageproduct =~ /\#/) 6301a01bd6SAndre Fischer { 6401a01bd6SAndre Fischer installer::exiter::exit_program( 6501a01bd6SAndre Fischer "building more than one language (or language set) is not supported anymore\n" 6601a01bd6SAndre Fischer ."please replace one call of 'make_installer.pl -l language1#language2'\n" 6701a01bd6SAndre Fischer ."with two calls 'make_installer.pl -l language1' and 'make_installer.pl -l language2'", 6801a01bd6SAndre Fischer "installer::language::analyze_languagelist"); 6901a01bd6SAndre Fischer } 7001a01bd6SAndre Fischer 7101a01bd6SAndre Fischer $installer::globals::languageproduct = $languageproduct; 72cdf0e10cSrcweir} 73cdf0e10cSrcweir 7401a01bd6SAndre Fischer 7501a01bd6SAndre Fischer 7601a01bd6SAndre Fischer 77852d2129SAndre Fischer=head2 get_language_directory_name ($language_string) 78852d2129SAndre Fischer 79852d2129SAndre Fischer Create a directory name that contains the given set of languages. 80852d2129SAndre Fischer When $language_string exceeds a certain length then it is shortened. 81852d2129SAndre Fischer 82852d2129SAndre Fischer=cut 83852d2129SAndre Fischersub get_language_directory_name ($) 84852d2129SAndre Fischer{ 85852d2129SAndre Fischer my ($language_string) = @_; 86852d2129SAndre Fischer 87852d2129SAndre Fischer if (length($language_string) > $installer::globals::max_lang_length) 88852d2129SAndre Fischer { 89852d2129SAndre Fischer my $number_of_languages = ($language_string =~ tr/_//); 90852d2129SAndre Fischer my $digest = new Digest::MD5(); 91852d2129SAndre Fischer $digest->add($language_string); 92852d2129SAndre Fischer my $short_digest = substr($digest->hexdigest(), 0, 8); 93852d2129SAndre Fischer return "lang_" . $number_of_languages . "_id_" . $short_digest; 94852d2129SAndre Fischer } 95852d2129SAndre Fischer else 96852d2129SAndre Fischer { 97852d2129SAndre Fischer return $language_string; 98852d2129SAndre Fischer } 99852d2129SAndre Fischer} 100852d2129SAndre Fischer 101852d2129SAndre Fischer 102852d2129SAndre Fischer 103852d2129SAndre Fischer 104cdf0e10cSrcweir#################################################### 105cdf0e10cSrcweir# Reading languages from zip list file 106cdf0e10cSrcweir#################################################### 107cdf0e10cSrcweir 108cdf0e10cSrcweirsub get_info_about_languages 109cdf0e10cSrcweir{ 110cdf0e10cSrcweir my ( $allsettingsarrayref ) = @_; 111cdf0e10cSrcweir 112cdf0e10cSrcweir my $languagelistref; 113cdf0e10cSrcweir 114cdf0e10cSrcweir $languagelistref = installer::ziplist::getinfofromziplist($allsettingsarrayref, "languages"); 115cdf0e10cSrcweir $installer::globals::languagelist = $$languagelistref; 116cdf0e10cSrcweir 117cdf0e10cSrcweir if ( $installer::globals::languagelist eq "" ) # not defined on command line and not in product list 118cdf0e10cSrcweir { 119cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Languages not defined on command line (-l) and not in product list!", "get_info_about_languages"); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir # Adapting the separator format from zip list. 123cdf0e10cSrcweir # | means new product, , (comma) means more than one language in one product 124cdf0e10cSrcweir # On the command line, | is difficult to use. Therefore this script uses hashes 125cdf0e10cSrcweir 126cdf0e10cSrcweir $installer::globals::languagelist =~ s/\|/\#/g; 127cdf0e10cSrcweir 128cdf0e10cSrcweir analyze_languagelist(); 129cdf0e10cSrcweir} 130cdf0e10cSrcweir 131cdf0e10cSrcweir############################################################################# 132cdf0e10cSrcweir# Checking whether all elements of an array A are also member of array B 133cdf0e10cSrcweir############################################################################# 134cdf0e10cSrcweir 135cdf0e10cSrcweirsub all_elements_of_array1_in_array2 136cdf0e10cSrcweir{ 137cdf0e10cSrcweir my ($array1, $array2) = @_; 138cdf0e10cSrcweir 139cdf0e10cSrcweir my $array2_contains_all_elements_of_array1 = 1; 140cdf0e10cSrcweir 141cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$array1}; $i++ ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir if (! installer::existence::exists_in_array(${$array1}[$i], $array2)) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir $array2_contains_all_elements_of_array1 = 0; 146cdf0e10cSrcweir last; 147cdf0e10cSrcweir } 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir return $array2_contains_all_elements_of_array1; 151cdf0e10cSrcweir} 152cdf0e10cSrcweir 153cdf0e10cSrcweir############################################# 154cdf0e10cSrcweir# All languages defined for one product 155cdf0e10cSrcweir############################################# 156852d2129SAndre Fischer 157852d2129SAndre Fischer=head2 get_all_languages_for_one_product($languagestring, $allvariables) 158852d2129SAndre Fischer 159852d2129SAndre Fischer $languagestring can be one or more language names, separated by ','. 160852d2129SAndre Fischer 161852d2129SAndre Fischer $installer::globals::ismultilingual is set to 1 when $languagestring contains more than one languages. 162852d2129SAndre Fischer 163852d2129SAndre Fischer=cut 164852d2129SAndre Fischersub get_all_languages_for_one_product ($$) 165cdf0e10cSrcweir{ 166cdf0e10cSrcweir my ( $languagestring, $allvariables ) = @_; 167cdf0e10cSrcweir 168cdf0e10cSrcweir 169852d2129SAndre Fischer $installer::globals::ismultilingual = ($languagestring =~ /\,/ ) ? 1 : 0; 170cdf0e10cSrcweir 171852d2129SAndre Fischer my $languages = $languagestring; 172852d2129SAndre Fischer $languages =~ s/\s+//g; 173852d2129SAndre Fischer my @languagearray = split(/,/, $languages); 174cdf0e10cSrcweir 175cdf0e10cSrcweir if ( $installer::globals::iswindowsbuild ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir my $furthercheck = 1; 178cdf0e10cSrcweir 179cdf0e10cSrcweir # For some languages (that are not supported by Windows, english needs to be added to the installation set 180cdf0e10cSrcweir # Languages saved in "@installer::globals::noMSLocaleLangs" 181cdf0e10cSrcweir 182cdf0e10cSrcweir if ( all_elements_of_array1_in_array2(\@languagearray, \@installer::globals::noMSLocaleLangs) ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir my $officestartlanguage = $languagearray[0]; 185cdf0e10cSrcweir unshift(@languagearray, "en-US"); # am Anfang einf�gen! 186cdf0e10cSrcweir $installer::globals::ismultilingual = 1; 187cdf0e10cSrcweir $installer::globals::added_english = 1; 188cdf0e10cSrcweir $installer::globals::set_office_start_language = 1; 189cdf0e10cSrcweir # setting the variable PRODUCTLANGUAGE, needed for Linguistic-ForceDefaultLanguage.xcu 190cdf0e10cSrcweir $allvariables->{'PRODUCTLANGUAGE'} = $officestartlanguage; 191cdf0e10cSrcweir $furthercheck = 0; 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir # In bilingual installation sets, in which english is the first language, 195cdf0e10cSrcweir # the Office start language shall be the second language. 196cdf0e10cSrcweir 197cdf0e10cSrcweir if ( $furthercheck ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir if (( $#languagearray == 1 ) && ( $languagearray[0] eq "en-US" )) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir my $officestartlanguage = $languagearray[1]; 202cdf0e10cSrcweir $installer::globals::set_office_start_language = 1; 203cdf0e10cSrcweir # setting the variable PRODUCTLANGUAGE, needed for Linguistic-ForceDefaultLanguage.xcu 204cdf0e10cSrcweir $allvariables->{'PRODUCTLANGUAGE'} = $officestartlanguage; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir } 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir return \@languagearray; 210cdf0e10cSrcweir} 211cdf0e10cSrcweir 212cdf0e10cSrcweir#################################################################################### 213cdf0e10cSrcweir# FAKE: The languages string may contain only "de", "en-US", instead of "01", ... 214cdf0e10cSrcweir# But this has to be removed as soon as possible. 215cdf0e10cSrcweir# In the future the languages are determined with "en-US" instead "01" 216cdf0e10cSrcweir# already on the command line and in the zip list file. 217cdf0e10cSrcweir#################################################################################### 218cdf0e10cSrcweir 219cdf0e10cSrcweirsub fake_languagesstring 220cdf0e10cSrcweir{ 221cdf0e10cSrcweir my ($stringref) = @_; 222cdf0e10cSrcweir 223cdf0e10cSrcweir # ATTENTION: This function has to be removed as soon as possible! 224cdf0e10cSrcweir 225cdf0e10cSrcweir $$stringref =~ s/01/en-US/; 226cdf0e10cSrcweir $$stringref =~ s/03/pt/; 227cdf0e10cSrcweir $$stringref =~ s/07/ru/; 228cdf0e10cSrcweir $$stringref =~ s/30/el/; 229cdf0e10cSrcweir $$stringref =~ s/31/nl/; 230cdf0e10cSrcweir $$stringref =~ s/33/fr/; 231cdf0e10cSrcweir $$stringref =~ s/34/es/; 232cdf0e10cSrcweir $$stringref =~ s/35/fi/; 233cdf0e10cSrcweir $$stringref =~ s/36/hu/; 234cdf0e10cSrcweir $$stringref =~ s/37/ca/; 235cdf0e10cSrcweir $$stringref =~ s/39/it/; 236cdf0e10cSrcweir $$stringref =~ s/42/cs/; 237cdf0e10cSrcweir $$stringref =~ s/43/sk/; 238cdf0e10cSrcweir $$stringref =~ s/44/en-GB/; 239cdf0e10cSrcweir $$stringref =~ s/45/da/; 240cdf0e10cSrcweir $$stringref =~ s/46/sv/; 241cdf0e10cSrcweir $$stringref =~ s/47/no/; 242cdf0e10cSrcweir $$stringref =~ s/48/pl/; 243cdf0e10cSrcweir $$stringref =~ s/49/de/; 244cdf0e10cSrcweir $$stringref =~ s/55/pt-BR/; 245cdf0e10cSrcweir $$stringref =~ s/66/th/; 246cdf0e10cSrcweir $$stringref =~ s/77/et/; 247cdf0e10cSrcweir $$stringref =~ s/81/ja/; 248cdf0e10cSrcweir $$stringref =~ s/82/ko/; 249cdf0e10cSrcweir $$stringref =~ s/86/zh-CN/; 250cdf0e10cSrcweir $$stringref =~ s/88/zh-TW/; 251cdf0e10cSrcweir $$stringref =~ s/90/tr/; 252cdf0e10cSrcweir $$stringref =~ s/91/hi-IN/; 253cdf0e10cSrcweir $$stringref =~ s/96/ar/; 254cdf0e10cSrcweir $$stringref =~ s/97/he/; 255cdf0e10cSrcweir} 256cdf0e10cSrcweir 257cdf0e10cSrcweir########################################################## 258cdf0e10cSrcweir# Converting the language array into a string for output 259cdf0e10cSrcweir########################################################## 260cdf0e10cSrcweir 261cdf0e10cSrcweirsub get_language_string 262cdf0e10cSrcweir{ 263cdf0e10cSrcweir my ($languagesref) = @_; 264cdf0e10cSrcweir 265cdf0e10cSrcweir my $newstring = ""; 266cdf0e10cSrcweir 267cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir $newstring = $newstring . ${$languagesref}[$i] . "_"; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir # remove ending underline 273cdf0e10cSrcweir 274cdf0e10cSrcweir $newstring =~ s/\_\s*$//; 275cdf0e10cSrcweir 276cdf0e10cSrcweir return \$newstring; 277cdf0e10cSrcweir} 278cdf0e10cSrcweir 279cdf0e10cSrcweir########################################################## 280cdf0e10cSrcweir# Analyzing the languages in the languages array and 281cdf0e10cSrcweir# returning the most important language 282cdf0e10cSrcweir########################################################## 283cdf0e10cSrcweir 284cdf0e10cSrcweirsub get_default_language 285cdf0e10cSrcweir{ 286cdf0e10cSrcweir my ($languagesref) = @_; 287cdf0e10cSrcweir 288cdf0e10cSrcweir return ${$languagesref}[0]; # ToDo, only returning the first language 289cdf0e10cSrcweir} 290cdf0e10cSrcweir 291cdf0e10cSrcweir############################################################# 292cdf0e10cSrcweir# Contains the installation set one of the asian languages? 293cdf0e10cSrcweir############################################################# 294cdf0e10cSrcweir 295cdf0e10cSrcweirsub detect_asian_language 296cdf0e10cSrcweir{ 297cdf0e10cSrcweir my ($languagesref) = @_; 298cdf0e10cSrcweir 299cdf0e10cSrcweir my $containsasia = 0; 300cdf0e10cSrcweir 301cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir my $onelang = ${$languagesref}[$i]; 304cdf0e10cSrcweir $onelang =~ s/\s*$//; 305cdf0e10cSrcweir 306cdf0e10cSrcweir for ( my $j = 0; $j <= $#installer::globals::asianlanguages; $j++ ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir my $asialang = $installer::globals::asianlanguages[$j]; 309cdf0e10cSrcweir $asialang =~ s/\s*$//; 310cdf0e10cSrcweir 311cdf0e10cSrcweir if ( $onelang eq $asialang ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir $containsasia = 1; 314cdf0e10cSrcweir last; 315cdf0e10cSrcweir } 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir if ( $containsasia ) { last; } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir return $containsasia; 322cdf0e10cSrcweir} 323cdf0e10cSrcweir 324cdf0e10cSrcweir############################################################# 325cdf0e10cSrcweir# Contains the installation set only asian languages? 326cdf0e10cSrcweir############################################################# 327cdf0e10cSrcweir 328cdf0e10cSrcweirsub contains_only_asian_languages 329cdf0e10cSrcweir{ 330cdf0e10cSrcweir my ($languagesref) = @_; 331cdf0e10cSrcweir 332cdf0e10cSrcweir my $onlyasian = 1; 333cdf0e10cSrcweir 334cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir my $onelang = ${$languagesref}[$i]; 337cdf0e10cSrcweir $onelang =~ s/\s*$//; 338cdf0e10cSrcweir 339cdf0e10cSrcweir if (! installer::existence::exists_in_array($onelang, \@installer::globals::asianlanguages)) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir $onlyasian = 0; 342cdf0e10cSrcweir last; 343cdf0e10cSrcweir } 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir return $onlyasian; 347cdf0e10cSrcweir} 348cdf0e10cSrcweir 349cdf0e10cSrcweir################################################################ 350cdf0e10cSrcweir# Contains the installation set one of the western languages 351cdf0e10cSrcweir################################################################ 352cdf0e10cSrcweir 353cdf0e10cSrcweirsub detect_western_language 354cdf0e10cSrcweir{ 355cdf0e10cSrcweir my ($languagesref) = @_; 356cdf0e10cSrcweir 357cdf0e10cSrcweir my $containswestern = 1; 358cdf0e10cSrcweir 359cdf0e10cSrcweir if ( contains_only_asian_languages($languagesref) ) { $containswestern = 0; } 360cdf0e10cSrcweir 361cdf0e10cSrcweir return $containswestern; 362cdf0e10cSrcweir} 363cdf0e10cSrcweir 364cdf0e10cSrcweir################################################################ 365cdf0e10cSrcweir# Determining the language used by the Java installer 366cdf0e10cSrcweir################################################################ 367cdf0e10cSrcweir 368cdf0e10cSrcweirsub get_java_language 369cdf0e10cSrcweir{ 370cdf0e10cSrcweir my ( $language ) = @_; 371cdf0e10cSrcweir 372cdf0e10cSrcweir # my $javalanguage = ""; 373cdf0e10cSrcweir 374cdf0e10cSrcweir # if ( $language eq "en-US" ) { $javalanguage = "en_US"; } 375cdf0e10cSrcweir # elsif ( $language eq "ar" ) { $javalanguage = "ar_AR"; } 376cdf0e10cSrcweir # elsif ( $language eq "bg" ) { $javalanguage = "bg_BG"; } 377cdf0e10cSrcweir # elsif ( $language eq "ca" ) { $javalanguage = "ca_CA"; } 378cdf0e10cSrcweir # elsif ( $language eq "cs" ) { $javalanguage = "cs_CS"; } 379cdf0e10cSrcweir # elsif ( $language eq "da" ) { $javalanguage = "da_DA"; } 380cdf0e10cSrcweir # elsif ( $language eq "de" ) { $javalanguage = "de"; } 381cdf0e10cSrcweir # elsif ( $language eq "de" ) { $javalanguage = "de_DE"; } 382cdf0e10cSrcweir # elsif ( $language eq "et" ) { $javalanguage = "et_ET"; } 383cdf0e10cSrcweir # elsif ( $language eq "el" ) { $javalanguage = "el_EL"; } 384cdf0e10cSrcweir # elsif ( $language eq "fi" ) { $javalanguage = "fi_FI"; } 385cdf0e10cSrcweir # elsif ( $language eq "fr" ) { $javalanguage = "fr_FR"; } 386cdf0e10cSrcweir # elsif ( $language eq "hu" ) { $javalanguage = "hu_HU"; } 387cdf0e10cSrcweir # elsif ( $language eq "he" ) { $javalanguage = "he_HE"; } 388cdf0e10cSrcweir # elsif ( $language eq "it" ) { $javalanguage = "it_IT"; } 389cdf0e10cSrcweir # elsif ( $language eq "nl" ) { $javalanguage = "nl_NL"; } 390cdf0e10cSrcweir # elsif ( $language eq "es" ) { $javalanguage = "es_ES"; } 391cdf0e10cSrcweir # elsif ( $language eq "sv" ) { $javalanguage = "sv_SV"; } 392cdf0e10cSrcweir # elsif ( $language eq "sk" ) { $javalanguage = "sk_SK"; } 393cdf0e10cSrcweir # elsif ( $language eq "pl" ) { $javalanguage = "pl_PL"; } 394cdf0e10cSrcweir # elsif ( $language eq "pt-BR" ) { $javalanguage = "pt_BR"; } 395cdf0e10cSrcweir # elsif ( $language eq "ru" ) { $javalanguage = "ru_RU"; } 396cdf0e10cSrcweir # elsif ( $language eq "tr" ) { $javalanguage = "tr_TR"; } 397cdf0e10cSrcweir # elsif ( $language eq "ja" ) { $javalanguage = "ja"; } 398cdf0e10cSrcweir # elsif ( $language eq "ja" ) { $javalanguage = "ja_JP"; } 399cdf0e10cSrcweir # elsif ( $language eq "ko" ) { $javalanguage = "ko_KR"; } 400cdf0e10cSrcweir # elsif ( $language eq "th" ) { $javalanguage = "th_TH"; } 401cdf0e10cSrcweir # elsif ( $language eq "zh-CN" ) { $javalanguage = "zh_CN"; } 402cdf0e10cSrcweir # elsif ( $language eq "zh-TW" ) { $javalanguage = "zh_TW"; } 403cdf0e10cSrcweir 404cdf0e10cSrcweir # languages not defined yet 405cdf0e10cSrcweir # if ( $javalanguage eq "" ) 406cdf0e10cSrcweir # { 407cdf0e10cSrcweir # $javalanguage = $language; 408cdf0e10cSrcweir # $javalanguage =~ s/\-/\_/; 409cdf0e10cSrcweir # } 410cdf0e10cSrcweir 411852d2129SAndre Fischer my $javalanguage = $language; 412cdf0e10cSrcweir $javalanguage =~ s/\-/\_/; 413cdf0e10cSrcweir 414cdf0e10cSrcweir return $javalanguage; 415cdf0e10cSrcweir} 416cdf0e10cSrcweir 417852d2129SAndre Fischer 418852d2129SAndre Fischer 419852d2129SAndre Fischer=head2 get_key_language ($languages) 420852d2129SAndre Fischer 421852d2129SAndre Fischer Determine the key language from the array of @$languages. 422852d2129SAndre Fischer 423852d2129SAndre Fischer If there is only one language then that is the key language. 424852d2129SAndre Fischer 425852d2129SAndre Fischer If there are two languages and one is en-US and was automatically 426852d2129SAndre Fischer added, then the other language is the key language. 427852d2129SAndre Fischer 428852d2129SAndre Fischer When there is more than one language and the case above does not 429852d2129SAndre Fischer apply then return either 'multiasia' or 'multiwestern' as key 430852d2129SAndre Fischer language, depending on whether one of the asian language parts 431852d2129SAndre Fischer 'jp', 'ko', 'zh' appear. 432852d2129SAndre Fischer 433852d2129SAndre Fischer=cut 434852d2129SAndre Fischersub get_key_language ($) 435852d2129SAndre Fischer{ 436852d2129SAndre Fischer my ($languages) = @_; 437852d2129SAndre Fischer 438852d2129SAndre Fischer my $language_count = scalar @$languages; 439852d2129SAndre Fischer 440852d2129SAndre Fischer if ($language_count == 1) 441852d2129SAndre Fischer { 442852d2129SAndre Fischer return $languages->[0]; 443852d2129SAndre Fischer } 444852d2129SAndre Fischer else 445852d2129SAndre Fischer { 446852d2129SAndre Fischer if ($installer::globals::added_english && $language_count==1) 447852d2129SAndre Fischer { 448852d2129SAndre Fischer # Only multilingual because of added English. 449852d2129SAndre Fischer return $languages->[1]; 450852d2129SAndre Fischer } 451852d2129SAndre Fischer else 452852d2129SAndre Fischer { 453852d2129SAndre Fischer if ($languages->[1] =~ /(jp|ko|zh)/) 454852d2129SAndre Fischer { 455852d2129SAndre Fischer return "multiasia"; 456852d2129SAndre Fischer } 457852d2129SAndre Fischer else 458852d2129SAndre Fischer { 459852d2129SAndre Fischer return "multiwestern"; 460852d2129SAndre Fischer } 461852d2129SAndre Fischer } 462852d2129SAndre Fischer } 463852d2129SAndre Fischer} 464852d2129SAndre Fischer 46560b96b8dSAndre Fischer 46660b96b8dSAndre Fischer 46760b96b8dSAndre Fischer 46860b96b8dSAndre Fischer=head2 get_normalized_language ($language) 46960b96b8dSAndre Fischer 47060b96b8dSAndre Fischer Transform "..._<language>" into "<language>". 47160b96b8dSAndre Fischer The ... part, if it exists, is typically en-US. 47260b96b8dSAndre Fischer 47360b96b8dSAndre Fischer If $language does not contain a '_' then $language is returned unmodified. 47460b96b8dSAndre Fischer 47560b96b8dSAndre Fischer=cut 47660b96b8dSAndre Fischersub get_normalized_language ($) 47760b96b8dSAndre Fischer{ 47860b96b8dSAndre Fischer my ($language) = @_; 479*f5a0c083SAndre Fischer 480*f5a0c083SAndre Fischer if (ref($language) eq "ARRAY") 481*f5a0c083SAndre Fischer { 482*f5a0c083SAndre Fischer if (scalar @$language > 1 && $language->[0] eq "en-US") 483*f5a0c083SAndre Fischer { 484*f5a0c083SAndre Fischer return $language->[1]; 485*f5a0c083SAndre Fischer } 486*f5a0c083SAndre Fischer else 487*f5a0c083SAndre Fischer { 488*f5a0c083SAndre Fischer return $language; 489*f5a0c083SAndre Fischer } 490*f5a0c083SAndre Fischer } 491*f5a0c083SAndre Fischer elsif ($language =~ /^.*?_(.*)$/) 49260b96b8dSAndre Fischer { 49360b96b8dSAndre Fischer return $1; 49460b96b8dSAndre Fischer } 49560b96b8dSAndre Fischer else 49660b96b8dSAndre Fischer { 49760b96b8dSAndre Fischer return $language; 49860b96b8dSAndre Fischer } 49960b96b8dSAndre Fischer} 50060b96b8dSAndre Fischer 501cdf0e10cSrcweir1; 502