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 language 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
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 ) = @_;
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 # All languages defined for one product
81 #############################################
83 sub get_all_languages_for_one_product
85 my ( $languagestring, $allvariables ) = @_;
87 my @languagearray = ();
89 my $last = $languagestring;
91 $installer::globals
::ismultilingual
= 0; # setting the global variable $ismultilingual !
92 if ( $languagestring =~ /\,/ ) { $installer::globals
::ismultilingual
= 1; }
94 while ( $last =~ /^\s*(.+?)\,(.+)\s*$/) # "$" for minimal matching, comma separated list
98 installer
::remover
::remove_leading_and_ending_whitespaces
(\
$first);
99 push(@languagearray, "$first");
102 installer
::remover
::remove_leading_and_ending_whitespaces
(\
$last);
103 push(@languagearray, "$last");
105 return \
@languagearray;
108 ##########################################################
109 # Converting the language array into a string for output
110 ##########################################################
112 sub get_language_string
114 my ($languagesref) = @_;
118 for ( my $i = 0; $i <= $#{$languagesref}; $i++ )
120 $newstring = $newstring . ${$languagesref}[$i] . "_";
123 # remove ending underline
125 $newstring =~ s/\_\s*$//;
130 ##########################################################
131 # Analyzing the languages in the languages array and
132 # returning the most important language
133 ##########################################################
135 sub get_default_language
137 my ($languagesref) = @_;
139 return ${$languagesref}[0]; # ToDo, only returning the first language