2 eval 'exec perl -wS $0 ${1+"$@"}'
5 #*************************************************************************
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9 # Copyright 2000, 2010 Oracle and/or its affiliates.
11 # OpenOffice.org - a multi-platform office productivity suite
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
33 #*********************************************************************
38 my ($prefix, $ext, $key);
39 $productname = "OpenOffice.org";
42 while ($_ = $ARGV[0], /^-/) {
46 $productname = $ARGV[0];
68 unless (open(SOURCE
, $ARGV[0])) {
69 print STDERR
"Can't open $ARGV[0] file: $!\n";
74 # For every section in the specified ulf file there should exist
75 # a template file in $workdir ..
79 if ( "[" eq substr($line, 0, 1) ) {
80 # Pass the tail of the template to the output file
88 system "mv -f $outfile.tmp $outfile\n";
91 $_ = substr($line, 1, index($line,"]")-1);
92 $outfile = "$workdir/$prefix$_.$ext";
94 # open the template file - ignore sections for which no
96 unless(open(TEMPLATE
, $outfile)) {
97 print STDERR
"Warning: No template found for item $_: $outfile: $!\n";
102 unless (open(OUTFILE
, "> $outfile.tmp")) {
103 print STDERR
"Can't create output file $outfile.tmp: $!\n";
107 # Pass the head of the template to the output file
108 KEY
: while (<TEMPLATE
>) {
110 last KEY
if (/$key/);
114 # split locale = "value" into 2 strings
115 ($locale, $value) = split(' = ', $line);
117 if ( $locale ne $line ) {
118 # replace en-US with en
119 $locale=~s/en-US/en/;
121 # use just anything inside the ""
122 $value = substr($value, index($value, "\"") + 1, rindex($value, "\"") - 1);
124 # replace resource placeholder
125 $value=~s/%PRODUCTNAME/$productname/g;
128 if ($ext eq "desktop") {
129 print OUTFILE
"$key\[$locale\]=$value\n";
131 print OUTFILE
"\t\[$locale\]$key=$value\n";
141 if (close(OUTFILE
)) {
142 system "mv -f $outfile.tmp $outfile\n";