View | Details | Raw Unified | Return to bug 10492
Collapse All | Expand All

(-)a/misc/translator/tmpl_process3.pl (-6 / +22 lines)
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
    }
(-)a/misc/translator/xgettext.pl (-1 / +5 lines)
Lines 124-129 sub text_extract { Link Here
124
                        || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|checkbox)$/)); # FIXME
124
                        || (ref $attr->{'type'} && $attr->{'type'}->[1] =~ /^(?:hidden|radio|checkbox)$/)); # FIXME
125
                    my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
125
                    my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
126
                    $val = TmplTokenizer::trim $val;
126
                    $val = TmplTokenizer::trim $val;
127
                    # for selected attributes replace '[%..%]' with '%s' globally
128
                    if ( $a =~ /title|value|alt|content|placeholder/ ) {
129
                        $val =~ s/\[\%.*?\%\]/\%s/g;
130
                    }
131
                    # save attribute text for translation
127
                    remember( $s, $val ) if $val =~ /\S/s;
132
                    remember( $s, $val ) if $val =~ /\S/s;
128
                }
133
                }
129
            }
134
            }
130
- 

Return to bug 10492