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