bump product version to 4.1.6.2
[LibreOffice.git] / solenv / bin / modules / installer / languages.pm
blobaf2be54e196bf3ab89e178148972d54d20b0549f
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 .
19 package installer::languages;
21 use installer::converter;
22 use installer::exiter;
23 use installer::globals;
24 use installer::remover;
25 use installer::ziplist;
27 #############################################################################
28 # Analyzing the laguage list parameter and language list from zip list file
29 #############################################################################
31 sub analyze_languagelist
33 my $first = $installer::globals::languagelist;
35 $first =~ s/\_/\,/g; # substituting "_" by ",", in case of dmake definition 01_49
37 # Products are separated by a "#", if defined in zip-list by a "|". But "get_info_about_languages"
38 # substitutes already "|" to "#". This procedure only knows "#" as product separator.
39 # Different languages for one product are separated by ",". But on the command line the "_" is used.
40 # Therefore "_" is replaced by "," at the beginning of this procedure.
42 while ($first =~ /^(\S+)\#(\S+?)$/) # Minimal matching, to keep the order of languages
44 $first = $1;
45 my $last = $2;
46 unshift(@installer::globals::languageproducts, $last);
49 unshift(@installer::globals::languageproducts, $first);
52 ####################################################
53 # Reading languages from zip list file
54 ####################################################
56 sub get_info_about_languages
58 my ( $allsettingsarrayref ) = @_;
60 my $languagelistref;
62 $languagelistref = installer::ziplist::getinfofromziplist($allsettingsarrayref, "languages");
63 $installer::globals::languagelist = $$languagelistref;
65 if ( $installer::globals::languagelist eq "" ) # not defined on command line and not in product list
67 installer::exiter::exit_program("ERROR: Languages not defined on command line (-l) and not in product list!", "get_info_about_languages");
70 # Adapting the separator format from zip list.
71 # | means new product, , (comma) means more than one language in one product
72 # On the command line, | is difficult to use. Therefore this script uses hashes
74 $installer::globals::languagelist =~ s/\|/\#/g;
76 analyze_languagelist();
79 #############################################################################
80 # Checking whether all elements of an array A are also member of array B
81 #############################################################################
83 sub all_elements_of_array1_in_array2
85 my ($array1, $array2) = @_;
87 my $array2_contains_all_elements_of_array1 = 1;
89 for ( my $i = 0; $i <= $#{$array1}; $i++ )
91 if (! grep {$_ eq ${$array1}[$i]} @{$array2})
93 $array2_contains_all_elements_of_array1 = 0;
94 last;
98 return $array2_contains_all_elements_of_array1;
101 #############################################
102 # All languages defined for one product
103 #############################################
105 sub get_all_languages_for_one_product
107 my ( $languagestring, $allvariables ) = @_;
109 my @languagearray = ();
111 my $last = $languagestring;
113 $installer::globals::ismultilingual = 0; # setting the global variable $ismultilingual !
114 if ( $languagestring =~ /\,/ ) { $installer::globals::ismultilingual = 1; }
116 while ( $last =~ /^\s*(.+?)\,(.+)\s*$/) # "$" for minimal matching, comma separated list
118 my $first = $1;
119 $last = $2;
120 installer::remover::remove_leading_and_ending_whitespaces(\$first);
121 push(@languagearray, "$first");
124 installer::remover::remove_leading_and_ending_whitespaces(\$last);
125 push(@languagearray, "$last");
127 return \@languagearray;
130 ##########################################################
131 # Converting the language array into a string for output
132 ##########################################################
134 sub get_language_string
136 my ($languagesref) = @_;
138 my $newstring = "";
140 for ( my $i = 0; $i <= $#{$languagesref}; $i++ )
142 $newstring = $newstring . ${$languagesref}[$i] . "_";
145 # remove ending underline
147 $newstring =~ s/\_\s*$//;
149 return \$newstring;
152 ##########################################################
153 # Analyzing the languages in the languages array and
154 # returning the most important language
155 ##########################################################
157 sub get_default_language
159 my ($languagesref) = @_;
161 return ${$languagesref}[0]; # ToDo, only returning the first language