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
;
24 use installer
::converter
;
25 use installer
::exiter
;
26 use installer
::globals
;
27 use installer
::remover
;
28 use installer
::ziplist
;
30 #############################################################################
31 # Analyzing the language list parameter and language list from zip list file
32 #############################################################################
34 sub analyze_languagelist
36 my $first = $installer::globals
::languagelist
;
38 $first =~ s/\_/\,/g; # substituting "_" by ",", in case of dmake definition 01_49
40 # Products are separated by a "#", if defined in zip-list by a "|". But "get_info_about_languages"
41 # substitutes already "|" to "#". This procedure only knows "#" as product separator.
42 # Different languages for one product are separated by ",". But on the command line the "_" is used.
43 # Therefore "_" is replaced by "," at the beginning of this procedure.
45 while ($first =~ /^(\S+)\#(\S+?)$/) # Minimal matching, to keep the order of languages
49 unshift(@installer::globals
::languageproducts
, $last);
52 unshift(@installer::globals
::languageproducts
, $first);
55 ####################################################
56 # Reading languages from zip list file
57 ####################################################
59 sub get_info_about_languages
61 my ( $allsettingsarrayref ) = @_;
65 $languagelistref = installer
::ziplist
::getinfofromziplist
($allsettingsarrayref, "languages");
66 $installer::globals
::languagelist
= $$languagelistref;
68 if ( $installer::globals
::languagelist
eq "" ) # not defined on command line and not in product list
70 installer
::exiter
::exit_program
("ERROR: Languages not defined on command line (-l) and not in product list!", "get_info_about_languages");
73 # Adapting the separator format from zip list.
74 # | means new product, , (comma) means more than one language in one product
75 # On the command line, | is difficult to use. Therefore this script uses hashes
77 $installer::globals
::languagelist
=~ s/\|/\#/g;
79 analyze_languagelist
();
82 #############################################
83 # All languages defined for one product
84 #############################################
86 sub get_all_languages_for_one_product
88 my ( $languagestring, $allvariables ) = @_;
90 my @languagearray = ();
92 my $last = $languagestring;
94 $installer::globals
::ismultilingual
= 0; # setting the global variable $ismultilingual !
95 if ( $languagestring =~ /\,/ ) { $installer::globals
::ismultilingual
= 1; }
97 while ( $last =~ /^\s*(.+?)\,(.+)\s*$/) # "$" for minimal matching, comma separated list
101 installer
::remover
::remove_leading_and_ending_whitespaces
(\
$first);
102 push(@languagearray, "$first");
105 installer
::remover
::remove_leading_and_ending_whitespaces
(\
$last);
106 push(@languagearray, "$last");
108 return \
@languagearray;
111 ##########################################################
112 # Converting the language array into a string for output
113 ##########################################################
115 sub get_language_string
117 my ($languagesref) = @_;
121 for ( my $i = 0; $i <= $#{$languagesref}; $i++ )
123 $newstring = $newstring . ${$languagesref}[$i] . "_";
126 # remove ending underline
128 $newstring =~ s/\_\s*$//;
133 ##########################################################
134 # Analyzing the languages in the languages array and
135 # returning the most important language
136 ##########################################################
138 sub get_default_language
140 my ($languagesref) = @_;
142 return ${$languagesref}[0]; # ToDo, only returning the first language