aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKjartan Maraas <kmaraas@src.gnome.org>2000-11-30 22:10:37 +0800
committerKjartan Maraas <kmaraas@src.gnome.org>2000-11-30 22:10:37 +0800
commit5fab333def88cfc41fcb18b11d1f31ce6d6e3019 (patch)
tree3a6cf7f728012a6a33181f1d3deafec456e767e1
parent6fca25a61dc5f5d111c36b7e3704850d73541923 (diff)
downloadgsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.tar
gsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.tar.gz
gsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.tar.bz2
gsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.tar.lz
gsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.tar.xz
gsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.tar.zst
gsoc2013-evolution-5fab333def88cfc41fcb18b11d1f31ce6d6e3019.zip
Put back the non-modified version of the tools
svn path=/trunk/; revision=6735
-rwxr-xr-xpo/ui-extract.pl110
-rwxr-xr-xpo/update.pl2
2 files changed, 77 insertions, 35 deletions
diff --git a/po/ui-extract.pl b/po/ui-extract.pl
index 602649c8de..9eb96497b6 100755
--- a/po/ui-extract.pl
+++ b/po/ui-extract.pl
@@ -23,37 +23,38 @@
#
+## Release information
+my $VERSION = "0.9.5";
-use strict;
+## Script options - Enable by setting value to 1
+my $ENABLE_GLADE = "1";
+my $ENABLE_XML = "1";
+my $ENABLE_XP = "0";
+
+## Loaded modules
+use strict;
use File::Basename;
use Getopt::Long;
-#---------------------------
-
-my $VERSION = "0.8.5";
-
-#---------------------------
-
+## Scalars used by the option stuff
my $LOCAL_ARG = "0";
my $HELP_ARG = "0";
my $VERSION_ARG = "0";
my $UPDATE_ARG = "0";
-#---------------------------
my $FILE;
my $OUTFILE;
-#---------------------------
-
-my %string = ();
+my %string = ();
my @elements;
+my @items;
my $n;
-#---------------------------
-
+## Always print first
$| = 1;
+## Handle options
GetOptions (
"local|l" => \$LOCAL_ARG,
"help|h|?" => \$HELP_ARG,
@@ -64,10 +65,8 @@ GetOptions (
&SplitOnArgument;
-#---------------------------------------------------
-# Check for options.
-# This section will check for the different options.
-#---------------------------------------------------
+## Check for options.
+## This section will check for the different options.
sub SplitOnArgument {
@@ -114,7 +113,13 @@ sub PlaceLocal {
}
-#-------------------
+sub PreCheck {
+ if (! $ENABLE_XML) { if ($FILE =~ /xml$/sg) { &WriteError; }}
+ if (! $ENABLE_GLADE) { if ($FILE =~ /glade$/sg) { &WriteError; }}
+ if (! $ENABLE_XP) { if ($FILE =~ /\/xp\/(.*)\.h$/sg) { &WriteError; }}
+}
+
+## Sub for printing release information
sub Version{
print "The XML UI Translations Extractor $VERSION\n";
print "Written by Kenneth Christiansen, 2000.\n\n";
@@ -124,7 +129,7 @@ sub Version{
exit;
}
-#-------------------
+## Sub for printing usage information
sub Help{
print "Usage: ui-extract.pl [FILENAME] [OPTIONS] ...\n";
print "Generates a headerfile from an xml source.\n\nGraps all strings ";
@@ -136,7 +141,7 @@ sub Help{
exit;
}
-#-------------------
+## Sub for printing error messages
sub Error{
# print "ui-extract: invalid option @ARGV\n";
print "Try `ui-extract.pl --help' for more information.\n";
@@ -144,11 +149,12 @@ sub Error{
}
sub Message {
- print "Generating headerfile for XML translation.\n";
+ print "Generating headerfile for translation.\n";
}
sub Preparation {
+ &PreCheck;
if (-s "$OUTFILE"){
unlink "$OUTFILE";
}
@@ -156,21 +162,24 @@ sub Preparation {
&Convert ($FILE);
}
+sub WriteError {
+ # print "Could not generate $FILE.h\n";
+ exit;
+}
+
sub WriteFile {
open OUT, ">>$OUTFILE";
+ if (! %string) { &WriteError; }
&addMessages;
close OUT;
print "Wrote $OUTFILE\n";
}
-#-------------------
sub Convert($) {
- #-----------------
- # Reading the file
- #-----------------
+ ## Reading the file
my $input; {
local (*IN);
local $/; #slurp mode
@@ -183,13 +192,16 @@ sub Convert($) {
print OUT "/*\n";
print OUT " * Translatable strings file generated by extract-ui.\n";
- print OUT " * Add this file to your project's POTFILES.in\n";
- print OUT " * DO NOT compile it as part of your application.\n";
+ print OUT " * DO NOT compile this file as part of your application.\n";
print OUT " */\n\n";
}
close OUT;
+##################
+if ($ENABLE_XML) {
+##################
+
### For generic translatable XML files ###
if ($FILE =~ /xml$/sg){
@@ -197,16 +209,22 @@ sub Convert($) {
$string{$1} = [];
}
- while ($input =~ /<_[a-zA-Z0-9_]+>(..[^_]*)<\/_[a-zA-Z0-9_]+>/sg) {
+ while ($input =~ /<_[a-zA-Z0-9_]+>([^_]+)<\/_[a-zA-Z0-9_]+>/sg) {
$string{$1} = [];
}}
+}
+####################
+if ($ENABLE_GLADE) {
+####################
+
### For translatable Glade XML files ###
if ($FILE =~ /glade$/sg){
- my $translate = "label|items|title|text|format|copyright|comments|preview_text|tooltip";
+ my $translate = "label|title|text|format|copyright|comments|
+ preview_text|tooltip";
- while ($input =~ /<($translate)>(..[^<]*)<\/($translate)>/sg) {
+ while ($input =~ /<($translate)>([^<]+)<\/($translate)>/sg) {
# Glade has some bugs, especially it uses translations tags to contain little
# non-translatable content. We work around this, by not including these
@@ -215,13 +233,36 @@ sub Convert($) {
} else {
$string{$2} = [];
}
+ }
+
+ while ($input =~ /<items>(..[^<]*)<\/items>/sg) {
+ @items = split (/\n/, $1);
+ for ($n = 0; $n < @items; $n++) {
+ $string{$items[$n]} = [];
+ }
+ }}
+}
+
+#################
+if ($ENABLE_XP) {
+#################
+
+ ### For generic translatable XP header files ###
+
+ if ($FILE =~ /\/xp\/(.*)\.h$/sg){
+ while ($input =~ /\((.*),(.+)\"(.*)\"/g) {
+ my $tag = $1;
+ $string{$3} = [$tag];
}}
+
}
+}
sub addMessages{
- foreach my $theMessage (sort keys %string) {
- my ($lineNo,$fileName) = @{ $string{$theMessage} };
+ foreach my $theMessage (sort keys %string) {
+
+ my ($tag) = @{ $string{$theMessage} };
# Replace XML codes for special chars to
# geniune gettext syntax
@@ -235,7 +276,7 @@ sub addMessages{
@elements = split (/\n/, $theMessage);
for ($n = 0; $n < @elements; $n++) {
- if ($n == 0) {
+ if ($n == 0) {
print OUT "gchar *s = N_";
print OUT "(\"$elements[$n]\\n\"\n";
}
@@ -252,7 +293,8 @@ sub addMessages{
}
} else {
-
+
+ if ($tag) { print OUT "/* $tag */\n"; }
print OUT "gchar *s = N_(\"$theMessage\");\n";
}
diff --git a/po/update.pl b/po/update.pl
index c7c86399df..2b6accb302 100755
--- a/po/update.pl
+++ b/po/update.pl
@@ -314,7 +314,7 @@ sub GeneratePot{
unlink(".headerlock");
print "Removing generated header (.h) files...";
-# system("rm ./tmp/ -rf");
+ system("rm ./tmp/ -rf");
}
print "done\n";
}