Lines 116-127
sub text_replace (**) {
Link Here
|
116 |
} elsif ($s->has_js_data) { |
116 |
} elsif ($s->has_js_data) { |
117 |
for my $t (@{$s->js_data}) { |
117 |
for my $t (@{$s->js_data}) { |
118 |
# FIXME for this whole block |
118 |
# FIXME for this whole block |
119 |
if ($t->[0]) { |
119 |
if ($t->[0]) { |
120 |
printf $output "%s%s%s", $t->[2], find_translation $t->[3], |
120 |
my $to_print; |
121 |
$t->[2]; |
121 |
if ($t->[1] =~ /^(?:(?<startquote>")(?<startstring>(?:\\"|[^"])*)"|(?<startquote>')(?<startstring>(?:\\'|[^'])*)')(?<rest>(?:\s*\+\s*(?:(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*')|[A-Za-z_][A-Za-z0-9_]*))+)$/ig) { |
122 |
} else { |
122 |
my @vars; |
123 |
print $output $t->[1]; |
123 |
my $quote = $+{startquote}; |
124 |
} |
124 |
my $to_parse = $+{startquote}.$+{rest}; |
|
|
125 |
my $to_translate = $+{startstring}; |
126 |
while (1) { # Loop through and substitute all vars with '%s' |
127 |
if ($to_parse =~ /^$quote((?:\s*\+\s*[A-Za-z_][0-9A-Za-z_]*)\s*\+\s*)(?<nextquotes>['"])/isg) { # 1 var |
128 |
push @vars, "'".$1."'"; |
129 |
$quote = $+{nextquotes}; |
130 |
$to_parse = $quote.$'; |
131 |
$to_translate .= '%s'; |
132 |
} elsif ($to_parse =~ /^$quote((?:\s*\+\s*[A-Za-z_][0-9A-Za-z_]*){2,})\s*\+\s*(?<nextquotes>['"])/isg) { # 2+ vars |
133 |
$quote = $+{nextquotes}; |
134 |
$to_parse = $quote.$'; |
135 |
my @current_vars = split(/\s*\+\s*/,$1); |
136 |
shift(@current_vars); |
137 |
foreach my $var (@current_vars) { |
138 |
$var = "'+".$var."+'"; |
139 |
$to_translate .= '%s'; |
140 |
} |
141 |
push @vars, @current_vars; |
142 |
} elsif ($to_parse =~ /^$quote\s*\+\s*(?<nextquotes>['"])/is) { # plus between two strings |
143 |
$quote = $+{nextquotes}; |
144 |
$to_parse = $quote.$'; |
145 |
} elsif ($quote eq "'" && $to_parse =~ /^'(?<text>(?:\\'|[^'])*?)'/is) { # 'string' |
146 |
$to_parse = $quote.$'; |
147 |
$to_translate .= $+{text}; |
148 |
$to_translate =~ s/\\'/'/ig; |
149 |
} elsif ($quote eq "\"" && $to_parse =~ /^"(?<text>(?:\\"|[^"])*?)"/is) { # "string" |
150 |
$to_parse = $quote.$'; |
151 |
$to_translate .= $+{text}; |
152 |
$to_translate =~ s/\\"/"/ig; |
153 |
} else { |
154 |
last; |
155 |
} |
156 |
} |
157 |
$to_print = find_translation($to_translate); |
158 |
$to_print =~ s/'/\\'/ig; |
159 |
foreach my $substitute (@vars) { # Substitute all '%s' with vars |
160 |
$to_print =~ s/\%s/$substitute/i; |
161 |
} |
162 |
$t->[2] = "'"; |
163 |
} else { |
164 |
$to_print = find_translation($t->[3]); |
165 |
} |
166 |
printf $output "%s%s%s", $t->[2], $to_print, $t->[2]; |
167 |
} else { |
168 |
print $output $t->[1]; |
169 |
} |
125 |
} |
170 |
} |
126 |
} elsif (defined $t) { |
171 |
} elsif (defined $t) { |
127 |
# Quick fix to bug 4472 |
172 |
# Quick fix to bug 4472 |