summaryrefslogtreecommitdiffstats
path: root/kturtle/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'kturtle/scripts')
-rw-r--r--kturtle/scripts/README.scripts56
-rwxr-xr-xkturtle/scripts/i18n_examples.pl214
-rwxr-xr-xkturtle/scripts/i18n_highlighting.pl129
3 files changed, 399 insertions, 0 deletions
diff --git a/kturtle/scripts/README.scripts b/kturtle/scripts/README.scripts
new file mode 100644
index 00000000..2df17a38
--- /dev/null
+++ b/kturtle/scripts/README.scripts
@@ -0,0 +1,56 @@
+kturtle/scripts/
+this directory of the source version KTurtle contains two scripts that will make translating of KTurtle to other langauges much easier.
+
+When translating KTurtle more than just the usual 'documantation and strings' have to be translated, namely:
+- the examples (which are *.logo files),
+- the logokeyword.*.xml files, and
+- the logohighlightstyle.*.xml files.
+
+These files are called data files, and their English originals can be found in kdeedu/kturtle/data.
+For more information on these files and their translation read:
+kdeedu/kturtle/data/README.data
+
+In this directory you find Rafael Beccar's nifty tranlaton perl scripts that can make translating KTurtle human resourcefriendly.
+
+This is how these scripts work:
+
+But only logokeywords.YOURLANGCODE.xml needs to be under current directory..
+
+If everything is working fine the general process is something like:
+
+
+1. MANUALLY TRANSLATE THE KEYWORD
+Copy the logokeywords.en_US.xml file (from kdeedu/kturtle/data) to the kturtle directory in your branch of the kde-i18n module (for Dutch this would be: kde-i18n/nl/data/kdeedu/kturtle). Translate the file, and change the name to:
+logokeywords.YOURLANGCODE.xml
+
+
+2. AUTOMAGICALLY GENERATE THE HIGHLIGHTSTYLE FOR YOUR LANGUAGE
+- Copy logokeywords.YOURLANGCODE.xml to kdeedu/kturtle/scripts
+- change directory to kdeedu/kturtle/sripts, and run:
+./i18n_highlighting.pl logokeywords.YOURLANGCODE.xml
+- Now you have a translated logohighlightstyle.YOURLANGCODE.xml under current directory (kdeedu/kturtle/scripts)
+
+
+3. AUTOMAGICALLY GENERATE NEARLY FINISHED TRANSLATIONS OF THE EXAMPLES
+- change directory to kdeedu/kturtle/scripts, and run:
+./i18n_examples.pl logokeywords.YOURLANGCODE.xml
+- the translated examples can then be found in current directory. Some manual adjusments are
+needed, namely: the sings in the code and the comments
+
+
+4. LAST BUT NOT LEAST!!! CHECK IF EVERYTHING WORKS
+- move all the generated files to the kturtle directory in your branch of the kde-i18n module
+- check if it installs correctly
+- check if the fresh logo examples in your language run when KTurtle is set to your language (see the Settings)
+
+
+Please report BUGs when it doesnt work (bugs.kde.org)!
+
+Thanks for the efford, we love you!
+
+
+
+
+
+
+
diff --git a/kturtle/scripts/i18n_examples.pl b/kturtle/scripts/i18n_examples.pl
new file mode 100755
index 00000000..36115ea8
--- /dev/null
+++ b/kturtle/scripts/i18n_examples.pl
@@ -0,0 +1,214 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2004-2005 Rafael Beccar <rafael.beccar ! kdemail.net>
+#
+# 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 <rafael.beccar ! kdemail.net>
+#
+# Bs.As. November 2004
+#
+# Automagically generate localized KTurtle logo code.
+#
+# Usage: ./i18n_examples.pl logokeywords.YOURLANGCODE.xml
+#
+# e.g.:
+# $./i18n_examples.pl logokeywords.es.xml
+#
+# arrow.logo -> arrow.es.LOGO
+# canvascolors.logo -> canvascolors.es.LOGO
+# curly.logo -> curly.es.LOGO
+#
+# NOTES:
+# - You'll need logokeywords.YOURLANGCODE.xml under kturtle/scripts
+# - Commented lines, variable names, and strings like
+# "What's your name?" must be translated by hand.
+# - You might want to rename the resulting files to something
+# into your own language e.g. arrow.es.LOGO to flecha.LOGO
+# - Please, if the script is not working for you report it to
+# KDE-Edu mailing list.
+#
+
+
+use strict;
+
+my @en_commands;
+my $langcode;
+my @mylang_commands;
+my %commands;
+my $i;
+my @examples= glob "../data/*.logo";
+my $filename;
+my $line;
+
+
+#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 logokeywords.en_US.xml";
+$i=0;
+while (<EN_COMMANDS>){
+ if (/<keyword>(.*)<\/keyword>/){
+ $en_commands[$i]=$1;
+ $i++;
+ }
+ elsif (/<alias>(.*)<\/alias>/){
+ $en_commands[$i]=$1;
+ $i++;
+ }
+ }
+
+close EN_COMMANDS;
+
+#Get commands for the given language
+$i=0;
+while(<>){
+ if (/<keyword>(.*)<\/keyword>/){
+ $mylang_commands[$i]=$1;
+ $commands{$en_commands[$i]}=$mylang_commands[$i];
+ $i++;
+ }
+ elsif (/<alias>(.*)<\/alias>/){
+ $mylang_commands[$i]=$1;
+ $commands{$en_commands[$i]}=$mylang_commands[$i];
+ $i++;
+ }
+
+ }
+
+
+#Remove brackets from @en_commands (they aren't needed here)
+#Brackets will be managed in a different way later
+shift @en_commands;
+shift @en_commands;
+
+
+#Parse *.logo and generate the homologous for the given language
+foreach (@examples){
+ if (m%^../data/(\w+).logo%){$filename="$1".".$langcode."."logo";}
+ else{die "Error: Check if you have ../data/*.logo files";}
+ printf "\n%-25s > ./%s \n", $_, $filename;
+ open EXAMPLE,"<$_"
+ or die "Cannot open $_ \n";
+ while (<EXAMPLE>){
+ #Manage comments (they do not get translated)
+ if (/^#(.*)/){
+ open TRANSLATION,">>$filename";
+ select TRANSLATION;
+ print "#$1\n";
+ select STDOUT;}
+ #Manage tabulated "for .. to .." lines
+ elsif (/(^\s+)(\bfor\b)(.*)(\bto\b)/){
+ chomp ($line = "$1$commands{$2}$3$commands{$4}$'");
+ open TRANSLATION, ">>$filename";
+ select TRANSLATION;
+ print "$line \n";
+ select STDOUT;}
+ #Manage tabulated brackets
+ elsif (/(^\s+)(\p{IsPunct})/){
+ open TRANSLATION,">>$filename";
+ select TRANSLATION;
+ print "$1$2\n";
+ select STDOUT;}
+ #Manage any other tabulated line
+ elsif (/(^\s+)(\w+)/){
+ my $tab=$1;
+ if ($commands{$2}){
+ chomp ($line = "$commands{$2}$'");
+ }
+ elsif (/([=])(\s+)(\w+)/){
+ if ($commands{$3}){
+ $tab="";
+ chomp ($line = "$`$1$2$commands{$3}$'");
+ }
+ }
+ elsif (/([=])(\w+)/){
+ if ($commands{$2}){
+ chomp ($line = "$`$1$commands{$2}$'");
+ }
+ }
+ else
+ {
+ chomp ($line = "$2$'");
+ }
+ open TRANSLATION,">>$filename";
+ select TRANSLATION;
+ print "$tab$line\n";
+ select STDOUT;}
+ #Manage "for .. to .." lines
+ elsif (/(^\bfor\b)(.*)(\bto\b)/){
+ chomp (my $line = "$commands{$1}$2$commands{$3}$'");
+ open TRANSLATION, ">>$filename";
+ select TRANSLATION;
+ print "$line\n";
+ select STDOUT;}
+ #Manage any other line of code
+ elsif (/(^\w+)/){
+ if ($commands{$&}){
+ chomp ($line = "$commands{$&}$'");
+ }
+ elsif (/([=])(\s+)(\w+)/){
+ if ($commands{$3}){
+ chomp ($line = "$`$1$2$commands{$3}$'");
+ }
+ }
+ elsif (/([=])(\w+)/){
+ if ($commands{$2}){
+ chomp ($line = "$`$1$commands{$2}$'");
+ }
+ }
+ else{
+ chomp ($line = "$1$'");
+ }
+ open TRANSLATION, ">>$filename";
+ select TRANSLATION;
+ print "$line \n";
+ select STDOUT;
+ }
+ #Manage brackets
+ elsif (/\p{IsPunct}/){
+ open TRANSLATION,">>$filename";
+ select TRANSLATION;
+ print "$&\n";
+ select STDOUT;}
+ #Manage empty lines
+ elsif (/^\s+/){
+ open TRANSLATION,">>$filename";
+ select TRANSLATION;
+ print "\n";
+ select STDOUT;}
+
+ }
+ }
+
+print <<EOF;
+
+The translation of KTurtle examples is almost DONE...
+You will need to translate the following by hand:
+1) Commented lines,
+2) Variable names (if any of them is named in english or represents a reserved word in your language),
+3) Strings like "What's your name?"
+4) File names
+
+Thanks a lot!
+
+EOF
+
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 <rafael.beccar ! kdemail.net>
+#
+# 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 <rafael.beccar ! kdemail.net>
+#
+# 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 (<EN_COMMANDS>){
+ if (/<keyword>(.*)<\/keyword>/){
+ $en_commands[$i]=$1;
+ $i++;
+ }
+ elsif (/<alias>(.*)<\/alias>/){
+ $en_commands[$i]=$1;
+ $i++;
+ }
+ }
+
+close EN_COMMANDS;
+
+#Get commands for the given language
+$i=0;
+while(<>){
+ if (/<keyword>(.*)<\/keyword>/){
+ $mylang_commands[$i]=$1;
+ $commands{$en_commands[$i]}=$mylang_commands[$i];
+ $i++;
+ }
+ elsif (/<alias>(.*)<\/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 (<HIGHLIGHT>){
+ #Manage language tag
+ if (m%(en_US)%){
+ open TRANSLATION,">>$filename";
+ select TRANSLATION;
+ print "$`${langcode}$'";
+ select STDOUT;}
+ #Manage translatable lines
+ elsif (m%<item> (\w+) </item>%){
+ if ($commands{$1}){
+ $line = "\t<item> $commands{$1} </item>";}
+ 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";
+
+