From c04f833db04defb9dac8227d1183fc49f15070c0 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 2 Sep 2009 17:38:36 +0200 Subject: [PATCH] Adding xsl strings to po xsl strings are now taken into account. This is a first draft. Some parameters of the functions will be taken into account and tags are not translated Signed-off-by: Galen Charlton --- misc/translator/TmplTokenizer.pm | 5 +++-- misc/translator/tmpl_process3.pl | 4 ++-- misc/translator/xgettext.pl | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/misc/translator/TmplTokenizer.pm b/misc/translator/TmplTokenizer.pm index 9d779b0dae..919a5d4e5b 100644 --- a/misc/translator/TmplTokenizer.pm +++ b/misc/translator/TmplTokenizer.pm @@ -39,7 +39,7 @@ use vars qw( $pedantic_error_markup_in_pcdata_p ); # Hideous stuff use vars qw( $re_directive $re_tmpl_var $re_tmpl_var_escaped $re_tmpl_include ); -use vars qw( $re_directive_control $re_tmpl_endif_endloop ); +use vars qw( $re_directive_control $re_tmpl_endif_endloop $re_xsl); BEGIN { # $re_directive must not do any backreferences $re_directive = q{<(?:(?i)(?:!--\s*)?\/?TMPL_(?:VAR|LOOP|INCLUDE|IF|ELSE|UNLESS)(?:\s+(?:[a-zA-Z][-a-zA-Z0-9]*=)?(?:'[^']*'|"[^"]*"|[^\s<>]+))*\s*(?:--)?)>}; @@ -47,6 +47,7 @@ BEGIN { $re_tmpl_var = q{<(?:(?i)(?:!--\s*)?TMPL_(?:VAR)(?:\s+(?:[a-zA-Z][-a-zA-Z0-9]*=)?(?:'[^']*'|"[^"]*"|[^\s<>]+))*\s*(?:--)?)>}; $re_tmpl_include = q{<(?:(?i)(?:!--\s*)?TMPL_(?:INCLUDE)(?:\s+(?:[a-zA-Z][-a-zA-Z0-9]*=)?(?:'[^']*'|"[^"]*"|[^\s<>]+))*\s*(?:--)?)>}; # TMPL_VAR ESCAPE=1/HTML/URL + $re_xsl = q{<\/?(?:xsl:)(?:[\s\-a-zA-Z0-9"'\/\.\[\]\@\(\):=,$]+)\/?>}; $re_tmpl_var_escaped = q{<(?:(?i)(?:!--\s*)?TMPL_(?:VAR|INCLUDE)(?:\s+(?:[a-zA-Z][-a-zA-Z0-9]*=)?(?:'[^']*'|"[^"]*"|[^\s<>]+))\s+ESCAPE=(?:1|HTML|URL)(?:\s+(?:[a-zA-Z][-a-zA-Z0-9]*=)?(?:'[^']*'|"[^"]*"|[^\s<>]+))*\s*(?:--)?)>}; # Any control flow directive $re_directive_control = q{<(?:(?i)(?:!--\s*)?\/?TMPL_(?:LOOP|IF|ELSE|UNLESS)(?:\s+(?:[a-zA-Z][-a-zA-Z0-9]*=)?(?:'[^']*'|"[^"]*"|[^\s<>]+))*\s*(?:--)?)>}; @@ -875,7 +876,7 @@ sub next_token { sub blank_p ($) { my($s) = @_; - return $s =~ /^(?:\s|\ $re_end_entity|$re_tmpl_var)*$/os; + return $s =~ /^(?:\s|\ $re_end_entity|$re_tmpl_var|$re_xsl)*$/os; } sub trim ($) { diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index a64c1424a6..b543a91c6d 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -54,7 +54,7 @@ sub text_replace_tag ($$) { if ($attr->{$a}) { next if $a eq 'content' && $tag ne 'meta'; next if $a eq 'value' && ($tag ne 'input' - || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|text)$/)); # FIXME + || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|text|submit)$/)); # FIXME my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME if ($val =~ /\S/s) { my $s = find_translation($val); @@ -218,7 +218,7 @@ usage_error('You must at least specify input and string list filenames.') if !@in_files || !defined $str_file; # Type match defaults to *.tmpl plus *.inc if not specified -$type = "tmpl|inc" if !defined($type); +$type = "tmpl|inc|js|xsl|def" if !defined($type); # Check the inputs for being files or directories for my $input (@in_files) { diff --git a/misc/translator/xgettext.pl b/misc/translator/xgettext.pl index 8d4d74c87e..996b952db6 100755 --- a/misc/translator/xgettext.pl +++ b/misc/translator/xgettext.pl @@ -7,6 +7,7 @@ xgettext.pl - xgettext(1)-like interface for .tmpl strings extraction =cut use strict; +use warnings; use Getopt::Long; use POSIX; use Locale::PO; @@ -101,7 +102,7 @@ sub text_extract (*) { if ($attr->{$a}) { next if $a eq 'content' && $tag ne 'meta'; next if $a eq 'value' && ($tag ne 'input' - || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio)$/)); # FIXME + || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|submit)$/)); # FIXME my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME $val = TmplTokenizer::trim $val; remember( $s, $val ) if $val =~ /\S/s; -- 2.39.5