xref: /aoo41x/main/l10ntools/scripts/localize.pl (revision 8e9e5c11)
1cdf0e10cSrcweir:
2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3cdf0e10cSrcweir    if 0;
4cdf0e10cSrcweir
5cdf0e10cSrcweir
67e90fac2SAndrew Rist#**************************************************************
77e90fac2SAndrew Rist#
87e90fac2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
97e90fac2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
107e90fac2SAndrew Rist#  distributed with this work for additional information
117e90fac2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
127e90fac2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
137e90fac2SAndrew Rist#  "License"); you may not use this file except in compliance
147e90fac2SAndrew Rist#  with the License.  You may obtain a copy of the License at
157e90fac2SAndrew Rist#
167e90fac2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
177e90fac2SAndrew Rist#
187e90fac2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
197e90fac2SAndrew Rist#  software distributed under the License is distributed on an
207e90fac2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
217e90fac2SAndrew Rist#  KIND, either express or implied.  See the License for the
227e90fac2SAndrew Rist#  specific language governing permissions and limitations
237e90fac2SAndrew Rist#  under the License.
247e90fac2SAndrew Rist#
257e90fac2SAndrew Rist#**************************************************************
267e90fac2SAndrew Rist
277e90fac2SAndrew Rist
28cdf0e10cSrcweir
29cdf0e10cSrcweiruse strict;
30cdf0e10cSrcweiruse Getopt::Long;
31cdf0e10cSrcweiruse IO::Handle;
32cdf0e10cSrcweiruse File::Find;
33cdf0e10cSrcweiruse File::Temp;
34cdf0e10cSrcweiruse File::Path;
35cdf0e10cSrcweiruse File::Copy;
36cdf0e10cSrcweiruse File::Glob qw(:glob csh_glob);
37cdf0e10cSrcweiruse Cwd;
38cdf0e10cSrcweir
39cdf0e10cSrcweirmy $CVS_BINARY = "/usr/bin/cvs";
40cdf0e10cSrcweir# ver 1.1
41cdf0e10cSrcweir#
42cdf0e10cSrcweir#### module lookup
43cdf0e10cSrcweir#use lib ("$ENV{SOLARENV}/bin/modules", "$ENV{COMMON_ENV_TOOLS}/modules");
44cdf0e10cSrcweir
45cdf0e10cSrcweir#### module lookup
46cdf0e10cSrcweir# OOo conform
47cdf0e10cSrcweirmy @lib_dirs;
48cdf0e10cSrcweirBEGIN {
49cdf0e10cSrcweir    if ( !defined($ENV{SOLARENV}) ) {
50cdf0e10cSrcweir        die "No environment found (environment variable SOLARENV is undefined)";
51cdf0e10cSrcweir    }
52cdf0e10cSrcweir    push(@lib_dirs, "$ENV{SOLARENV}/bin/modules");
53cdf0e10cSrcweir    push(@lib_dirs, "$ENV{COMMON_ENV_TOOLS}/modules") if defined($ENV{COMMON_ENV_TOOLS});
54cdf0e10cSrcweir}
55cdf0e10cSrcweiruse lib (@lib_dirs);
56cdf0e10cSrcweir
57cdf0e10cSrcweir#### globals ####
58cdf0e10cSrcweirmy $sdffile                 = '';
59cdf0e10cSrcweirmy $no_sort                 = '';
60cdf0e10cSrcweirmy $create_dirs             = '';
61cdf0e10cSrcweirmy $multi_localize_files    = '';
62cdf0e10cSrcweirmy $module_to_merge         = '';
63cdf0e10cSrcweirmy $sort_sdf_before         = '';
64cdf0e10cSrcweirmy $outputfile              = '';
65cdf0e10cSrcweirmy $no_gsicheck             = '';
66cdf0e10cSrcweirmy $mode                    = '';
67cdf0e10cSrcweirmy $bVerbose                = "0";
68cdf0e10cSrcweirmy $srcpath                 = '';
69cdf0e10cSrcweirmy $languages;
70cdf0e10cSrcweir#my %sl_modules;     # Contains all modules where en-US and de is source language
71cdf0e10cSrcweirmy $use_default_date = '0';
72cdf0e10cSrcweirmy $force_ooo_module = '0';
73cdf0e10cSrcweirmy %is_ooo_module;
74cdf0e10cSrcweirmy %is_so_module;
75cdf0e10cSrcweir
76cdf0e10cSrcweir         #         (                           leftpart                                                     )            (           rightpart                    )
77cdf0e10cSrcweir         #            prj      file      dummy     type       gid       lid      helpid    pform     width      lang       text    helptext  qhelptext   title    timestamp
78cdf0e10cSrcweirmy $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]*)\t)([^\t]*))";
79cdf0e10cSrcweirmy $file_types = "(src|hrc|xcs|xcu|lng|ulf|xrm|xhp|xcd|xgf|xxl|xrb)";
80cdf0e10cSrcweir# Always use this date to prevent cvs conflicts
81cdf0e10cSrcweirmy $default_date = "2002-02-02 02:02:02";
82cdf0e10cSrcweirmy @sdfparticles;
83cdf0e10cSrcweir
84cdf0e10cSrcweir#### main ####
85cdf0e10cSrcweirparse_options();
86cdf0e10cSrcweir
87cdf0e10cSrcweirmy $binpath = '';
88cdf0e10cSrcweirif( defined $ENV{UPDMINOREXT} )
89cdf0e10cSrcweir{
90cdf0e10cSrcweir    $binpath = $ENV{SOLARVER}."/".$ENV{INPATH}."/bin".$ENV{UPDMINOREXT}."/" ;
91cdf0e10cSrcweir}
92cdf0e10cSrcweirelse
93cdf0e10cSrcweir{
94cdf0e10cSrcweir    $binpath = $ENV{SOLARVER}."/".$ENV{INPATH}."/bin/" ;
95cdf0e10cSrcweir}
96cdf0e10cSrcweir
97cdf0e10cSrcweir#%sl_modules = fetch_sourcelanguage_dirlist();
98cdf0e10cSrcweir
99cdf0e10cSrcweir
100cdf0e10cSrcweirif   ( $mode eq "merge"    )    {
101cdf0e10cSrcweir    if ( ! $no_gsicheck ){
102cdf0e10cSrcweir        merge_gsicheck();
103cdf0e10cSrcweir    }
104cdf0e10cSrcweir    splitfile( $sdffile );
105cdf0e10cSrcweir    if ( ! $no_gsicheck ){
106cdf0e10cSrcweir        unlink $sdffile;             # remove temp file!
107cdf0e10cSrcweir    }
108cdf0e10cSrcweir}
109cdf0e10cSrcweirelsif( $mode eq "extract"  )    {
110cdf0e10cSrcweir    collectfiles( $outputfile );
111cdf0e10cSrcweir}
112cdf0e10cSrcweirelse                            {
113cdf0e10cSrcweir    usage();
114cdf0e10cSrcweir}
115cdf0e10cSrcweir
116cdf0e10cSrcweirexit(0);
117cdf0e10cSrcweir
118cdf0e10cSrcweir#########################################################
119cdf0e10cSrcweirsub splitfile{
120cdf0e10cSrcweir
121cdf0e10cSrcweir    my $lastFile        = '';
122cdf0e10cSrcweir    my $currentFile     = '';
123cdf0e10cSrcweir    my $cur_sdffile     = '';
124cdf0e10cSrcweir    my $last_sdffile    = '';
125cdf0e10cSrcweir    my $delim;
126cdf0e10cSrcweir    my $badDelim;
127cdf0e10cSrcweir    my $start           = 'TRUE';
128cdf0e10cSrcweir    my %index  = ();
129cdf0e10cSrcweir    my %block;
130cdf0e10cSrcweir
131cdf0e10cSrcweir    STDOUT->autoflush( 1 );
132cdf0e10cSrcweir
133cdf0e10cSrcweir    #print STDOUT "Open File $sdffile\n";
134cdf0e10cSrcweir    open MYFILE , "< $sdffile"
135cdf0e10cSrcweir    or die "Can't open '$sdffile'\n";
136cdf0e10cSrcweir
137cdf0e10cSrcweir#    my %lang_hash;
138cdf0e10cSrcweir    my %string_hash_ooo;
139cdf0e10cSrcweir    my %string_hash_so;
140cdf0e10cSrcweir    my %so_modules;
141cdf0e10cSrcweir    $so_modules{ "extras_full" } = "TRUE";
142cdf0e10cSrcweir
143cdf0e10cSrcweir    while( <MYFILE>){
144cdf0e10cSrcweir         if( /$sdf_regex/ ){
145cdf0e10cSrcweir            my $line           = defined $_ ? $_ : '';
146cdf0e10cSrcweir            my $prj            = defined $3 ? $3 : '';
147cdf0e10cSrcweir            my $file           = defined $4 ? $4 : '';
148cdf0e10cSrcweir            my $type           = defined $6 ? $6 : '';
149cdf0e10cSrcweir            my $gid            = defined $7 ? $7 : '';
150cdf0e10cSrcweir            my $lid            = defined $8 ? $8 : '';
151cdf0e10cSrcweir            my $lang           = defined $12 ? $12 : '';
152cdf0e10cSrcweir            my $plattform      = defined $10 ? $10 : '';
153cdf0e10cSrcweir            my $helpid         = defined $9 ? $9 : '';
154cdf0e10cSrcweir            next if( $prj eq "binfilter" );     # Don't merge strings into binfilter module
155cdf0e10cSrcweir	        chomp( $line );
156cdf0e10cSrcweir
157cdf0e10cSrcweir            if( $force_ooo_module )
158cdf0e10cSrcweir            {
159cdf0e10cSrcweir                $string_hash_ooo { $lang }{ "$prj\t$file\t$type\t$gid\t$lid\t$helpid\t$plattform\t$lang" } = $line;
160cdf0e10cSrcweir            }
161cdf0e10cSrcweir            else
162cdf0e10cSrcweir            {
163cdf0e10cSrcweir                $string_hash_so{ $lang }{ "$prj\t$file\t$type\t$gid\t$lid\t$helpid\t$plattform\t$lang" } = $line;
164cdf0e10cSrcweir            }
165cdf0e10cSrcweir        }
166cdf0e10cSrcweir    }
167cdf0e10cSrcweir    close( MYFILE );
168cdf0e10cSrcweir
169cdf0e10cSrcweir    if( !defined $ENV{SOURCE_ROOT_DIR} ){
170cdf0e10cSrcweir        print "Error, no SOURCE_ROOT_DIR in env found.\n";
171cdf0e10cSrcweir        exit( -1 );
172cdf0e10cSrcweir    }
173cdf0e10cSrcweir    my $src_root = $ENV{SOURCE_ROOT_DIR};
174cdf0e10cSrcweir    my $ooo_src_root = $src_root."/l10n";
175cdf0e10cSrcweir    my $so_l10n_path  = $src_root."/sun/l10n_so/source";
176cdf0e10cSrcweir    my $ooo_l10n_path = $ooo_src_root."/l10n/source";
177cdf0e10cSrcweir
178cdf0e10cSrcweir    #print "$so_l10n_path\n";
179cdf0e10cSrcweir    #print "$ooo_l10n_path\n";
180cdf0e10cSrcweir
181cdf0e10cSrcweir    if( $force_ooo_module )
182cdf0e10cSrcweir    {
183cdf0e10cSrcweir        write_sdf( \%string_hash_ooo , $ooo_l10n_path );
184cdf0e10cSrcweir    }
185cdf0e10cSrcweir    else
186cdf0e10cSrcweir    {
187cdf0e10cSrcweir        write_sdf( \%string_hash_so , $so_l10n_path );
188cdf0e10cSrcweir    }
189cdf0e10cSrcweir}
190cdf0e10cSrcweir
191cdf0e10cSrcweirsub write_sdf
192cdf0e10cSrcweir{
193cdf0e10cSrcweir    my $string_hash         = shift;
194cdf0e10cSrcweir    my $l10n_file           = shift;
195cdf0e10cSrcweir
196cdf0e10cSrcweir    foreach my $lang( keys( %{ $string_hash } ) )
197cdf0e10cSrcweir    {
198cdf0e10cSrcweir        my @sdf_file;
199cdf0e10cSrcweir        next , if( $lang eq "en-US" );
200cdf0e10cSrcweir
201cdf0e10cSrcweir        mkdir $l10n_file."/$lang";
202cdf0e10cSrcweir        # mkdir!!!!
203cdf0e10cSrcweir        my $current_l10n_file = $l10n_file."/$lang/localize.sdf";
204cdf0e10cSrcweir        print "Writing '$current_l10n_file'\n";
205cdf0e10cSrcweir        if( open DESTFILE , "< $current_l10n_file" ){
206cdf0e10cSrcweir
207cdf0e10cSrcweir            while(<DESTFILE>){
208cdf0e10cSrcweir                if( /$sdf_regex/ ){
209cdf0e10cSrcweir                    my $line           = defined $_ ? $_ : '';
210cdf0e10cSrcweir                    my $prj            = defined $3 ? $3 : '';
211cdf0e10cSrcweir                    my $file           = defined $4 ? $4 : '';
212cdf0e10cSrcweir                    my $type           = defined $6 ? $6 : '';
213cdf0e10cSrcweir                    my $gid            = defined $7 ? $7 : '';
214cdf0e10cSrcweir                    my $lid            = defined $8 ? $8 : '';
215cdf0e10cSrcweir                    my $lang           = defined $12 ? $12 : '';
216cdf0e10cSrcweir                    my $plattform      = defined $10 ? $10 : '';
217cdf0e10cSrcweir                    my $helpid         = defined $9 ? $9 : '';
218cdf0e10cSrcweir
219cdf0e10cSrcweir                    chomp( $line );
220cdf0e10cSrcweir                    if ( defined $string_hash->{ $lang }{ "$prj\t$file\t$type\t$gid\t$lid\t$helpid\t$plattform\t$lang" } )
221cdf0e10cSrcweir                    {
222cdf0e10cSrcweir                        # Changed String!
223cdf0e10cSrcweir                        push @sdf_file , $string_hash->{ $lang }{ "$prj\t$file\t$type\t$gid\t$lid\t$helpid\t$plattform\t$lang" } ;
224cdf0e10cSrcweir                        $string_hash->{ $lang }{ "$prj\t$file\t$type\t$gid\t$lid\t$helpid\t$plattform\t$lang" } = undef;
225cdf0e10cSrcweir                    }
226cdf0e10cSrcweir                    else
227cdf0e10cSrcweir                    {
228cdf0e10cSrcweir                        # No new string
229cdf0e10cSrcweir                        push @sdf_file , $line;
230cdf0e10cSrcweir                    }
231cdf0e10cSrcweir                }
232cdf0e10cSrcweir            }
233cdf0e10cSrcweir        }
234cdf0e10cSrcweir        close( DESTFILE );
235cdf0e10cSrcweir        #Now just append the enw strings
236cdf0e10cSrcweir        #FIXME!!! Implement insertion in the correct order
237cdf0e10cSrcweir        foreach my $key ( keys ( %{ $string_hash->{ $lang } } ) )
238cdf0e10cSrcweir        {
239cdf0e10cSrcweir            push @sdf_file , $string_hash->{ $lang }{ $key } , if ( defined $string_hash->{ $lang }{ $key } );
240cdf0e10cSrcweir            #print "WARNING: Not defined = ".$string_hash->{ $lang }{ $key }."\n", if( ! defined  $string_hash->{ $lang }{ $key } );
241cdf0e10cSrcweir        }
242cdf0e10cSrcweir
243cdf0e10cSrcweir        # Write the new file
244cdf0e10cSrcweir        my ( $TMPFILE , $tmpfile ) = File::Temp::tempfile();
245cdf0e10cSrcweir        if( open DESTFILE , "+> $tmpfile " ){
246cdf0e10cSrcweir            print DESTFILE get_license_header();
247cdf0e10cSrcweir            foreach my $string( @sdf_file ){
248cdf0e10cSrcweir                print DESTFILE "$string\n";
249cdf0e10cSrcweir            }
250cdf0e10cSrcweir            close ( DESTFILE );
251cdf0e10cSrcweir            if( move( $current_l10n_file , $current_l10n_file.".backup" ) ){
252cdf0e10cSrcweir                if( copy( $tmpfile , $current_l10n_file ) ){
253cdf0e10cSrcweir                    unlink $l10n_file.".backup";
254cdf0e10cSrcweir                 } else { print STDERR "Can't open/create '$l10n_file', original file is renamed to $l10n_file.backup\n"; }
255cdf0e10cSrcweir            } else { print STDERR "Can't open/create '$l10n_file'\n"; }
256cdf0e10cSrcweir         }else{
257cdf0e10cSrcweir            print STDERR "WARNING: Can't open/create '$l10n_file'\n";
258cdf0e10cSrcweir         }
259cdf0e10cSrcweir         unlink $tmpfile;
260cdf0e10cSrcweir     }
261cdf0e10cSrcweir}
262cdf0e10cSrcweir
263cdf0e10cSrcweir#########################################################
264cdf0e10cSrcweir
265cdf0e10cSrcweirsub get_license_header{
266cdf0e10cSrcweir    return
267cdf0e10cSrcweir"#\n".
268cdf0e10cSrcweir"#    ####    ###     #   #   ###   #####    #####  ####   #####  #####  \n".
269cdf0e10cSrcweir"#    #   #  #   #    ##  #  #   #    #      #      #   #    #      #    \n".
270cdf0e10cSrcweir"#    #   #  #   #    # # #  #   #    #      ###    #   #    #      #    \n".
271cdf0e10cSrcweir"#    #   #  #   #    #  ##  #   #    #      #      #   #    #      #    \n".
272cdf0e10cSrcweir"#    ####    ###     #   #   ###     #      #####  ####   #####    #    \n".
273cdf0e10cSrcweir"#\n".
274cdf0e10cSrcweir"#    DO NOT EDIT! This file will be overwritten by localisation process\n".
275cdf0e10cSrcweir"#\n".
276*8e9e5c11SAndrew Rist"#**************************************************************\n".
277*8e9e5c11SAndrew Rist"#  \n".
278*8e9e5c11SAndrew Rist"#  Licensed to the Apache Software Foundation (ASF) under one\n".
279*8e9e5c11SAndrew Rist"#  or more contributor license agreements.  See the NOTICE file\n".
280*8e9e5c11SAndrew Rist"#  distributed with this work for additional information\n".
281*8e9e5c11SAndrew Rist"#  regarding copyright ownership.  The ASF licenses this file\n".
282*8e9e5c11SAndrew Rist"#  to you under the Apache License, Version 2.0 (the\n".
283*8e9e5c11SAndrew Rist"#  "License"); you may not use this file except in compliance\n".
284*8e9e5c11SAndrew Rist"#  with the License.  You may obtain a copy of the License at\n".
285*8e9e5c11SAndrew Rist"#  \n".
286*8e9e5c11SAndrew Rist"#    http://www.apache.org/licenses/LICENSE-2.0\n".
287*8e9e5c11SAndrew Rist"#  \n".
288*8e9e5c11SAndrew Rist"#  Unless required by applicable law or agreed to in writing,\n".
289*8e9e5c11SAndrew Rist"#  software distributed under the License is distributed on an\n".
290*8e9e5c11SAndrew Rist"#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n".
291*8e9e5c11SAndrew Rist"#  KIND, either express or implied.  See the License for the\n".
292*8e9e5c11SAndrew Rist"#  specific language governing permissions and limitations\n".
293*8e9e5c11SAndrew Rist"#  under the License.\n".
294*8e9e5c11SAndrew Rist"#  \n".
295*8e9e5c11SAndrew Rist"#**************************************************************\n";
296cdf0e10cSrcweir}
297cdf0e10cSrcweir######## Check input sdf file and use only the correct part
298cdf0e10cSrcweirsub merge_gsicheck{
299cdf0e10cSrcweir    my $command = '';
300cdf0e10cSrcweir    my ( $TMPHANDLE , $tmpfile ) = File::Temp::tempfile();
301cdf0e10cSrcweir    close ( $TMPHANDLE );
302cdf0e10cSrcweir
303cdf0e10cSrcweir    $command = "$ENV{WRAPCMD} " if( $ENV{WRAPCMD} );
304cdf0e10cSrcweir    $command .= "$ENV{SOLARVER}/$ENV{INPATH}/bin/gsicheck";
305cdf0e10cSrcweir
306cdf0e10cSrcweir    my $errfile = $sdffile.".err";
307cdf0e10cSrcweir    $command .= " -k -c -wcf $tmpfile -wef $errfile -l \"\" $sdffile";
308cdf0e10cSrcweir    #my $rc = system( $command );
309cdf0e10cSrcweir    my $output = `$command`;
310cdf0e10cSrcweir    my $rc = $? << 8;
311cdf0e10cSrcweir    if ( $output ne "" ){
312cdf0e10cSrcweir        print STDOUT "### gsicheck ###\n";
313cdf0e10cSrcweir        print STDOUT "### The file $errfile have been written containing the errors in your sdf file. Those lines will not be merged: ###\n\n";
314cdf0e10cSrcweir        print STDOUT "$output\n";
315cdf0e10cSrcweir        print STDOUT "################\n";
316cdf0e10cSrcweir
317cdf0e10cSrcweir    }else{
318cdf0e10cSrcweir        # Remove the 0 Byte file
319cdf0e10cSrcweir        unlink $errfile;
320cdf0e10cSrcweir    }
321cdf0e10cSrcweir    $sdffile = $tmpfile;
322cdf0e10cSrcweir}
323cdf0e10cSrcweir#########################################################
324cdf0e10cSrcweir# find search function
325cdf0e10cSrcweirsub wanted
326cdf0e10cSrcweir{
327cdf0e10cSrcweir    my $file = $File::Find::name;
328cdf0e10cSrcweir    if( -f $file && $file =~ /.*localize.sdf$/ && !( $file =~ /.*\.svn.*/ ) ) {
329cdf0e10cSrcweir        push   @sdfparticles , $file;
330cdf0e10cSrcweir        if( $bVerbose eq "1" ) { print STDOUT "$file\n"; }
331cdf0e10cSrcweir        else { print ".";  }
332cdf0e10cSrcweir    }
333cdf0e10cSrcweir}
334cdf0e10cSrcweir
335cdf0e10cSrcweirsub add_paths
336cdf0e10cSrcweir{
337cdf0e10cSrcweir    my $langhash_ref            = shift;
338cdf0e10cSrcweir    my $root_dir = $ENV{ SRC_ROOT };
339cdf0e10cSrcweir    my $ooo_l10n_dir = "$root_dir/l10n/source";
340cdf0e10cSrcweir    my $so_l10n_dir  = "$root_dir/l10n_so/source";
341cdf0e10cSrcweir
342cdf0e10cSrcweir    if( -e $ooo_l10n_dir )
343cdf0e10cSrcweir    {
344cdf0e10cSrcweir        foreach my $lang ( keys( %{ $langhash_ref } ) )
345cdf0e10cSrcweir        {
346cdf0e10cSrcweir            my $loc_file = "$ooo_l10n_dir/$lang/localize.sdf";
347cdf0e10cSrcweir            if( -e $loc_file )
348cdf0e10cSrcweir            {
349cdf0e10cSrcweir                push @sdfparticles , "$ooo_l10n_dir/$lang/localize.sdf";
350cdf0e10cSrcweir            }
351cdf0e10cSrcweir            else { print "WARNING: $loc_file not found ....\n"; }
352cdf0e10cSrcweir        }
353cdf0e10cSrcweir    }
354cdf0e10cSrcweir    else { die "ERROR: Can not find directory $ooo_l10n_dir!!!" }
355cdf0e10cSrcweir    if( -e $so_l10n_dir )
356cdf0e10cSrcweir    {
357cdf0e10cSrcweir        foreach my $lang ( keys( %{ $langhash_ref } ) )
358cdf0e10cSrcweir        {
359cdf0e10cSrcweir            my $loc_file = "$so_l10n_dir/$lang/localize.sdf";
360cdf0e10cSrcweir            if( -e $loc_file )
361cdf0e10cSrcweir            {
362cdf0e10cSrcweir                push @sdfparticles , "$ooo_l10n_dir/$lang/localize.sdf";
363cdf0e10cSrcweir            }
364cdf0e10cSrcweir            else { #print "WARNING: $loc_file not found ....\n";
365cdf0e10cSrcweir            }
366cdf0e10cSrcweir        }
367cdf0e10cSrcweir
368cdf0e10cSrcweir    }
369cdf0e10cSrcweir}
370cdf0e10cSrcweirsub collectfiles{
371cdf0e10cSrcweir    print STDOUT "### Localize\n";
372cdf0e10cSrcweir    my $localizehash_ref;
373cdf0e10cSrcweir    my ( $bAll , $bUseLocalize, $langhash_ref , $bHasSourceLanguage , $bFakeEnglish ) = parseLanguages();
374cdf0e10cSrcweir
375cdf0e10cSrcweir    # Enable autoflush on STDOUT
376cdf0e10cSrcweir    # $| = 1;
377cdf0e10cSrcweir    STDOUT->autoflush( 1 );
378cdf0e10cSrcweir
379cdf0e10cSrcweir    my $working_path = getcwd();
380cdf0e10cSrcweir    chdir $ENV{SOURCE_ROOT_DIR}, if defined $ENV{SOURCE_ROOT_DIR};
381cdf0e10cSrcweir    add_paths( $langhash_ref );
382cdf0e10cSrcweir
383cdf0e10cSrcweir    my ( $LOCALIZEPARTICLE , $localizeSDF ) = File::Temp::tempfile();
384cdf0e10cSrcweir    close( $LOCALIZEPARTICLE );
385cdf0e10cSrcweir
386cdf0e10cSrcweir    my ( $ALLPARTICLES_MERGED , $particleSDF_merged )     = File::Temp::tempfile();
387cdf0e10cSrcweir    close( $ALLPARTICLES_MERGED );
388cdf0e10cSrcweir    my ( $LOCALIZE_LOG , $my_localize_log ) = File::Temp::tempfile();
389cdf0e10cSrcweir    close( $LOCALIZE_LOG );
390cdf0e10cSrcweir
391cdf0e10cSrcweir    ## Get the localize en-US extract
392cdf0e10cSrcweir    if( $bAll || $bUseLocalize ){
393cdf0e10cSrcweir        print "### Fetching source language strings\n";
394cdf0e10cSrcweir        my $command = "";
395cdf0e10cSrcweir        my $args    = "";
396cdf0e10cSrcweir
397cdf0e10cSrcweir        if( $ENV{WRAPCMD} ){
398cdf0e10cSrcweir            $command = $ENV{WRAPCMD}.$binpath."localize_sl";
399cdf0e10cSrcweir        }else{
400cdf0e10cSrcweir            $command = $binpath."localize_sl";
401cdf0e10cSrcweir        }
402cdf0e10cSrcweir        print $command;
403cdf0e10cSrcweir        # -e
404cdf0e10cSrcweir        # if ( -x $command ){
405cdf0e10cSrcweir        if( $command ){
406cdf0e10cSrcweir            if( !$bVerbose  ){ $args .= " "; }
407cdf0e10cSrcweir            $args .= " -e -f $localizeSDF -l ";
408cdf0e10cSrcweir            my $bFlag="";
409cdf0e10cSrcweir            if( $bAll ) {$args .= " en-US";}
410cdf0e10cSrcweir            else{
411cdf0e10cSrcweir              my @list;
412cdf0e10cSrcweir              foreach my $isokey ( keys( %{ $langhash_ref } ) ){
413cdf0e10cSrcweir                push @list , $isokey;
414cdf0e10cSrcweir                if( $langhash_ref->{ $isokey } ne "" ){
415cdf0e10cSrcweir                    push @list , $langhash_ref->{ $isokey };
416cdf0e10cSrcweir                }
417cdf0e10cSrcweir              }
418cdf0e10cSrcweir              remove_duplicates( \@list );
419cdf0e10cSrcweir              foreach my $isokey ( @list ){
420cdf0e10cSrcweir                switch :{
421cdf0e10cSrcweir                       ( $isokey=~ /^en-US$/i  )
422cdf0e10cSrcweir                        && do{
423cdf0e10cSrcweir                                if( $bFlag eq "TRUE" ){ $args .= ",en-US"; }
424cdf0e10cSrcweir                                else {
425cdf0e10cSrcweir                                    $args .= "en-US";  $bFlag = "TRUE";
426cdf0e10cSrcweir                                 }
427cdf0e10cSrcweir                              };
428cdf0e10cSrcweir
429cdf0e10cSrcweir                    } #switch
430cdf0e10cSrcweir                } #foreach
431cdf0e10cSrcweir              } # if
432cdf0e10cSrcweir        } # if
433cdf0e10cSrcweir        if ( $bVerbose ) { print STDOUT $command.$args."\n"; }
434cdf0e10cSrcweir
435cdf0e10cSrcweir        my $rc = system( $command.$args );
436cdf0e10cSrcweir
437cdf0e10cSrcweir        if( $rc < 0 ){    print STDERR "ERROR: localize rc = $rc\n"; exit( -1 ); }
438cdf0e10cSrcweir        ( $localizehash_ref )  = read_file( $localizeSDF , $langhash_ref );
439cdf0e10cSrcweir
440cdf0e10cSrcweir    }
441cdf0e10cSrcweir    ## Get sdf particles
442cdf0e10cSrcweir#*****************
443cdf0e10cSrcweir    open ALLPARTICLES_MERGED , "+>> $particleSDF_merged"
444cdf0e10cSrcweir    or die "Can't open $particleSDF_merged";
445cdf0e10cSrcweir
446cdf0e10cSrcweir    ## Fill fackback hash
447cdf0e10cSrcweir    my( $fallbackhashhash_ref ) = fetch_fallback( \@sdfparticles , $localizeSDF ,  $langhash_ref );
448cdf0e10cSrcweir    my %block;
449cdf0e10cSrcweir    my $cur_fallback;
450cdf0e10cSrcweir    if( !$bAll) {
451cdf0e10cSrcweir        foreach my $cur_lang ( keys( %{ $langhash_ref } ) ){
452cdf0e10cSrcweir            #print STDOUT "DBG: G1 cur_lang=$cur_lang\n";
453cdf0e10cSrcweir            $cur_fallback = $langhash_ref->{ $cur_lang };
454cdf0e10cSrcweir            if( $cur_fallback ne "" ){
455cdf0e10cSrcweir                # Insert fallback strings
456cdf0e10cSrcweir                #print STDOUT "DBG: Renaming $cur_fallback to $cur_lang in fallbackhash\n";
457cdf0e10cSrcweir                rename_language(  $fallbackhashhash_ref ,  $cur_fallback , $cur_lang );
458cdf0e10cSrcweir            }
459cdf0e10cSrcweir            foreach my $currentfile ( @sdfparticles ){
460cdf0e10cSrcweir                if ( open MYFILE , "< $currentfile" ) {
461cdf0e10cSrcweir                    while(<MYFILE>){
462cdf0e10cSrcweir                        if( /$sdf_regex/ ){
463cdf0e10cSrcweir                            my $line           = defined $_ ? $_ : '';
464cdf0e10cSrcweir                            my $prj            = defined $3 ? $3 : '';
465cdf0e10cSrcweir                            my $file           = defined $4 ? $4 : '';
466cdf0e10cSrcweir                            my $type           = defined $6 ? $6 : '';
467cdf0e10cSrcweir                            my $gid            = defined $7 ? $7 : '';
468cdf0e10cSrcweir                            my $lid            = defined $8 ? $8 : '';
469cdf0e10cSrcweir                            my $lang           = defined $12 ? $12 : '';
470cdf0e10cSrcweir                            my $plattform      = defined $10 ? $10 : '';
471cdf0e10cSrcweir                            my $helpid         = defined $9 ? $9 : '';
472cdf0e10cSrcweir
473cdf0e10cSrcweir                            chomp( $line );
474cdf0e10cSrcweir
475cdf0e10cSrcweir                            if ( $lang eq $cur_lang ){
476cdf0e10cSrcweir                                # Overwrite fallback strings with collected strings
477cdf0e10cSrcweir                                #if( ( !has_two_sourcelanguages( $cur_lang) && $cur_lang eq "de" ) || $cur_lang ne "en-US" ){
478cdf0e10cSrcweir                                     $fallbackhashhash_ref->{ $cur_lang }{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } =  $line ;
479cdf0e10cSrcweir                                     #}
480cdf0e10cSrcweir
481cdf0e10cSrcweir                            }
482cdf0e10cSrcweir                        }
483cdf0e10cSrcweir                    }
484cdf0e10cSrcweir                }else { print STDERR "WARNING: Can't open file $currentfile"; }
485cdf0e10cSrcweir            }
486cdf0e10cSrcweir
487cdf0e10cSrcweir            foreach my $line ( keys( %{$fallbackhashhash_ref->{ $cur_lang } } )) {
488cdf0e10cSrcweir                if( #$cur_lang ne "de" &&
489cdf0e10cSrcweir                    $cur_lang ne "en-US" ){
490cdf0e10cSrcweir                    print ALLPARTICLES_MERGED ( $fallbackhashhash_ref->{ $cur_lang }{ $line }, "\n" );
491cdf0e10cSrcweir                }
492cdf0e10cSrcweir             }
493cdf0e10cSrcweir        }
494cdf0e10cSrcweir    } else {
495cdf0e10cSrcweir        foreach my $currentfile ( @sdfparticles ){
496cdf0e10cSrcweir            if ( open MYFILE , "< $currentfile" ) {
497cdf0e10cSrcweir                while( <MYFILE> ){
498cdf0e10cSrcweir                    print ALLPARTICLES_MERGED ( $_, "\n" );  # recheck de / en-US !
499cdf0e10cSrcweir                }
500cdf0e10cSrcweir            }
501cdf0e10cSrcweir            else { print STDERR "WARNING: Can't open file $currentfile"; }
502cdf0e10cSrcweir        }
503cdf0e10cSrcweir    }
504cdf0e10cSrcweir    close ALLPARTICLES_MERGED;
505cdf0e10cSrcweir
506cdf0e10cSrcweir    # Hash of array
507cdf0e10cSrcweir    my %output;
508cdf0e10cSrcweir    my @order;
509cdf0e10cSrcweir
510cdf0e10cSrcweir    ## Join both
511cdf0e10cSrcweir    if( $outputfile ){
512cdf0e10cSrcweir        if( open DESTFILE , "+> $outputfile" ){
513cdf0e10cSrcweir            if( !open LOCALIZEPARTICLE ,  "< $localizeSDF" ) { print STDERR "ERROR: Can't open file $localizeSDF\n"; }
514cdf0e10cSrcweir            if( !open ALLPARTICLES_MERGED , "< $particleSDF_merged" ) { print STDERR "ERROR: Can't open file $particleSDF_merged\n"; }
515cdf0e10cSrcweir
516cdf0e10cSrcweir            # Insert localize
517cdf0e10cSrcweir            my $extract_date="";
518cdf0e10cSrcweir            while ( <LOCALIZEPARTICLE> ){
519cdf0e10cSrcweir                if( /$sdf_regex/ ){
520cdf0e10cSrcweir                    my $leftpart       = defined $2 ? $2 : '';
521cdf0e10cSrcweir                    my $lang           = defined $12 ? $12 : '';
522cdf0e10cSrcweir                    my $rightpart      = defined $13 ? $13 : '';
523cdf0e10cSrcweir                    my $timestamp      = defined $18 ? $18 : '';
524cdf0e10cSrcweir
525cdf0e10cSrcweir                    my $prj            = defined $3 ? $3 : '';
526cdf0e10cSrcweir                    my $file           = defined $4 ? $4 : '';
527cdf0e10cSrcweir                    my $type           = defined $6 ? $6 : '';
528cdf0e10cSrcweir                    my $gid            = defined $7 ? $7 : '';
529cdf0e10cSrcweir                    my $lid            = defined $8 ? $8 : '';
530cdf0e10cSrcweir                    #my $lang           = defined $12 ? $12 : '';
531cdf0e10cSrcweir                    my $plattform      = defined $10 ? $10 : '';
532cdf0e10cSrcweir                    my $helpid         = defined $9 ? $9 : '';
533cdf0e10cSrcweir
534cdf0e10cSrcweir
535cdf0e10cSrcweir                    if( $use_default_date )
536cdf0e10cSrcweir                    {
537cdf0e10cSrcweir                        $extract_date = "$default_date\n" ;
538cdf0e10cSrcweir                    }
539cdf0e10cSrcweir                    elsif( $extract_date eq "" ) {
540cdf0e10cSrcweir                        $extract_date = $timestamp ;
541cdf0e10cSrcweir                        $extract_date =~ tr/\r\n//d;
542cdf0e10cSrcweir                        $extract_date .= "\n";
543cdf0e10cSrcweir                    }
544cdf0e10cSrcweir
545cdf0e10cSrcweir                    if( $bAll ){ print DESTFILE $leftpart."\t".$lang."\t".$rightpart.$extract_date ; }
546cdf0e10cSrcweir                    else {
547cdf0e10cSrcweir                        foreach my $sLang ( keys( %{ $langhash_ref } ) ){
548cdf0e10cSrcweir                            if( $sLang=~ /all/i )                       {
549cdf0e10cSrcweir                                push @{ $output{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } } ,  $leftpart."\t".$lang."\t".$rightpart.$extract_date ;
550cdf0e10cSrcweir                                #print DESTFILE $leftpart."\t".$lang."\t".$rightpart.$extract_date;
551cdf0e10cSrcweir                            }
552cdf0e10cSrcweir                            #if( $sLang eq "de" && $lang eq "de" )       {
553cdf0e10cSrcweir                            #    push @{ $output{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } } ,  $leftpart."\t".$lang."\t".$rightpart.$extract_date ;
554cdf0e10cSrcweir                                #print DESTFILE $leftpart."\t".$lang."\t".$rightpart.$extract_date;
555cdf0e10cSrcweir                                #}
556cdf0e10cSrcweir                            if( $sLang eq "en-US" && $lang eq "en-US" ) {
557cdf0e10cSrcweir                                push @order , $prj.$gid.$lid.$file.$type.$plattform.$helpid;
558cdf0e10cSrcweir                                if( !$bFakeEnglish ){ push @{ $output{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } } ,  $leftpart."\t".$lang."\t".$rightpart.$extract_date ; }
559cdf0e10cSrcweir                                #print DESTFILE $leftpart."\t".$lang."\t".$rightpart.$extract_date;
560cdf0e10cSrcweir                            }
561cdf0e10cSrcweir
562cdf0e10cSrcweir                        }
563cdf0e10cSrcweir                    }
564cdf0e10cSrcweir                }
565cdf0e10cSrcweir            }
566cdf0e10cSrcweir            # Insert particles
567cdf0e10cSrcweir            while ( <ALLPARTICLES_MERGED> ){
568cdf0e10cSrcweir                if( /$sdf_regex/ ){
569cdf0e10cSrcweir                    my $leftpart       = defined $2 ? $2 : '';
570cdf0e10cSrcweir                    my $prj            = defined $3 ? $3 : '';
571cdf0e10cSrcweir                    my $lang           = defined $12 ? $12 : '';
572cdf0e10cSrcweir                    my $rightpart      = defined $13 ? $13 : '';
573cdf0e10cSrcweir                    my $timestamp      = defined $18 ? $18 : '';
574cdf0e10cSrcweir
575cdf0e10cSrcweir                    #my $prj            = defined $3 ? $3 : '';
576cdf0e10cSrcweir                    my $file           = defined $4 ? $4 : '';
577cdf0e10cSrcweir                    my $type           = defined $6 ? $6 : '';
578cdf0e10cSrcweir                    my $gid            = defined $7 ? $7 : '';
579cdf0e10cSrcweir                    my $lid            = defined $8 ? $8 : '';
580cdf0e10cSrcweir                    #my $lang           = defined $12 ? $12 : '';
581cdf0e10cSrcweir                    my $plattform      = defined $10 ? $10 : '';
582cdf0e10cSrcweir                    my $helpid         = defined $9 ? $9 : '';
583cdf0e10cSrcweir
584cdf0e10cSrcweir
585cdf0e10cSrcweir                    if( $use_default_date )
586cdf0e10cSrcweir                    {
587cdf0e10cSrcweir                        $extract_date = "$default_date\n" ;
588cdf0e10cSrcweir                    }
589cdf0e10cSrcweir                    elsif( $extract_date eq "" )
590cdf0e10cSrcweir                    {
591cdf0e10cSrcweir                        $extract_date = $timestamp;
592cdf0e10cSrcweir                    }
593cdf0e10cSrcweir
594cdf0e10cSrcweir                    if( ! ( $prj =~ /binfilter/i ) ) {
595cdf0e10cSrcweir                        push @{ $output{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } } , $leftpart."\t".$lang."\t".$rightpart.$extract_date ;
596cdf0e10cSrcweir                        #print DESTFILE $leftpart."\t".$lang."\t".$rightpart.$extract_date ;
597cdf0e10cSrcweir                    }
598cdf0e10cSrcweir                 }
599cdf0e10cSrcweir            }
600cdf0e10cSrcweir
601cdf0e10cSrcweir            # Write!
602cdf0e10cSrcweir            foreach my $curkey ( @order ){
603cdf0e10cSrcweir                foreach my $curlist ( $output{ $curkey } ){
604cdf0e10cSrcweir                    foreach my $line ( @{$curlist} ){
605cdf0e10cSrcweir                        print DESTFILE $line;
606cdf0e10cSrcweir                    }
607cdf0e10cSrcweir                }
608cdf0e10cSrcweir            }
609cdf0e10cSrcweir
610cdf0e10cSrcweir        }else { print STDERR "Can't open $outputfile";}
611cdf0e10cSrcweir    }
612cdf0e10cSrcweir    close DESTFILE;
613cdf0e10cSrcweir    close LOCALIZEPARTICLE;
614cdf0e10cSrcweir    close ALLPARTICLES_MERGED;
615cdf0e10cSrcweir    chdir $working_path;
616cdf0e10cSrcweir
617cdf0e10cSrcweir    #print STDOUT "DBG: \$localizeSDF $localizeSDF \$particleSDF_merged $particleSDF_merged\n";
618cdf0e10cSrcweir    unlink $localizeSDF , $particleSDF_merged ,  $my_localize_log;
619cdf0e10cSrcweir
620cdf0e10cSrcweir    #sort_outfile( $outputfile );
621cdf0e10cSrcweir    #remove_obsolete( $outputfile ) , if $bHasSourceLanguage ne "";
622cdf0e10cSrcweir    }
623cdf0e10cSrcweir
624cdf0e10cSrcweir#########################################################
625cdf0e10cSrcweirsub remove_obsolete{
626cdf0e10cSrcweir    my $outfile = shift;
627cdf0e10cSrcweir    my @lines;
628cdf0e10cSrcweir    my $enusleftpart;
629cdf0e10cSrcweir    my @good_lines;
630cdf0e10cSrcweir
631cdf0e10cSrcweir    print STDOUT "### Removing obsolete strings\n";
632cdf0e10cSrcweir
633cdf0e10cSrcweir    # Kick out all strings without en-US reference
634cdf0e10cSrcweir    if ( open ( SORTEDFILE , "< $outfile" ) ){
635cdf0e10cSrcweir        while( <SORTEDFILE> ){
636cdf0e10cSrcweir            if( /$sdf_regex/ ){
637cdf0e10cSrcweir                my $line           = defined $_ ? $_ : '';
638cdf0e10cSrcweir                my $language       = defined $12 ? $12 : '';
639cdf0e10cSrcweir                my $prj            = defined $3 ? $3 : '';
640cdf0e10cSrcweir                my $file           = defined $4 ? $4 : '';
641cdf0e10cSrcweir                my $type           = defined $6 ? $6 : '';
642cdf0e10cSrcweir                my $gid            = defined $7 ? $7 : '';
643cdf0e10cSrcweir                my $lid            = defined $8 ? $8 : '';
644cdf0e10cSrcweir                my $plattform      = defined $10 ? $10 : '';
645cdf0e10cSrcweir                my $helpid         = defined $9 ? $9 : '';
646cdf0e10cSrcweir
647cdf0e10cSrcweir                my $leftpart = $prj.$gid.$lid.$file.$type.$plattform.$helpid;
648cdf0e10cSrcweir
649cdf0e10cSrcweir                if( $language eq "en-US" ){                 # source string found, 1. entry
650cdf0e10cSrcweir                    $enusleftpart = $leftpart;
651cdf0e10cSrcweir                    push @good_lines , $line;
652cdf0e10cSrcweir                }else{
653cdf0e10cSrcweir                    if( !defined $enusleftpart or !defined $leftpart ){
654cdf0e10cSrcweir                        print STDERR "BADLINE: $line\n";
655cdf0e10cSrcweir                        print STDERR "\$enusleftpart = $enusleftpart\n";
656cdf0e10cSrcweir                        print STDERR "\$leftpart = $leftpart\n";
657cdf0e10cSrcweir                    }
658cdf0e10cSrcweir                    if( $enusleftpart eq $leftpart ){   # matching language
659cdf0e10cSrcweir                        push @good_lines , $line;
660cdf0e10cSrcweir                    }
661cdf0e10cSrcweir                    #else{
662cdf0e10cSrcweir                    #    print STDERR "OUT:  \$enusleftpart=$enusleftpart \$leftpart=$leftpart \$line=$line\n";
663cdf0e10cSrcweir                    #}
664cdf0e10cSrcweir                }
665cdf0e10cSrcweir            }
666cdf0e10cSrcweir        }
667cdf0e10cSrcweir        close SORTEDFILE;
668cdf0e10cSrcweir    } else { print STDERR "ERROR: Can't open file $outfile\n";}
669cdf0e10cSrcweir
670cdf0e10cSrcweir    # Write file
671cdf0e10cSrcweir    if ( open ( SORTEDFILE , "> $outfile" ) ){
672cdf0e10cSrcweir        foreach my $newline ( @good_lines ) {
673cdf0e10cSrcweir            print SORTEDFILE $newline;
674cdf0e10cSrcweir        }
675cdf0e10cSrcweir        close SORTEDFILE;
676cdf0e10cSrcweir    } else { print STDERR "ERROR: Can't open file $outfile\n";}
677cdf0e10cSrcweir
678cdf0e10cSrcweir}
679cdf0e10cSrcweir#########################################################
680cdf0e10cSrcweirsub sort_outfile{
681cdf0e10cSrcweir        my $outfile = shift;
682cdf0e10cSrcweir        print STDOUT "### Sorting ... $outfile ...";
683cdf0e10cSrcweir        my @lines;
684cdf0e10cSrcweir        my @sorted_lines;
685cdf0e10cSrcweir
686cdf0e10cSrcweir
687cdf0e10cSrcweir        #if ( open ( SORTEDFILE , "< $outputfile" ) ){
688cdf0e10cSrcweir        if ( open ( SORTEDFILE , "< $outfile" ) ){
689cdf0e10cSrcweir            my $line;
690cdf0e10cSrcweir            while ( <SORTEDFILE> ){
691cdf0e10cSrcweir                $line = $_;
692cdf0e10cSrcweir                if( $line =~ /^[^\#]/ ){
693cdf0e10cSrcweir                    push @lines , $line;
694cdf0e10cSrcweir                }
695cdf0e10cSrcweir            }
696cdf0e10cSrcweir            close SORTEDFILE;
697cdf0e10cSrcweir            @sorted_lines = sort {
698cdf0e10cSrcweir                my $xa_lang          = "";
699cdf0e10cSrcweir                my $xa_left_part    = "";
700cdf0e10cSrcweir                my $xa_right_part    = "";
701cdf0e10cSrcweir                my $xa_timestamp     = "";
702cdf0e10cSrcweir                my $xb_lang          = "";
703cdf0e10cSrcweir                my $xb_left_part    = "";
704cdf0e10cSrcweir                my $xb_right_part    = "";
705cdf0e10cSrcweir                my $xb_timestamp     = "";
706cdf0e10cSrcweir                my $xa               = "";
707cdf0e10cSrcweir                my $xb               = "";
708cdf0e10cSrcweir                my @alist;
709cdf0e10cSrcweir                my @blist;
710cdf0e10cSrcweir
711cdf0e10cSrcweir                if( $a=~ /$sdf_regex/ ){
712cdf0e10cSrcweir                    $xa_left_part       = defined $2 ? $2 : '';
713cdf0e10cSrcweir                    $xa_lang           = defined $12 ? $12 : '';
714cdf0e10cSrcweir                    $xa_right_part     = defined $13 ? $13 : '';
715cdf0e10cSrcweir                    $xa_left_part = remove_last_column( $xa_left_part );
716cdf0e10cSrcweir
717cdf0e10cSrcweir                }
718cdf0e10cSrcweir                if( $b=~ /$sdf_regex/ ){
719cdf0e10cSrcweir                    $xb_left_part       = defined $2 ? $2 : '';
720cdf0e10cSrcweir                    $xb_lang           = defined $12 ? $12 : '';
721cdf0e10cSrcweir                    $xb_right_part     = defined $13 ? $13 : '';
722cdf0e10cSrcweir                    $xb_left_part = remove_last_column( $xb_left_part );
723cdf0e10cSrcweir
724cdf0e10cSrcweir
725cdf0e10cSrcweir                }
726cdf0e10cSrcweir                if( (  $xa_left_part cmp $xb_left_part ) == 0 ){         # Left part equal
727cdf0e10cSrcweir                     if( ( $xa_lang cmp $xb_lang ) == 0 ){               # Lang equal
728cdf0e10cSrcweir                         return ( $xa_right_part cmp $xb_right_part );   # Right part compare
729cdf0e10cSrcweir                    }
730cdf0e10cSrcweir                    elsif( $xa_lang eq "en-US" ) { return -1; }        # en-US wins
731cdf0e10cSrcweir                    elsif( $xb_lang eq "en-US" ) { return 1;  }        # en-US wins
732cdf0e10cSrcweir                    else { return $xa_lang cmp $xb_lang; }             # lang compare
733cdf0e10cSrcweir                }
734cdf0e10cSrcweir                else {
735cdf0e10cSrcweir                    return $xa_left_part cmp $xb_left_part;        # Left part compare
736cdf0e10cSrcweir                }
737cdf0e10cSrcweir            } @lines;
738cdf0e10cSrcweir
739cdf0e10cSrcweir            if ( open ( SORTEDFILE , "> $outfile" ) ){
740cdf0e10cSrcweir                print SORTEDFILE get_license_header();
741cdf0e10cSrcweir                foreach my $newline ( @sorted_lines ) {
742cdf0e10cSrcweir                    print SORTEDFILE $newline;
743cdf0e10cSrcweir                    #print STDOUT $newline;
744cdf0e10cSrcweir                }
745cdf0e10cSrcweir            }
746cdf0e10cSrcweir            close SORTEDFILE;
747cdf0e10cSrcweir        } else { print STDERR "WARNING: Can't open file $outfile\n";}
748cdf0e10cSrcweir	print "done\n";
749cdf0e10cSrcweir
750cdf0e10cSrcweir}
751cdf0e10cSrcweir#########################################################
752cdf0e10cSrcweirsub remove_last_column{
753cdf0e10cSrcweir    my $string                  = shift;
754cdf0e10cSrcweir    my @alist = split ( "\t" , $string );
755cdf0e10cSrcweir    pop @alist;
756cdf0e10cSrcweir    return join( "\t" , @alist );
757cdf0e10cSrcweir}
758cdf0e10cSrcweir
759cdf0e10cSrcweir#########################################################
760cdf0e10cSrcweirsub rename_language{
761cdf0e10cSrcweir    my $fallbackhashhash_ref    = shift;
762cdf0e10cSrcweir    my $cur_fallback            = shift;
763cdf0e10cSrcweir    my $cur_lang                = shift;
764cdf0e10cSrcweir    my $line;
765cdf0e10cSrcweir
766cdf0e10cSrcweir    foreach my $key( keys ( %{ $fallbackhashhash_ref->{ $cur_fallback } } ) ){
767cdf0e10cSrcweir        $line = $fallbackhashhash_ref->{ $cur_fallback }{ $key };
768cdf0e10cSrcweir        if( $line =~ /$sdf_regex/ ){
769cdf0e10cSrcweir            my $leftpart       = defined $2 ? $2 : '';
770cdf0e10cSrcweir            my $lang           = defined $12 ? $12 : '';
771cdf0e10cSrcweir            my $rightpart      = defined $13 ? $13 : '';
772cdf0e10cSrcweir
773cdf0e10cSrcweir            $fallbackhashhash_ref->{ $cur_lang }{ $key } = $leftpart."\t".$cur_lang."\t".$rightpart;
774cdf0e10cSrcweir        }
775cdf0e10cSrcweir    }
776cdf0e10cSrcweir}
777cdf0e10cSrcweir
778cdf0e10cSrcweir############################################################
779cdf0e10cSrcweirsub remove_duplicates{
780cdf0e10cSrcweir    my $list_ref    = shift;
781cdf0e10cSrcweir    my %tmphash;
782cdf0e10cSrcweir    foreach my $key ( @{ $list_ref } ){ $tmphash{ $key } = '' ; }
783cdf0e10cSrcweir    @{$list_ref} = keys( %tmphash );
784cdf0e10cSrcweir}
785cdf0e10cSrcweir
786cdf0e10cSrcweir##############################################################
787cdf0e10cSrcweirsub fetch_fallback{
788cdf0e10cSrcweir    my $sdfparticleslist_ref   = shift;
789cdf0e10cSrcweir    my $localizeSDF            = shift;
790cdf0e10cSrcweir    my $langhash_ref           = shift;
791cdf0e10cSrcweir    my %fallbackhashhash;
792cdf0e10cSrcweir    my $cur_lang;
793cdf0e10cSrcweir    my @langlist;
794cdf0e10cSrcweir
795cdf0e10cSrcweir    foreach my $key ( keys ( %{ $langhash_ref } ) ){
796cdf0e10cSrcweir        $cur_lang = $langhash_ref->{ $key };
797cdf0e10cSrcweir        if ( $cur_lang ne "" ) {
798cdf0e10cSrcweir            push @langlist , $cur_lang;
799cdf0e10cSrcweir        }
800cdf0e10cSrcweir    }
801cdf0e10cSrcweir    remove_duplicates( \@langlist );
802cdf0e10cSrcweir    foreach  $cur_lang ( @langlist ){
803cdf0e10cSrcweir        if( $cur_lang eq "en-US" ){
804cdf0e10cSrcweir            read_fallbacks_from_source( $localizeSDF , $cur_lang , \%fallbackhashhash );
805cdf0e10cSrcweir        }
806cdf0e10cSrcweir    }
807cdf0e10cSrcweir
808cdf0e10cSrcweir    # remove de / en-US
809cdf0e10cSrcweir    my @tmplist;
810cdf0e10cSrcweir    foreach $cur_lang( @langlist ){
811cdf0e10cSrcweir        if(  $cur_lang ne "en-US" ){
812cdf0e10cSrcweir           push @tmplist , $cur_lang;
813cdf0e10cSrcweir
814cdf0e10cSrcweir        }
815cdf0e10cSrcweir    }
816cdf0e10cSrcweir    @langlist = @tmplist;
817cdf0e10cSrcweir    if ( $#langlist +1 ){
818cdf0e10cSrcweir        read_fallbacks_from_particles( $sdfparticleslist_ref , \@langlist , \%fallbackhashhash );
819cdf0e10cSrcweir
820cdf0e10cSrcweir    }
821cdf0e10cSrcweir    return (\%fallbackhashhash);
822cdf0e10cSrcweir}
823cdf0e10cSrcweir
824cdf0e10cSrcweir#########################################################
825cdf0e10cSrcweirsub write_file{
826cdf0e10cSrcweir
827cdf0e10cSrcweir    my $localizeFile = shift;
828cdf0e10cSrcweir    my $index_ref    = shift;
829cdf0e10cSrcweir
830cdf0e10cSrcweir    if( open DESTFILE , "+> $localizeFile" ){
831cdf0e10cSrcweir        foreach my $key( %{ $index_ref } ){
832cdf0e10cSrcweir            print DESTFILE ($index_ref->{ $key }, "\n" );
833cdf0e10cSrcweir        }
834cdf0e10cSrcweir        close DESTFILE;
835cdf0e10cSrcweir    }else {
836cdf0e10cSrcweir      print STDERR "Can't open/create '$localizeFile'";
837cdf0e10cSrcweir    }
838cdf0e10cSrcweir}
839cdf0e10cSrcweir
840cdf0e10cSrcweir#########################################################
841cdf0e10cSrcweirsub read_file{
842cdf0e10cSrcweir
843cdf0e10cSrcweir    my $sdffile         = shift;
844cdf0e10cSrcweir    my $langhash_ref    = shift;
845cdf0e10cSrcweir    my %block           = ();
846cdf0e10cSrcweir
847cdf0e10cSrcweir    open MYFILE , "< $sdffile"
848cdf0e10cSrcweir        or die "Can't open '$sdffile'\n";
849cdf0e10cSrcweir        while( <MYFILE>){
850cdf0e10cSrcweir          if( /$sdf_regex/ ){
851cdf0e10cSrcweir            my $line           = defined $_ ? $_ : '';
852cdf0e10cSrcweir            my $prj            = defined $3 ? $3 : '';
853cdf0e10cSrcweir            my $file           = defined $4 ? $4 : '';
854cdf0e10cSrcweir            my $type           = defined $6 ? $6 : '';
855cdf0e10cSrcweir            my $gid            = defined $7 ? $7 : '';
856cdf0e10cSrcweir            my $lid            = defined $8 ? $8 : '';
857cdf0e10cSrcweir            my $plattform      = defined $10 ? $10 : '';
858cdf0e10cSrcweir            my $lang           = defined $12 ? $12 : '';
859cdf0e10cSrcweir            my $helpid         = defined $9 ? $9 : '';
860cdf0e10cSrcweir
861cdf0e10cSrcweir            foreach my $isolang ( keys ( %{ $langhash_ref } ) ){
862cdf0e10cSrcweir                if( $isolang=~ /$lang/i || $isolang=~ /all/i ) { $block{$prj.$gid.$lid.$file.$type.$plattform.$helpid } =  $line ; }
863cdf0e10cSrcweir            }
864cdf0e10cSrcweir        }
865cdf0e10cSrcweir    }
866cdf0e10cSrcweir    return (\%block);
867cdf0e10cSrcweir}
868cdf0e10cSrcweir
869cdf0e10cSrcweir#########################################################
870cdf0e10cSrcweirsub read_fallbacks_from_particles{
871cdf0e10cSrcweir
872cdf0e10cSrcweir    my $sdfparticleslist_ref    = shift;
873cdf0e10cSrcweir    my $isolanglist_ref         = shift;
874cdf0e10cSrcweir    my $fallbackhashhash_ref    = shift;
875cdf0e10cSrcweir    my $block_ref;
876cdf0e10cSrcweir    foreach my $currentfile ( @{ $sdfparticleslist_ref } ){
877cdf0e10cSrcweir        if ( open MYFILE , "< $currentfile" ) {
878cdf0e10cSrcweir            while(<MYFILE>){
879cdf0e10cSrcweir                if( /$sdf_regex/ ){
880cdf0e10cSrcweir                    my $line           = defined $_ ? $_ : '';
881cdf0e10cSrcweir                    my $prj            = defined $3 ? $3 : '';
882cdf0e10cSrcweir                    my $file           = defined $4 ? $4 : '';
883cdf0e10cSrcweir                    my $type           = defined $6 ? $6 : '';
884cdf0e10cSrcweir                    my $gid            = defined $7 ? $7 : '';
885cdf0e10cSrcweir                    my $lid            = defined $8 ? $8 : '';
886cdf0e10cSrcweir                    my $lang           = defined $12 ? $12 : '';
887cdf0e10cSrcweir                    my $plattform      = defined $10 ? $10 : '';
888cdf0e10cSrcweir                    my $helpid         = defined $9 ? $9 : '';
889cdf0e10cSrcweir
890cdf0e10cSrcweir                    chomp( $line );
891cdf0e10cSrcweir
892cdf0e10cSrcweir                    foreach my $isolang ( @{$isolanglist_ref}  ){
893cdf0e10cSrcweir                        if( $isolang=~ /$lang/i ) {
894cdf0e10cSrcweir                            $fallbackhashhash_ref->{ $isolang }{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } =  $line ;
895cdf0e10cSrcweir                        }
896cdf0e10cSrcweir                    }
897cdf0e10cSrcweir                }
898cdf0e10cSrcweir            }
899cdf0e10cSrcweir       }else { print STDERR "WARNING: Can't open file $currentfile"; }
900cdf0e10cSrcweir    }
901cdf0e10cSrcweir}
902cdf0e10cSrcweir
903cdf0e10cSrcweir#########################################################
904cdf0e10cSrcweirsub read_fallbacks_from_source{
905cdf0e10cSrcweir
906cdf0e10cSrcweir    my $sdffile                 = shift;
907cdf0e10cSrcweir    my $isolang                 = shift;
908cdf0e10cSrcweir    my $fallbackhashhash_ref    = shift;
909cdf0e10cSrcweir    my $block_ref;
910cdf0e10cSrcweir    # read fallback for single file
911cdf0e10cSrcweir    open MYFILE , "< $sdffile"
912cdf0e10cSrcweir        or die "Can't open '$sdffile'\n";
913cdf0e10cSrcweir
914cdf0e10cSrcweir    while( <MYFILE>){
915cdf0e10cSrcweir          if( /$sdf_regex/ ){
916cdf0e10cSrcweir            my $line           = defined $_ ? $_ : '';
917cdf0e10cSrcweir            my $prj            = defined $3 ? $3 : '';
918cdf0e10cSrcweir            my $file           = defined $4 ? $4 : '';
919cdf0e10cSrcweir            my $type           = defined $6 ? $6 : '';
920cdf0e10cSrcweir            my $gid            = defined $7 ? $7 : '';
921cdf0e10cSrcweir            my $lid            = defined $8 ? $8 : '';
922cdf0e10cSrcweir            my $helpid         = defined $9 ? $9 : '';
923cdf0e10cSrcweir            my $lang           = defined $12 ? $12 : '';
924cdf0e10cSrcweir            my $plattform      = defined $10 ? $10 : '';
925cdf0e10cSrcweir
926cdf0e10cSrcweir            chomp( $line );
927cdf0e10cSrcweir            if( $isolang=~ /$lang/i ) { $fallbackhashhash_ref->{ $isolang }{ $prj.$gid.$lid.$file.$type.$plattform.$helpid } =  $line ;
928cdf0e10cSrcweir            }
929cdf0e10cSrcweir        }
930cdf0e10cSrcweir    }
931cdf0e10cSrcweir}
932cdf0e10cSrcweir
933cdf0e10cSrcweir#########################################################
934cdf0e10cSrcweirsub parseLanguages{
935cdf0e10cSrcweir
936cdf0e10cSrcweir    my $bAll;
937cdf0e10cSrcweir    my $bUseLocalize;
938cdf0e10cSrcweir    my $bHasSourceLanguage="";
939cdf0e10cSrcweir    my $bFakeEnglish="";
940cdf0e10cSrcweir    my %langhash;
941cdf0e10cSrcweir    my $iso="";
942cdf0e10cSrcweir    my $fallback="";
943cdf0e10cSrcweir
944cdf0e10cSrcweir    #### -l all
945cdf0e10cSrcweir    if(   $languages=~ /all/ ){
946cdf0e10cSrcweir        $bAll = "TRUE";
947cdf0e10cSrcweir        $bHasSourceLanguage = "TRUE";
948cdf0e10cSrcweir    }
949cdf0e10cSrcweir    ### -l fr=de,de
950cdf0e10cSrcweir    elsif( $languages=~ /.*,.*/ ){
951cdf0e10cSrcweir        my @tmpstr =  split "," , $languages;
952cdf0e10cSrcweir        for my $lang ( @tmpstr ){
953cdf0e10cSrcweir            if( $lang=~ /([a-zA-Z]{2,3}(-[a-zA-Z\-]*)*)(=([a-zA-Z]{2,3}(-[a-zA-Z\-]*)*))?/ ){
954cdf0e10cSrcweir                $iso        = $1;
955cdf0e10cSrcweir                $fallback   = $4;
956cdf0e10cSrcweir
957cdf0e10cSrcweir                if( ( $iso && $iso=~ /(en-US)/i )  || ( $fallback && $fallback=~ /(en-US)/i ) ) {
958cdf0e10cSrcweir                    $bUseLocalize = "TRUE";
959cdf0e10cSrcweir                }
960cdf0e10cSrcweir                if( ( $iso && $iso=~ /(en-US)/i ) ) {
961cdf0e10cSrcweir                    $bHasSourceLanguage = "TRUE";
962cdf0e10cSrcweir                }
963cdf0e10cSrcweir             if( $fallback ) { $langhash{ $iso } = $fallback;   }
964cdf0e10cSrcweir             else            { $langhash{ $iso } = "";          }
965cdf0e10cSrcweir            }
966cdf0e10cSrcweir        }
967cdf0e10cSrcweir    }
968cdf0e10cSrcweir    ### -l de
969cdf0e10cSrcweir    else{
970cdf0e10cSrcweir        if( $languages=~ /([a-zA-Z]{2,3}(-[a-zA-Z\-]*)*)(=([a-zA-Z]{2,3}(-[a-zA-Z\-]*)*))?/ ){
971cdf0e10cSrcweir            $iso        = $1;
972cdf0e10cSrcweir            $fallback   = $4;
973cdf0e10cSrcweir
974cdf0e10cSrcweir            if( ( $iso && $iso=~ /(en-US)/i )  || ( $fallback && $fallback=~ /(en-US)/i ) ) {
975cdf0e10cSrcweir                $bUseLocalize = "TRUE";
976cdf0e10cSrcweir
977cdf0e10cSrcweir            }
978cdf0e10cSrcweir            if( ( $iso && $iso=~ /(en-US)/i )  ) {
979cdf0e10cSrcweir                $bHasSourceLanguage = "TRUE";
980cdf0e10cSrcweir            }
981cdf0e10cSrcweir
982cdf0e10cSrcweir             if( $fallback ) { $langhash{ $iso } = $fallback;   }
983cdf0e10cSrcweir             else            { $langhash{ $iso } = "";          }
984cdf0e10cSrcweir        }
985cdf0e10cSrcweir    }
986cdf0e10cSrcweir    # HACK en-US always needed!
987cdf0e10cSrcweir    if( !$bHasSourceLanguage ){
988cdf0e10cSrcweir        #$bHasSourceLanguage = "TRUE";
989cdf0e10cSrcweir        $bUseLocalize = "TRUE";
990cdf0e10cSrcweir        $bFakeEnglish = "TRUE";
991cdf0e10cSrcweir        $langhash{ "en-US" } = "";
992cdf0e10cSrcweir    }
993cdf0e10cSrcweir    return ( $bAll ,  $bUseLocalize , \%langhash , $bHasSourceLanguage, $bFakeEnglish);
994cdf0e10cSrcweir}
995cdf0e10cSrcweir
996cdf0e10cSrcweir#########################################################
997cdf0e10cSrcweirsub parse_options{
998cdf0e10cSrcweir
999cdf0e10cSrcweir    my $help;
1000cdf0e10cSrcweir    my $merge;
1001cdf0e10cSrcweir    my $extract;
1002cdf0e10cSrcweir    my $success = GetOptions('f=s' => \$sdffile , 'l=s' => \$languages , 's=s' => \$srcpath ,  'h' => \$help , 'v' => \$bVerbose ,
1003cdf0e10cSrcweir                             'm' => \$merge , 'e' => \$extract , 'x' => \$no_sort , 'd' => \$use_default_date , 'c' => \$create_dirs ,
1004cdf0e10cSrcweir                             'n' => \$no_gsicheck , 'o' => \$force_ooo_module );
1005cdf0e10cSrcweir    $outputfile = $sdffile;
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir    #print STDOUT "DBG: lang = $languages\n";
1008cdf0e10cSrcweir    if( !$srcpath ){
1009cdf0e10cSrcweir        $srcpath = "$ENV{SRC_ROOT}";
1010cdf0e10cSrcweir        if( !$srcpath ){
1011cdf0e10cSrcweir	        print STDERR "No path to the source root found!\n\n";
1012cdf0e10cSrcweir	        usage();
1013cdf0e10cSrcweir            exit(1);
1014cdf0e10cSrcweir        }
1015cdf0e10cSrcweir    }
1016cdf0e10cSrcweir    if( $help ){
1017cdf0e10cSrcweir        usage();
1018cdf0e10cSrcweir        exit(0);
1019cdf0e10cSrcweir    }
1020cdf0e10cSrcweir    if( !$success || $#ARGV > 1 || ( !$sdffile ) ){
1021cdf0e10cSrcweir        usage();
1022cdf0e10cSrcweir        exit(1);
1023cdf0e10cSrcweir    }
1024cdf0e10cSrcweir    if( $merge && $sdffile && ! ( -r $sdffile)){
1025cdf0e10cSrcweir        print STDERR "Can't open file '$sdffile'\n";
1026cdf0e10cSrcweir        exit(1);
1027cdf0e10cSrcweir    }
1028cdf0e10cSrcweir    if( !( $languages=~ /[a-zA-Z]{2,3}(-[a-zA-Z\-]*)*(=[a-zA-Z]{2,3}(-[a-zA-Z\-]*)*)?(,[a-zA-Z]{2,3}(-[a-zA-Z\-]*)*(=[a-zA-Z]{2,3}(-[a-zA-Z\-]*)*)?)*/ ) ){
1029cdf0e10cSrcweir        print STDERR "Please check the -l iso code\n";
1030cdf0e10cSrcweir        exit(1);
1031cdf0e10cSrcweir    }
1032cdf0e10cSrcweir    if( ( !$merge && !$extract ) || ( $merge && $extract ) ){ usage();exit( -1 );}
1033cdf0e10cSrcweir    if( $extract ){ $mode = "extract"; }
1034cdf0e10cSrcweir    else          { $mode = "merge";   }
1035cdf0e10cSrcweir}
1036cdf0e10cSrcweir#my $multi_localize_files    = ''; h
1037cdf0e10cSrcweir#my $module_to_merge         = ''; i
1038cdf0e10cSrcweir#my $sort_sdf_before         = ''; g
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir#########################################################
1041cdf0e10cSrcweirsub usage{
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir    print STDERR "Usage: localize.pl\n";
1044cdf0e10cSrcweir    print STDERR "Split or collect SDF files\n";
1045cdf0e10cSrcweir    print STDERR "           merge: -m -f <sdffile>    -l l1[=f1][,l2[=f2]][...] [ -s <sourceroot> ] [ -c ]\n";
1046cdf0e10cSrcweir    print STDERR "         extract: -e -f <outputfile> -l <lang> [ -s <sourceroot> ] [-d]\n";
1047cdf0e10cSrcweir    print STDERR "Options:\n";
1048cdf0e10cSrcweir    print STDERR "    -h              help\n";
1049cdf0e10cSrcweir    print STDERR "    -m              Merge mode\n";
1050cdf0e10cSrcweir    print STDERR "    -e              Extract mode\n";
1051cdf0e10cSrcweir    print STDERR "    -f <sdffile>    To split a big SDF file into particles\n";
1052cdf0e10cSrcweir    print STDERR "       <outputfile> To collect and join all particles to one big file\n";
1053cdf0e10cSrcweir    print STDERR "    -s <sourceroot> Path to the modules, if no \$SRC_ROOT is set\n";
1054cdf0e10cSrcweir    print STDERR "    -l ( all | <isocode> | <isocode>=fallback ) comma seperated languages\n";
1055cdf0e10cSrcweir    print STDERR "    -d              Use default date in extracted sdf file\n";
1056cdf0e10cSrcweir    print STDERR "    -c              Create needed directories\n";
1057cdf0e10cSrcweir    print STDERR "    -g              Sort sdf file before mergeing\n";
1058cdf0e10cSrcweir    print STDERR "    -h              File with localize.sdf's\n!";
1059cdf0e10cSrcweir    print STDERR "    -n              No gsicheck\n";
1060cdf0e10cSrcweir    print STDERR "    -i              Module to merge\n";
1061cdf0e10cSrcweir    print STDERR "    -o              force using ooo localization from the l10n module instead of l10n_so; \n";
1062cdf0e10cSrcweir    print STDERR "                    useful if the type can't be detected by the .svn tags; \n";
1063cdf0e10cSrcweir    print STDERR "    -v              Verbose\n";
1064cdf0e10cSrcweir    print STDERR "\nExample:\n";
1065cdf0e10cSrcweir    print STDERR "\nlocalize -e -l en-US,pt-BR=en-US -f my.sdf\n( Extract en-US and pt-BR with en-US fallback )\n";
1066cdf0e10cSrcweir    print STDERR "\nlocalize -m -l cs -f my.sdf\n( Merge cs translation into the sourcecode ) \n";
1067cdf0e10cSrcweir}
1068cdf0e10cSrcweir
1069