From ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kturtle/scripts/i18n_highlighting.pl | 129 +++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 kturtle/scripts/i18n_highlighting.pl (limited to 'kturtle/scripts/i18n_highlighting.pl') diff --git a/kturtle/scripts/i18n_highlighting.pl b/kturtle/scripts/i18n_highlighting.pl new file mode 100755 index 00000000..463c364a --- /dev/null +++ b/kturtle/scripts/i18n_highlighting.pl @@ -0,0 +1,129 @@ +#!/usr/bin/perl -w + +# Copyright (C) 2004 Rafael Beccar +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General +# Public License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# Author: Rafael Beccar +# +# Bs.As. November 2004 +# +# Automagically gen. localized highlighting for KTurtle commands +# +# Usage: +# ./i18n_highlighting.pl logokeywords.YOURLANG.xml +# +# E.g. +# ./i18n_highlighting.pl logokeywords.es.xml +# +# NOTES: +# - You'll need logokeywords.YOURLANGCODE.xml under kturtle/scripts +# +# - The script search for logokeywords.en_US.xml under ../data/ +# and writes the resulting files under current directory +# + + +use strict; + +my $langcode; +my @en_commands; +my @mylang_commands; +my %commands; +my $i; +my $line; + +#Give message if no parameter passed +if (! $ARGV[0]){ + die "Usage:\n ./i18n_highlighting.pl logokeywords.YOURLANG.xml";} + +#Get the langcode we are translating to +$_ = $ARGV[0]; +if (/logokeywords.(\w+).xml/){ + $langcode = $1; + } + +#Get en_US commands +open EN_COMMANDS, "<../data/logokeywords.en_US.xml" + or die "Cannot open ../data/logokeywords.en_US.xml"; +$i=0; +while (){ + if (/(.*)<\/keyword>/){ + $en_commands[$i]=$1; + $i++; + } + elsif (/(.*)<\/alias>/){ + $en_commands[$i]=$1; + $i++; + } + } + +close EN_COMMANDS; + +#Get commands for the given language +$i=0; +while(<>){ + if (/(.*)<\/keyword>/){ + $mylang_commands[$i]=$1; + $commands{$en_commands[$i]}=$mylang_commands[$i]; + $i++; + } + elsif (/(.*)<\/alias>/){ + $mylang_commands[$i]=$1; + $commands{$en_commands[$i]}=$mylang_commands[$i]; + $i++; + } + } + +#Remove brackets from @en_commands (they are not needed here) +#Brackets will be managed in a different way later +shift @en_commands; +shift @en_commands; + +#Set destination +my $filename = "logohighlightstyle.${langcode}.xml"; + + +#Parse logohighlightstyle.en_US.xml and generate the homologous for the given language +open HIGHLIGHT,"<../data/logohighlightstyle.en_US.xml" + or die "Cannot open $_ \n"; +while (){ + #Manage language tag + if (m%(en_US)%){ + open TRANSLATION,">>$filename"; + select TRANSLATION; + print "$`${langcode}$'"; + select STDOUT;} + #Manage translatable lines + elsif (m% (\w+) %){ + if ($commands{$1}){ + $line = "\t $commands{$1} ";} + open TRANSLATION,">>$filename"; + select TRANSLATION; + print "$line \n"; + select STDOUT; + } + #Manage not translatable lines + else{ + open TRANSLATION,">>$filename"; + select TRANSLATION; + print "$_";} + select STDOUT; + } +close TRANSLATION; +print "DONE... The translated file is:\n $filename \n"; + + -- cgit v1.2.1