1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4#*************************************************************************
5#
6# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7#
8# Copyright 2000, 2010 Oracle and/or its affiliates.
9#
10# OpenOffice.org - a multi-platform office productivity suite
11#
12# This file is part of OpenOffice.org.
13#
14# OpenOffice.org is free software: you can redistribute it and/or modify
15# it under the terms of the GNU Lesser General Public License version 3
16# only, as published by the Free Software Foundation.
17#
18# OpenOffice.org is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21# GNU Lesser General Public License version 3 for more details
22# (a copy is included in the LICENSE file that accompanied this code).
23#
24# You should have received a copy of the GNU Lesser General Public License
25# version 3 along with OpenOffice.org.  If not, see
26# <http://www.openoffice.org/license.html>
27# for a copy of the LGPLv3 License.
28#
29#***********************************************************************/
30
31
32#### script id #####
33
34( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
35
36$id_str = ' $Revision: 1.4.108.1 $ ';
37$id_str =~ /Revision:\s+(\S+)\s+\$/
38  ? ($script_rev = $1) : ($script_rev = "-");
39
40#########################
41#                       #
42#   Globale Variablen   #
43#                       #
44#########################
45
46use Encode;
47use Encode::Alias;
48
49
50my ($in_name, $ID, $new_ID);
51my ($help);
52
53print STDERR "$script_name -- Version: $script_rev\n" ;
54
55&get_options;
56
57if ( $help ) {
58    &usage();
59    exit 0;
60};
61
62
63open IN, "<$in_name" or die "Could not open $in_name for reading $! $^E";
64
65foreach $lang ( keys %files )
66{
67    open "F_$lang",">$files{$lang}" or die "Could not open $files{$lang} for writing $! $^E";
68    binmode "F_$lang";
69    $files{$lang} = "F_$lang";
70}
71
72%transunit = ();
73
74while ( <IN> )
75{
76    chomp;
77    $line = $_;
78    $line =~ s/\r$//;
79    # [RID_RESXLS_COST_Print_Area]
80    if ( $line =~ /^\[(.*)\]$/ )
81    {
82        $new_ID = $1;
83
84        write_transunit();
85        $ID = $new_ID;
86        %transunit = ();
87    }
88    # de = "Druckbereich"
89    elsif ( $line =~ /^(\S*)\s*=\s*\"(.*)\"$/ )
90    {
91        $lang = $1;
92        $string = $2;
93        $transunit{ $lang } = $string;
94    }
95    elsif ( $line !~ /^\s*$/ )
96    {
97        die "unknown lineformat in $in_name: $line\n";
98    }
99}
100write_transunit();
101
102
103sub write_transunit
104{
105    if ( ! $ID )
106    {
107        return;
108    }
109	foreach $lang ( keys %files )
110	{
111	    my $string;
112	    if ( defined $transunit{ $lang } )
113	    {
114	        $string = $transunit{ $lang };
115	    }
116	    else
117	    {
118	        $string = $transunit{ "en-US" };
119	    }
120
121        my $dat_line = "$ID=$string";
122        Encode::from_to( $dat_line, "utf8", "UTF-16LE");
123		print { $files{$lang} } "$dat_line\015\000\012\000";
124	}
125}
126
127
128sub get_options {
129	my ($arg,$lang);
130
131	while ($arg = shift @ARGV) {
132		$arg =~ /^-i$/  and $in_name = shift @ARGV and next;
133		$arg =~ /^-help$/  and $help = 1 and next; #show help
134
135		$arg =~ /.*[\/\\]([^\/\\]*)\.dat$/;
136#		$arg =~ /.*[/\]([^/\]*)\.dat$/;
137		$lang = $1;
138		print "got $lang = $arg\n";
139		$files{ $lang } = $arg;
140	}
141}
142
143
144
145sub usage {
146	print STDERR "\n\n";
147    print STDERR "Syntax:   $script_name [-help|-i <ulf-filename>] <dat-filename> ... \n";
148    print STDERR "Example:  $script_name -i strings.ulf en-US.dat de.dat\n";
149    print STDERR "Options:\n\n";
150    print STDERR "    -i      input ulf file\n";
151    print STDERR "    -help   print this help info\n\n";
152};
153
154