3 # Copyright (C) 2004 Rafael Beccar <rafael.beccar ! kdemail.net>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of version 2 of the GNU General
7 # Public License as published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public
15 # License along with this program; if not, write to the
16 # Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Author: Rafael Beccar <rafael.beccar ! kdemail.net>
22 # Bs.As. November 2004
24 # Automagically gen. localized highlighting for KTurtle commands
27 # ./i18n_highlighting.pl logokeywords.YOURLANG.xml
30 # ./i18n_highlighting.pl logokeywords.es.xml
33 # - You'll need logokeywords.YOURLANGCODE.xml under kturtle/scripts
35 # - The script search for logokeywords.en_US.xml under ../data/
36 # and writes the resulting files under current directory
49 #Give message if no parameter passed
51 die "Usage:\n ./i18n_highlighting.pl logokeywords.YOURLANG.xml";}
53 #Get the langcode we are translating to
55 if (/logokeywords.(\w+).xml/){
60 open EN_COMMANDS
, "<../data/logokeywords.en_US.xml"
61 or die "Cannot open ../data/logokeywords.en_US.xml";
63 while (<EN_COMMANDS
>){
64 if (/<keyword>(.*)<\/keyword
>/){
68 elsif (/<alias>(.*)<\/alias>/){
76 #Get commands for the given language
79 if (/<keyword>(.*)<\/keyword
>/){
80 $mylang_commands[$i]=$1;
81 $commands{$en_commands[$i]}=$mylang_commands[$i];
84 elsif (/<alias>(.*)<\/alias>/){
85 $mylang_commands[$i]=$1;
86 $commands{$en_commands[$i]}=$mylang_commands[$i];
91 #Remove brackets from @en_commands (they are not needed here)
92 #Brackets will be managed in a different way later
97 my $filename = "logohighlightstyle.${langcode}.xml";
100 #Parse logohighlightstyle.en_US.xml and generate the homologous for the given language
101 open HIGHLIGHT
,"<../data/logohighlightstyle.en_US.xml"
102 or die "Cannot open $_ \n";
106 open TRANSLATION
,">>$filename";
108 print "$`${langcode}$'";
110 #Manage translatable lines
111 elsif (m
%<item
> (\w
+) </item
>%){
113 $line = "\t<item> $commands{$1} </item>";}
114 open TRANSLATION
,">>$filename";
119 #Manage not translatable lines
121 open TRANSLATION
,">>$filename";
127 print "DONE... The translated file is:\n $filename \n";