2 eval 'exec perl -S $0 ${1+"$@"}'
4 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License or as specified alternatively below. You may obtain a copy of
9 # the License at http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Initial Developer of the Original Code is
17 # Andras Timar <atimar@suse.com>
18 # Portions created by the Initial Developer are Copyright (C) 2011 the
19 # Initial Developer. All Rights Reserved.
21 # Major Contributor(s):
23 # For minor contributions see the git repository.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 3 or later (the "GPLv3+"), or
27 # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
28 # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
29 # instead of those above.
31 # merges strings from SDF file to properties files
38 getopts("i:m:", \%options);
40 my %translations = ();
42 # ( leftpart ) ( rightpart )
43 # prj file dummy type gid lid helpid pform width lang text helptext qhelptext title
44 my $sdf_regex = "((([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t])*\t([^\t]*)\t([^\t]*))\t([^\t]*)\t(([^\t]*)\t([^\t]*)\t([^\t]*)\t([^\t]*)))";
46 open (SDFFILE, "<$options{m}") || die "propmerge: cannot open sdf file: $options{m}";
51 my $gid = defined $7 ? $7 : '';
52 my $lang = defined $12 ? $12 : '';
53 my $text = defined $14 ? $14 : '';
54 my $key = $lang . $gid;
55 $languages{$lang} = 1;
57 $text =~ s/([^\x{20}-\x{7E}])/sprintf("\\u%04X",ord($1))/ge;
58 $translations{$key} = $text;
64 foreach my $lang (keys %languages) {
65 my $locfilename = $options{i};
67 $locfilename =~ s/en_US\.properties/$lang.properties/;
69 open (INFILE, "<$options{i}") || die "propmerge: cannot open source file: $options{i}";
70 open (OUTFILE, ">$locfilename") || die "propmerge: cannot open output file: $locfilename";
74 my ($id, $value) = split /=/;
75 $id =~ s/^\s+//; #remove leading spaces
76 $id =~ s/\s+$//; #remove trailing spaces
77 my $key = $lang . $id;
78 print OUTFILE "$id=$translations{$key}\n";