2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: ulf2dat.pl,v $
13 # $Revision: 1.4.108.1 $
15 # This file is part of OpenOffice.org.
17 # OpenOffice.org is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU Lesser General Public License version 3
19 # only, as published by the Free Software Foundation.
21 # OpenOffice.org is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU Lesser General Public License version 3 for more details
25 # (a copy is included in the LICENSE file that accompanied this code).
27 # You should have received a copy of the GNU Lesser General Public License
28 # version 3 along with OpenOffice.org. If not, see
29 # <http://www.openoffice.org/license.html>
30 # for a copy of the LGPLv3 License.
32 #***********************************************************************/
37 ( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
39 $id_str = ' $Revision: 1.4.108.1 $ ';
40 $id_str =~ /Revision:\s+(\S+)\s+\$/
41 ?
($script_rev = $1) : ($script_rev = "-");
43 #########################
47 #########################
53 my ($in_name, $ID, $new_ID);
56 print STDERR
"$script_name -- Version: $script_rev\n" ;
66 open IN
, "<$in_name" or die "Could not open $in_name for reading $! $^E";
68 foreach $lang ( keys %files )
70 open "F_$lang",">$files{$lang}" or die "Could not open $files{$lang} for writing $! $^E";
72 $files{$lang} = "F_$lang";
82 # [RID_RESXLS_COST_Print_Area]
83 if ( $line =~ /^\[(.*)\]$/ )
92 elsif ( $line =~ /^(\S*)\s*=\s*\"(.*)\"$/ )
96 $transunit{ $lang } = $string;
98 elsif ( $line !~ /^\s*$/ )
100 die "unknown lineformat in $in_name: $line\n";
112 foreach $lang ( keys %files )
115 if ( defined $transunit{ $lang } )
117 $string = $transunit{ $lang };
121 $string = $transunit{ "en-US" };
124 my $dat_line = "$ID=$string";
125 Encode
::from_to
( $dat_line, "utf8", "UTF-16LE");
126 print { $files{$lang} } "$dat_line\015\000\012\000";
134 while ($arg = shift @ARGV) {
135 $arg =~ /^-i$/ and $in_name = shift @ARGV and next;
136 $arg =~ /^-help$/ and $help = 1 and next; #show help
138 $arg =~ /.*[\/\\]([^\
/\\]*)\.dat$/;
139 # $arg =~ /.*[/\]([^/\]*)\.dat$/;
141 print "got $lang = $arg\n";
142 $files{ $lang } = $arg;
150 print STDERR
"Syntax: $script_name [-help|-i <ulf-filename>] <dat-filename> ... \n";
151 print STDERR
"Example: $script_name -i strings.ulf en-US.dat de.dat\n";
152 print STDERR
"Options:\n\n";
153 print STDERR
" -i input ulf file\n";
154 print STDERR
" -help print this help info\n\n";