languages.pm (01a01bd6) languages.pm (852d2129)
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

--- 15 unchanged lines hidden (view full) ---

24package installer::languages;
25
26use installer::converter;
27use installer::existence;
28use installer::exiter;
29use installer::globals;
30use installer::remover;
31use installer::ziplist;
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

--- 15 unchanged lines hidden (view full) ---

24package installer::languages;
25
26use installer::converter;
27use installer::existence;
28use installer::exiter;
29use installer::globals;
30use installer::remover;
31use installer::ziplist;
32use Digest::MD5;
32
33
34use strict;
35
36
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

--- 24 unchanged lines hidden (view full) ---

65 }
66
67 $installer::globals::languageproduct = $languageproduct;
68}
69
70
71
72
37=head2 analyze_languagelist()
38
39 Convert $installer::globals::languagelist into $installer::globals::languageproduct.
40
41 That is now just a replacement of '_' with ','.
42
43 $installer::globals::languageproduct (specified by the -l option
44 on the command line) can contain multiple languages separated by

--- 24 unchanged lines hidden (view full) ---

69 }
70
71 $installer::globals::languageproduct = $languageproduct;
72}
73
74
75
76
77=head2 get_language_directory_name ($language_string)
78
79 Create a directory name that contains the given set of languages.
80 When $language_string exceeds a certain length then it is shortened.
81
82=cut
83sub get_language_directory_name ($)
84{
85 my ($language_string) = @_;
86
87 if (length($language_string) > $installer::globals::max_lang_length)
88 {
89 my $number_of_languages = ($language_string =~ tr/_//);
90 my $digest = new Digest::MD5();
91 $digest->add($language_string);
92 my $short_digest = substr($digest->hexdigest(), 0, 8);
93 return "lang_" . $number_of_languages . "_id_" . $short_digest;
94 }
95 else
96 {
97 return $language_string;
98 }
99}
100
101
102
103
73####################################################
74# Reading languages from zip list file
75####################################################
76
77sub get_info_about_languages
78{
79 my ( $allsettingsarrayref ) = @_;
80

--- 36 unchanged lines hidden (view full) ---

117 }
118
119 return $array2_contains_all_elements_of_array1;
120}
121
122#############################################
123# All languages defined for one product
124#############################################
104####################################################
105# Reading languages from zip list file
106####################################################
107
108sub get_info_about_languages
109{
110 my ( $allsettingsarrayref ) = @_;
111

--- 36 unchanged lines hidden (view full) ---

148 }
149
150 return $array2_contains_all_elements_of_array1;
151}
152
153#############################################
154# All languages defined for one product
155#############################################
125
126sub get_all_languages_for_one_product
156
157=head2 get_all_languages_for_one_product($languagestring, $allvariables)
158
159 $languagestring can be one or more language names, separated by ','.
160
161 $installer::globals::ismultilingual is set to 1 when $languagestring contains more than one languages.
162
163=cut
164sub get_all_languages_for_one_product ($$)
127{
128 my ( $languagestring, $allvariables ) = @_;
129
165{
166 my ( $languagestring, $allvariables ) = @_;
167
130 my @languagearray = ();
131
168
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 }
169 $installer::globals::ismultilingual = ($languagestring =~ /\,/ ) ? 1 : 0;
144
170
145 installer::remover::remove_leading_and_ending_whitespaces(\$last);
146 push(@languagearray, "$last");
171 my $languages = $languagestring;
172 $languages =~ s/\s+//g;
173 my @languagearray = split(/,/, $languages);
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

--- 221 unchanged lines hidden (view full) ---

376
377 # languages not defined yet
378 # if ( $javalanguage eq "" )
379 # {
380 # $javalanguage = $language;
381 # $javalanguage =~ s/\-/\_/;
382 # }
383
174
175 if ( $installer::globals::iswindowsbuild )
176 {
177 my $furthercheck = 1;
178
179 # For some languages (that are not supported by Windows, english needs to be added to the installation set
180 # Languages saved in "@installer::globals::noMSLocaleLangs"
181

--- 221 unchanged lines hidden (view full) ---

403
404 # languages not defined yet
405 # if ( $javalanguage eq "" )
406 # {
407 # $javalanguage = $language;
408 # $javalanguage =~ s/\-/\_/;
409 # }
410
384 $javalanguage = $language;
411 my $javalanguage = $language;
385 $javalanguage =~ s/\-/\_/;
386
387 return $javalanguage;
388}
389
412 $javalanguage =~ s/\-/\_/;
413
414 return $javalanguage;
415}
416
417
418
419=head2 get_key_language ($languages)
420
421 Determine the key language from the array of @$languages.
422
423 If there is only one language then that is the key language.
424
425 If there are two languages and one is en-US and was automatically
426 added, then the other language is the key language.
427
428 When there is more than one language and the case above does not
429 apply then return either 'multiasia' or 'multiwestern' as key
430 language, depending on whether one of the asian language parts
431 'jp', 'ko', 'zh' appear.
432
433=cut
434sub get_key_language ($)
435{
436 my ($languages) = @_;
437
438 my $language_count = scalar @$languages;
439
440 if ($language_count == 1)
441 {
442 return $languages->[0];
443 }
444 else
445 {
446 if ($installer::globals::added_english && $language_count==1)
447 {
448 # Only multilingual because of added English.
449 return $languages->[1];
450 }
451 else
452 {
453 if ($languages->[1] =~ /(jp|ko|zh)/)
454 {
455 return "multiasia";
456 }
457 else
458 {
459 return "multiwestern";
460 }
461 }
462 }
463}
464
3901;
4651;