Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / setup_native / source / packinfo / spellchecker_selection.pl
blob31750139743f611e27fd2733cd6d5b6dcae1fdcc
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/.
9 use List::Util qw[max];
11 @ARGV == 0 or die 'Usage: translates from stdin to stdout';
13 my %map = ();
14 my $max = 0;
16 while (<>) {
17 next if /^\s*(#.*)?$/;
18 # Accept combinations of lll-Ssss-CC-vvvvvvvv
19 # XXX NOTE: when changing this also adapt
20 # setup_native/source/win32/customactions/sellang/sellang.cxx
21 # struct InstallLocalized{ char lang[sizeof(...)]; }
22 /^ \s* ([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?(?:-[a-z]{5,8})?) \s* = \s*
23 \"(EMPTY|[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?(?:-[a-z]{5,8})?
24 (?:,[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?(?:-[a-z]{5,8})?)*)\" \s* $/x
25 or die "unexpected input line \"$_\"";
26 my $lang = $1;
27 $lang =~ tr/-/_/;
28 my $dicts = $2;
29 $dicts =~ tr/-/_/;
30 !exists($map{$lang}) or die "duplicate values for $lang";
31 if ($dicts eq 'EMPTY') {
32 @{$map{$lang}} = ();
33 } else {
34 @{$map{$lang}} = split(/,/, $dicts);
36 push(@{$map{$lang}}, ('en')) unless grep($_ eq 'en', @{$map{$lang}});
37 $max = max($max, scalar(@{$map{$lang}}));
40 ++$max;
42 print <<EOF;
43 // generated by setup_native/source/packinfo/spellchecker_selection.pl
45 #ifndef INCLUDED_SETUP_NATIVE_SOURCE_PACKINFO_SPELLCHECKER_SELECTION_HXX
46 #define INCLUDED_SETUP_NATIVE_SOURCE_PACKINFO_SPELLCHECKER_SELECTION_HXX
48 #include "sal/config.h"
50 namespace setup_native {
52 struct LanguageDictionaries {
53 char const * language;
54 char const * dictionaries[$max];
57 LanguageDictionaries const languageDictionaries[] = {
58 EOF
60 foreach $i (sort(keys(%map))) {
61 print(" { \"$i\", {");
62 foreach $j (sort(@{$map{$i}})) {
63 print(" \"$j\",");
65 print(" 0 } },\n");
68 print <<EOF;
73 #endif
74 EOF