1cdf0e10cSrcweir: 2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}' 3cdf0e10cSrcweir if 0; 4*c6f2b4a8Smseidel 57e90fac2SAndrew Rist#************************************************************** 6cdf0e10cSrcweir# 77e90fac2SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 87e90fac2SAndrew Rist# or more contributor license agreements. See the NOTICE file 97e90fac2SAndrew Rist# distributed with this work for additional information 107e90fac2SAndrew Rist# regarding copyright ownership. The ASF licenses this file 117e90fac2SAndrew Rist# to you under the Apache License, Version 2.0 (the 127e90fac2SAndrew Rist# "License"); you may not use this file except in compliance 137e90fac2SAndrew Rist# with the License. You may obtain a copy of the License at 14cdf0e10cSrcweir# 157e90fac2SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 16cdf0e10cSrcweir# 177e90fac2SAndrew Rist# Unless required by applicable law or agreed to in writing, 187e90fac2SAndrew Rist# software distributed under the License is distributed on an 197e90fac2SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 207e90fac2SAndrew Rist# KIND, either express or implied. See the License for the 217e90fac2SAndrew Rist# specific language governing permissions and limitations 227e90fac2SAndrew Rist# under the License. 23cdf0e10cSrcweir# 247e90fac2SAndrew Rist#************************************************************** 257e90fac2SAndrew Rist 26cdf0e10cSrcweiruse Cwd 'abs_path'; 27cdf0e10cSrcweiruse File::Find; 28cdf0e10cSrcweiruse File::Copy qw/cp mv/; 29cdf0e10cSrcweiruse File::Basename; 30cdf0e10cSrcweiruse Benchmark; 31cdf0e10cSrcweir 32cdf0e10cSrcweir$t0 = new Benchmark; 33cdf0e10cSrcweir# update the tree files in <platform>/misc/* 34cdf0e10cSrcweir 35cdf0e10cSrcweir$| = 1; 36cdf0e10cSrcweir 37cdf0e10cSrcweirmy $prj = $ENV{ENVPRJ}; 38cdf0e10cSrcweir 39cdf0e10cSrcweirmy $inpath = $ENV{INPATH}; 40cdf0e10cSrcweirterminate() if ( ! defined $inpath ); 41cdf0e10cSrcweir 42cdf0e10cSrcweirmy $destpath = $inpath; 43cdf0e10cSrcweirmy $with_lang = $ENV{WITH_LANG}; 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir# Always use / directory separators 47cdf0e10cSrcweir$prj =~ s/\\/\//g if defined($prj); 48cdf0e10cSrcweir$inpath =~ s/\\/\//g; 49cdf0e10cSrcweir$destpath =~ s/\\/\//g; 50cdf0e10cSrcweir 51cdf0e10cSrcweir 52cdf0e10cSrcweirif ( ! defined $prj ) { 53*c6f2b4a8Smseidel# do something that works for manual call 54cdf0e10cSrcweir ($scriptname = `pwd`) =~ s/\n/\/$0/; 55cdf0e10cSrcweir ($tree_src = $scriptname) =~ s/\/update_tree.pl/\/..\/source\/auxiliary/; 56cdf0e10cSrcweir ($tree_dest = $scriptname) =~ s/\/update_tree.pl/\/..\/$destpath\/misc/; 57cdf0e10cSrcweir ($source_dir = $scriptname) =~ s/\/update_tree.pl/\/..\/source/; 58cdf0e10cSrcweir ($source_dir_xhp = $scriptname) =~ s/\/update_tree.pl/\/..\/source/; 59cdf0e10cSrcweir 60cdf0e10cSrcweir if ( defined $ENV{TRYSDF} || defined $ENV{LOCALIZESDF} ) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir if( defined $ENV{LOCALIZATION_FOUND} && $ENV{LOCALIZATION_FOUND} eq "YES" ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir $source_dir = $ENV{TRYSDF}; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir else 67cdf0e10cSrcweir { 68cdf0e10cSrcweir $source_dir = $ENV{LOCALIZESDF}; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir $source_dir =~ s/\/auxiliary\/localize.sdf$// ; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir #else {die "ERROR: The env variables TRYSDF LOCALIZATION_FOUND LOCALIZESDF not found ... something is wrong!\n";} 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir $treestrings = "$source_dir/text/shared/tree_strings.xhp"; 76cdf0e10cSrcweir} else { 77cdf0e10cSrcweir $tree_src = "$prj\/source\/auxiliary"; 78cdf0e10cSrcweir $tree_dest = "$prj\/$destpath\/misc"; 79cdf0e10cSrcweir $source_dir = "$prj\/source"; 80cdf0e10cSrcweir $source_dir_xhp = "$prj\/source"; 81cdf0e10cSrcweir $treestrings = "$source_dir/text/shared/tree_strings.xhp"; 82cdf0e10cSrcweir 83cdf0e10cSrcweir if( defined $ENV{LOCALIZATION_FOUND} && $ENV{LOCALIZATION_FOUND} eq "YES" ) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir $source_dir = $ENV{TRYSDF}; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir else 88cdf0e10cSrcweir { 89cdf0e10cSrcweir $source_dir = $ENV{LOCALIZESDF}; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir $source_dir =~ s/\/auxiliary\/localize.sdf$// ; 92cdf0e10cSrcweir #else {die "ERROR: The env variables TRYSDF LOCALIZATION_FOUND LOCALIZESDF not found ... something is wrong!\n";} 93cdf0e10cSrcweir 94cdf0e10cSrcweir} 95cdf0e10cSrcweir 96cdf0e10cSrcweir# Get the English tree files as master 97cdf0e10cSrcweir#------------------------------- 98cdf0e10cSrcweir# Update English from xhp 99cdf0e10cSrcweir#------------------------------- 100cdf0e10cSrcweir&do_english; 101cdf0e10cSrcweir#------------------------------- 102*c6f2b4a8Smseidel# Update localization from sdf 103cdf0e10cSrcweir#------------------------------- 104cdf0e10cSrcweir 105cdf0e10cSrcweir@langs = split /\s+/, $with_lang; 106cdf0e10cSrcweir&read_loc; 107cdf0e10cSrcweirprint "################\nUpdating the treefiles for @langs \n"; 108cdf0e10cSrcweirfor $l(@langs) { 109cdf0e10cSrcweir if ($l ne "en-US") { 110cdf0e10cSrcweir &do_lang($l); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir} 113cdf0e10cSrcweir 114cdf0e10cSrcweir#------------------------------- 115cdf0e10cSrcweir# 116cdf0e10cSrcweir$t1 = new Benchmark; 117cdf0e10cSrcweir$td = timediff($t1, $t0); 118cdf0e10cSrcweirprint timestr($td),"\n"; 119cdf0e10cSrcweir 120cdf0e10cSrcweir#################### 121cdf0e10cSrcweir# SUBS 122cdf0e10cSrcweir#################### 123cdf0e10cSrcweirsub terminate { 124cdf0e10cSrcweir $err = shift; 125cdf0e10cSrcweir print "$err\n\n"; 126cdf0e10cSrcweir $msg = <<"MSG"; 127cdf0e10cSrcweir 128cdf0e10cSrcweirupdate_tree.pl 129cdf0e10cSrcweir all languages in WITH_LANG are processed. WITH_LANG=ALL is 130cdf0e10cSrcweir not supported in manual calls. 131cdf0e10cSrcweir 132cdf0e10cSrcweir Updates the *.tree files. 133cdf0e10cSrcweir At first, the English file is updated based on the English 134cdf0e10cSrcweir help topic titles as read from the help files. Then, the 135cdf0e10cSrcweir localized tree files are written based on the English tree 136cdf0e10cSrcweir file and the localized help topic titles. 137cdf0e10cSrcweir 138cdf0e10cSrcweir Requires a valid SO/OOo environment. 139cdf0e10cSrcweirMSG 140cdf0e10cSrcweir print "$msg\n"; 141cdf0e10cSrcweir exit( -1 ); 142cdf0e10cSrcweir # die "$msg\n"; 143cdf0e10cSrcweir} 144cdf0e10cSrcweir 145cdf0e10cSrcweir#--------------------------------------------------- 146cdf0e10cSrcweir 147cdf0e10cSrcweirsub do_english { 148cdf0e10cSrcweir print "Processing en-US\n"; 149cdf0e10cSrcweir undef %helpsection; undef %node; 150cdf0e10cSrcweir &readtreestrings; 151cdf0e10cSrcweir &gettreefiles; 152cdf0e10cSrcweir &processtreefiles('en-US'); 153cdf0e10cSrcweir} 154cdf0e10cSrcweir 155cdf0e10cSrcweir#--------------------------------------------------- 156cdf0e10cSrcweirsub do_lang { 157cdf0e10cSrcweir $lng = shift; 158cdf0e10cSrcweir print "\n---------------------------------------------------\nProcessing $lng\n"; 159cdf0e10cSrcweir &processtreefiles($lng); 160cdf0e10cSrcweir print "\n"; 161cdf0e10cSrcweir} 162cdf0e10cSrcweir 163cdf0e10cSrcweir#--------------------------------------------------- 164cdf0e10cSrcweirsub readtreestrings { 165cdf0e10cSrcweir print "Reading tree strings for en-US..."; 166cdf0e10cSrcweir if (open TREE, $treestrings) { 167cdf0e10cSrcweir while (<TREE>) { 168cdf0e10cSrcweir chomp; 169cdf0e10cSrcweir s/<\/*help:productname>//gis; 170cdf0e10cSrcweir if (/help_section/) { 171cdf0e10cSrcweir s/^\s*<.*help_section//; 172cdf0e10cSrcweir s/<\/.*$//; 173cdf0e10cSrcweir ($id = $_) =~ s/^.*id="(\d+)".*$/$1/; 174cdf0e10cSrcweir ($title = $_) =~ s/^.*title="(.*)".*$/$1/; 175cdf0e10cSrcweir $helpsection{$id} = $title; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir if (/node id=/) { 179cdf0e10cSrcweir s/^\s*<.*node //; 180cdf0e10cSrcweir s/<\/.*$//; 181cdf0e10cSrcweir ($id = $_) =~ s/^.*id="(\d+)".*$/$1/; 182cdf0e10cSrcweir ($title = $_) =~ s/^.*title="(.*)".*$/$1/; 183cdf0e10cSrcweir $node{$id} = $title; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir } 186cdf0e10cSrcweir close TREE; 187cdf0e10cSrcweir } else { 188cdf0e10cSrcweir &terminate("Error opening $treestrings"); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir print "done\n"; 191cdf0e10cSrcweir} 192cdf0e10cSrcweir 193cdf0e10cSrcweir#------------------------------------ 194cdf0e10cSrcweirsub gettreefiles { 195cdf0e10cSrcweir # Read the tree files from the directory 196cdf0e10cSrcweir # this list is also used for all foreign languages 197cdf0e10cSrcweir print "Reading tree files..."; 198cdf0e10cSrcweir if (opendir ENUS, "$tree_src") { 199cdf0e10cSrcweir @treeviews = grep /\.tree/, readdir ENUS; 200cdf0e10cSrcweir closedir ENUS; 201cdf0e10cSrcweir } else { 202cdf0e10cSrcweir &terminate("Cannot open directory $tree_src"); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir print "done\n"; 205cdf0e10cSrcweir} 206cdf0e10cSrcweir 207cdf0e10cSrcweir#------------------------------------ 208cdf0e10cSrcweirsub processtreefiles { 209cdf0e10cSrcweir $lng = shift; 210cdf0e10cSrcweir use File::Temp qw/ tempfile /; 211cdf0e10cSrcweir use File::Spec; 212cdf0e10cSrcweir 213cdf0e10cSrcweir for $tv(@treeviews) { 214cdf0e10cSrcweir print "\nProcessing $tv\n"; 215cdf0e10cSrcweir @lines = &readtv("$tree_src/$tv"); 216cdf0e10cSrcweir print "Read ".scalar @lines." lines\n"; 217cdf0e10cSrcweir for $l(@lines) { 218cdf0e10cSrcweir if ($l =~ /topic/) { 219cdf0e10cSrcweir ($id = $l) =~ s/^.*id="([^"]*)".*$/$1/gis; 220cdf0e10cSrcweir ($module = $id) =~ s/^([^\/]*).*$/$1/; 221cdf0e10cSrcweir $id =~ s/^.*?\///; 222cdf0e10cSrcweir $file = "$source_dir_xhp/$id"; 223cdf0e10cSrcweir 224*c6f2b4a8Smseidel if ($lng eq 'en-US') { # English comes from the file 225cdf0e10cSrcweir if (open F,$file) { 226cdf0e10cSrcweir print "."; 227cdf0e10cSrcweir undef $/; $cnt = <F>; close F; 228cdf0e10cSrcweir $cnt =~ s/^.*<title[^>]+id="tit"[^>]*>([^<]*)<\/title>.*$/$1/gis; 229cdf0e10cSrcweir $cnt =~ s/'/\'/gis; $cnt =~ s/&/+/gis; 230cdf0e10cSrcweir $cnt =~ s/"/\'/gis; $cnt =~ s/&/+/gis; 231cdf0e10cSrcweir $l = "<topic id=\"$module/$id\">$cnt</topic>\n"; 232cdf0e10cSrcweir } else { 233cdf0e10cSrcweir print "!"; 234cdf0e10cSrcweir $l = "<!-- removed $module/$id -->\n"; 235cdf0e10cSrcweir } 236cdf0e10cSrcweir } else { # localized comes from the localize sdf 237cdf0e10cSrcweir #print "\nid: $id"; 238cdf0e10cSrcweir if (defined($loc_title{$lng}->{$id})) { 239cdf0e10cSrcweir print "."; 240cdf0e10cSrcweir $l = "<topic id=\"$module/$id\">$loc_title{$lng}->{$id}</topic>\n"; 241cdf0e10cSrcweir } else { 242cdf0e10cSrcweir print "!"; 243cdf0e10cSrcweir } 244cdf0e10cSrcweir } 245cdf0e10cSrcweir } 246cdf0e10cSrcweir 247cdf0e10cSrcweir if ($l =~/<node/) { 248cdf0e10cSrcweir ($id = $l) =~ s/^.*id="(\d+)".*$/$1/gis; 249cdf0e10cSrcweir if ($lng eq 'en-US') { 250cdf0e10cSrcweir if (defined($node{$id})) { 251cdf0e10cSrcweir $l =~ s/title="(.*)"/title="$node{$id}"/; 252cdf0e10cSrcweir } else { 253cdf0e10cSrcweir $l =~ s/title="(.*)"/title="NOTFOUND:$id"/; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir } else { 256cdf0e10cSrcweir if (defined($node{$lng}->{$id})) { 257cdf0e10cSrcweir $l =~ s/title="(.*)"/title="$node{$lng}->{$id}"/; 258cdf0e10cSrcweir } 259cdf0e10cSrcweir } 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir if ($l =~/<help_section/) { 263cdf0e10cSrcweir ($id = $l) =~ s/^.*id="(\d+)".*$/$1/gis; 264cdf0e10cSrcweir if ($lng eq 'en-US') { 265cdf0e10cSrcweir if (defined($helpsection{$id})) { 266cdf0e10cSrcweir $l =~ s/title="(.*)"/title="$helpsection{$id}"/; 267cdf0e10cSrcweir } else { 268cdf0e10cSrcweir print "#"; 269cdf0e10cSrcweir $l =~ s/title="(.*)"/title="NOTFOUND:$id"/; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir } else { 272cdf0e10cSrcweir if (defined($helpsection{$lng}->{$id})) { 273cdf0e10cSrcweir $l =~ s/title="(.*)"/title="$helpsection{$lng}->{$id}"/; 274cdf0e10cSrcweir } 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir } 278cdf0e10cSrcweir if ( ! -d "$tree_dest/$lng" ) { 279cdf0e10cSrcweir mkdir "$tree_dest/$lng" or die "\nCouldn't create directory \"$tree_dest/$lng\""; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir my $treeoutdir = "$tree_dest/$lng"; 282cdf0e10cSrcweir my $tmpname_template=$tv."_XXXXX"; 283cdf0e10cSrcweir my ( $treetmpfilehandle, $treetmpfile ) = tempfile($tmpname_template , DIR => File::Spec->tmpdir() ); 284cdf0e10cSrcweir close $treetmpfilehandle ; 285cdf0e10cSrcweir if (open TV, ">$treetmpfile") { 286cdf0e10cSrcweir for $line(@lines) { 287cdf0e10cSrcweir $line =~ s/\$\[officename\]/%PRODUCTNAME/g; 288cdf0e10cSrcweir $line =~ s/\$\[officeversion\]/%PRODUCTVERSION/g; 289cdf0e10cSrcweir print TV $line; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir close TV; 292cdf0e10cSrcweir chmod 0664, $treetmpfile or &terminate("Cannot change rights on $treetmpfile"); 293cdf0e10cSrcweir if( $^O eq 'MSWin32' ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir $tree_dest =~ s/\//\\/g ; 296cdf0e10cSrcweir unlink "$tree_dest\\$lng\\$tv" ; 297cdf0e10cSrcweir mv $treetmpfile , "$tree_dest\\$lng\\$tv" or &terminate("Cannot mv $treetmpfile to $tree_dest\\$lng\\$tv" ); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir else 300cdf0e10cSrcweir { 301cdf0e10cSrcweir unlink "$tree_dest/$lng/$tv" ; 302cdf0e10cSrcweir my $ret=mv $treetmpfile , "$tree_dest/$lng/$tv$inpath" or &terminate("Cannot write to $tree_dest/$lng/$tv$inpath - Error $!"); 303cdf0e10cSrcweir my $ret=mv "$tree_dest/$lng/$tv$inpath" , "$tree_dest/$lng/$tv" or &terminate("Cannot write to $tree_dest/$lng/$tv - Error $!"); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } else { 306cdf0e10cSrcweir &terminate("Cannot write to $tvout"); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir } 309cdf0e10cSrcweir} 310cdf0e10cSrcweir 311cdf0e10cSrcweir#------------------------------------ 312cdf0e10cSrcweirsub readtv { 313cdf0e10cSrcweir my $f = shift; 314cdf0e10cSrcweir if (open TV, $f) { 315cdf0e10cSrcweir $/ = "\n"; 316cdf0e10cSrcweir my @l = <TV>; 317cdf0e10cSrcweir close TV; 318cdf0e10cSrcweir return @l; 319cdf0e10cSrcweir } else { 320cdf0e10cSrcweir &terminate("Error opening $f"); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir} 323cdf0e10cSrcweir 324cdf0e10cSrcweir#------------------------------------ 325cdf0e10cSrcweir# read entries form localize.sdf files 326cdf0e10cSrcweir#------------------------------------ 327cdf0e10cSrcweirsub read_loc { 328cdf0e10cSrcweir print "\n\nReading localized titles..."; 329cdf0e10cSrcweir $/ = "\n"; 330cdf0e10cSrcweir my $path = "$source_dir/text"; 331cdf0e10cSrcweir print " in $source_dir/text\n"; 332cdf0e10cSrcweir @files = `find $source_dir/text -name localize.sdf`; 333cdf0e10cSrcweir for my $fname (@files) { 334cdf0e10cSrcweir $FS = '\t'; 335cdf0e10cSrcweir print "."; 336cdf0e10cSrcweir open(LOCALIZE_SDF, $fname) || die 'Cannot open "localize.sdf".'."$fname"; 337cdf0e10cSrcweir while (<LOCALIZE_SDF>) { 338cdf0e10cSrcweir my $sdf_line = $_; 339cdf0e10cSrcweir my ($Fld1,$file,$Fld3,$Fld4,$id,$Fld6,$Fld7,$Fld8,$Fld9,$lang,$text) = split($FS, $sdf_line , 12); 340cdf0e10cSrcweir next if ( $Fld1 =~ /^#/); 341cdf0e10cSrcweir if ($id eq 'tit') { 342cdf0e10cSrcweir #strip filename 343cdf0e10cSrcweir $file =~ s/.*text\\/text\\/g; 344cdf0e10cSrcweir #convert \ to / in filename 345cdf0e10cSrcweir $file =~ s/\\/\//g; 346cdf0e10cSrcweir #fpe: i46823 - need to encode &s, added encoding 347cdf0e10cSrcweir $text =~ s/&(?!amp;)/&/g; 348cdf0e10cSrcweir # add entry to the hash 349cdf0e10cSrcweir $loc_title{$lang}->{$file} = $text; 350cdf0e10cSrcweir } 351cdf0e10cSrcweir if ($file =~ /tree_strings.xhp/) { 352cdf0e10cSrcweir #strip filename 353cdf0e10cSrcweir $file =~ s/.*text/text/g; 354cdf0e10cSrcweir #convert \ to / in filename 355cdf0e10cSrcweir $file =~ s/\\/\//g; 356cdf0e10cSrcweir if ($text =~ /^<help_section/) { 357cdf0e10cSrcweir #example: <help_section application="scalc" id="08" title="表計算ドキュメント"> 358cdf0e10cSrcweir my ($fld1,$app,$fld3,$id,$fld5,$sec_title) = split('"', $text, 7); 359cdf0e10cSrcweir #fpe: i46823 - need to encode &s, added encoding 360cdf0e10cSrcweir if( defined $sec_title ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir $sec_title =~ s/&(?!amp;)/&/g; 363cdf0e10cSrcweir #unquot \<item ... /\> 364cdf0e10cSrcweir terminate( "\n\nERROR: Bad string in file '$fname' will cause invalid xml tree file \n---\n'$sdf_line'\n---\nPlease remove or replace < = '<' and > = '>' within the title attribute '$sec_title'\n") , if( $sec_title =~ /[\<\>]/ ); 365cdf0e10cSrcweir $helpsection{$lang}->{$id} = $sec_title; 366cdf0e10cSrcweir } 367cdf0e10cSrcweir } elsif ($text =~/<node id=/) { 368cdf0e10cSrcweir # example: <node id="0205" title="Tabelas em documentos de texto"> 369cdf0e10cSrcweir # BEWARE: title may contain escaped '"' so only match " not preceded by \ 370cdf0e10cSrcweir # using a zero‐width negative look‐behind assertion. 371cdf0e10cSrcweir my ($fld1,$id,$fld3,$node_title,$Fld5) = split(/(?<!\\)"/, $text, 5); 372cdf0e10cSrcweir #fpe: i46823 - need to encode &s, added encoding 373cdf0e10cSrcweir if( defined $node_title ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir $node_title =~ s/&(?!amp;)/&/g; 376cdf0e10cSrcweir terminate( "\n\nERROR: Bad string in '$fname' will cause invalid xml tree file \n---\n'$sdf_line'\n---\nPlease remove or replace < = '<' and > = '>' within the title attribute '$node_title'\n") , if( $node_title =~ /[\<\>]/ ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir $node{$lang}->{$id} = $node_title; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir } 381cdf0e10cSrcweir } 382cdf0e10cSrcweir close LOCALIZE_SDF; 383cdf0e10cSrcweir } 384cdf0e10cSrcweir # statistics 385cdf0e10cSrcweir $total_elements=0; 386cdf0e10cSrcweir foreach $lang (keys %loc_title) { 387cdf0e10cSrcweir $no_elements = scalar(keys(%{$loc_title{$lang}})); 388cdf0e10cSrcweir push(@langstat, "$lang:\t ".$no_elements." matches\n"); 389cdf0e10cSrcweir $total_elements += $no_elements; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir print "\ndone reading a total of ".$total_elements." localized titles for ".scalar(keys(%loc_title))." languages from ".scalar @files ." files\n"; 392cdf0e10cSrcweir print sort(@langstat); 393cdf0e10cSrcweir} 394