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 # extracts strings from Java properties files
40 getopts("ep:r:i:o:l:", \%options);
42 unless ( $options{i} =~ m/en_US/ ) {exit 0;}
44 $options{i} =~ s|\\|/|g; # fix path on Windows, Perl expects / separator
45 my ($unused1, $dir, $unused2) = File::Basename::fileparse($options{i});
46 my $file = substr ( Cwd::abs_path($options{i}), length(Cwd::abs_path($dir . $options{r})) + 1 );
49 open (INFILE, "<$options{i}") || die "propex: cannot open input file: $options{i}";
50 open (OUTFILE, ">$options{o}") || die "propex: cannot open output file: $options{o}";
55 my ($id, $value) = split /=/;
56 $id =~ s/^\s+//; #remove leading spaces
57 $id =~ s/\s+$//; #remove trailing spaces
58 $value =~ s/^\s+//; #remove leading spaces
59 $value =~ s/\s+$//; #remove trailing spaces
60 $value =~ s/(\\u([0-9a-fA-F]{4}))/pack("C0U1",hex($2))/ge; #convert ascii escaped unicode to utf-8
61 print OUTFILE "$options{p}\t$file\t0\tproperty\t$id\t\t\t\t0\ten-US\t$value\t\t\t\t20020202 02:02:02\n";