Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 07d3f9e2

Von Moritz Bunkus vor etwa 19 Jahren hinzugefügt

  • ID 07d3f9e216ae112930a78dafaeef3cb10ee14236
  • Vorgänger 860f3274
  • Nachfolger 23e9c296

Den Parser in locaes.pl so erweitert, dass er auch $text->locale(...)-Funktionsaufrufe auswertet, die ueber mehrere Zeilen gehen. Das wurde durch die Verwendung von perltidy akut, das bei sehr langen Zeilen das Argument zu $text->locale() in eine eigene Zeile schreibt. Einige der dadurch neu/wieder gefundenen Ausdruecke uebersetzt bzw. deren urspruengliche Uebersetzung wiederhergestellt.

Unterschiede anzeigen:

locale/de/locales.pl
212 212

  
213 213
# eom
214 214

  
215
sub extract_text_between_parenthesis {
216
  my ($fh, $line) = @_;
217
  my ($inside_string, $pos, $text, $quote_next) = (undef, 0, "", 0);
218

  
219
  while (1) {
220
    if (length($line) <= $pos) {
221
      $line = <$fh>;
222
      return ($text, "") unless ($line);
223
      $pos = 0;
224
    }
225

  
226
    my $cur_char = substr($line, $pos, 1);
227

  
228
    if (!$inside_string) {
229
      if ((length($line) >= ($pos + 3)) && (substr($line, $pos, 2)) eq "qq") {
230
        $inside_string = substr($line, $pos + 2, 1);
231
        $pos += 2;
232

  
233
      } elsif ((length($line) >= ($pos + 2)) &&
234
               (substr($line, $pos, 1) eq "q")) {
235
        $inside_string = substr($line, $pos + 1, 1);
236
        $pos++;
237

  
238
      } elsif (($cur_char eq '"') || ($cur_char eq '\'')) {
239
        $inside_string = $cur_char;
240

  
241
      } elsif ($cur_char eq ")") {
242
        return ($text, substr($line, $pos + 1));
243
      }
244

  
245
    } else {
246
      if ($quote_next) {
247
        $text .= $cur_char;
248
        $quote_next = 0;
249

  
250
      } elsif ($cur_char eq '\\') {
251
        $text .= $cur_char;
252
        $quote_next = 1;
253

  
254
      } elsif ($cur_char eq $inside_string) {
255
        undef($inside_string);
256

  
257
      } else {
258
        $text .= $cur_char;
259

  
260
      }
261
    }
262
    $pos++;
263
  }
264
}
265

  
215 266
sub scanfile {
216 267
  my $file = shift;
217 268

  
......
262 313
        }
263 314
      }
264 315

  
265
      my ($found) = /\$locale->text.*?\W\)/;
316
      my ($found) = /\$locale->text.*?\(/;
266 317
      my $postmatch = $';
267 318

  
268 319
      if ($found) {
269
        my $string = $&;
270
        $string =~ s/\$locale->text\(\s*[\'\"(q|qq)][\'\/\\\|~]*//;
271
        $string =~ s/\W\)+.*$//;
320
        my $string;
321
        ($string, $_) = extract_text_between_parenthesis($fh, $postmatch);
322
        $postmatch = $_;
272 323

  
273 324
        # if there is no $ in the string record it
274
        unless ($string =~ /\$\D.*/) {
325
        unless (($string =~ /\$\D.*/) || ("" eq $string)) {
275 326

  
276 327
          # this guarantees one instance of string
277 328
          $locale{$string} = 1;

Auch abrufbar als: Unified diff