Lines 59-64
sub find_translation ($) {
Link Here
|
59 |
sub text_replace_tag ($$) { |
59 |
sub text_replace_tag ($$) { |
60 |
my($t, $attr) = @_; |
60 |
my($t, $attr) = @_; |
61 |
my $it; |
61 |
my $it; |
|
|
62 |
my @ttvar; |
62 |
|
63 |
|
63 |
# value [tag=input], meta |
64 |
# value [tag=input], meta |
64 |
my $tag = lc($1) if $t =~ /^<(\S+)/s; |
65 |
my $tag = lc($1) if $t =~ /^<(\S+)/s; |
Lines 71-82
sub text_replace_tag ($$) {
Link Here
|
71 |
|
72 |
|
72 |
my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME |
73 |
my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME |
73 |
if ($val =~ /\S/s) { |
74 |
if ($val =~ /\S/s) { |
74 |
my $s = find_translation($val); |
75 |
# for selected attributes replace '[%..%]' with '%s' and remember matches |
75 |
if ($attr->{$a}->[1] ne $s) { #FIXME |
76 |
if ( $a =~ /title|value|alt|content|placeholder/ ) { |
76 |
$attr->{$a}->[1] = $s; # FIXME |
77 |
while ( $val =~ s/(\[\%.*?\%\])/\%s/ ) { |
77 |
$attr->{$a}->[2] = ($s =~ /"/s)? "'$s'": "\"$s\""; #FIXME |
78 |
my $var = $1; |
78 |
$translated_p = 1; |
79 |
push @ttvar, $1; |
79 |
} |
80 |
} |
|
|
81 |
} |
82 |
# find translation for transformed attributes |
83 |
my $s = find_translation($val); |
84 |
# replace '%s' with original content (in order) on translated string, this is fragile! |
85 |
if ( $a =~ /title|value|alt|content|placeholder/ and @ttvar ) { |
86 |
while ( @ttvar ) { |
87 |
my $var = shift @ttvar; |
88 |
$s =~ s/\%s/$var/; |
89 |
} |
90 |
} |
91 |
if ($attr->{$a}->[1] ne $s) { #FIXME |
92 |
$attr->{$a}->[1] = $s; # FIXME |
93 |
$attr->{$a}->[2] = ($s =~ /"/s)? "'$s'": "\"$s\""; #FIXME |
94 |
$translated_p = 1; |
95 |
} |
80 |
} |
96 |
} |
81 |
} |
97 |
} |
82 |
} |
98 |
} |