~ubuntu-branches/debian/experimental/intltool/experimental

« back to all changes in this revision

Viewing changes to intltool-merge.in

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge, Josselin Mouette, Sebastian Dröge
  • Date: 2008-07-27 11:46:44 UTC
  • mfrom: (1.3.2 upstream) (4.1.19 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080727114644-emlk8gm2hrzv1xo9
Tags: 0.40.3-1
[ Josselin Mouette ]
* Depend on automake instead of automake1.7. Closes: #491360.

[ Sebastian Dröge ]
* New upstream bugfix release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
441
441
    &create_cache;
442
442
}
443
443
 
 
444
sub add_translation
 
445
{
 
446
    my ($lang, $msgctxt, $msgid, $msgstr) = @_;
 
447
 
 
448
    return if !($msgid && $msgstr);
 
449
 
 
450
    if ($msgctxt) {
 
451
        $msgid = "$msgctxt\004$msgid";
 
452
    }
 
453
    $translations{$lang, $msgid} = $msgstr;
 
454
}
 
455
 
444
456
sub create_translation_database
445
457
{
446
458
    for my $lang (keys %po_files_by_lang) 
468
480
        }
469
481
 
470
482
        my $nextfuzzy = 0;
 
483
        my $inmsgctxt = 0;
471
484
        my $inmsgid = 0;
472
485
        my $inmsgstr = 0;
 
486
        my $msgctxt = "";
473
487
        my $msgid = "";
474
488
        my $msgstr = "";
475
489
 
477
491
        {
478
492
            $nextfuzzy = 1 if /^#, fuzzy/;
479
493
       
 
494
            if (/^msgctxt "((\\.|[^\\]+)*)"/ ) 
 
495
            {
 
496
                if ($inmsgstr) {
 
497
                    add_translation ($lang, $msgctxt, $msgid, $msgstr);
 
498
                    $msgctxt = "";
 
499
                    $msgid = "";
 
500
                    $msgstr = "";
 
501
                }
 
502
 
 
503
                $msgctxt = unescape_po_string($1);
 
504
                $inmsgctxt = 1;
 
505
                $inmsgid = 0;
 
506
                $inmsgstr = 0;
 
507
            }
 
508
 
480
509
            if (/^msgid "((\\.|[^\\]+)*)"/ ) 
481
510
            {
482
 
                $translations{$lang, $msgid} = $msgstr if $inmsgstr && $msgid && $msgstr;
483
 
                $msgid = "";
484
 
                $msgstr = "";
 
511
                if ($inmsgstr) {
 
512
                    add_translation ($lang, $msgctxt, $msgid, $msgstr);
 
513
                    $msgctxt = "";
 
514
                    $msgid = "";
 
515
                    $msgstr = "";
 
516
                }
485
517
 
486
518
                if ($nextfuzzy) {
487
519
                    $inmsgid = 0;
 
520
                    $nextfuzzy = 0;
488
521
                } else {
489
522
                    $msgid = unescape_po_string($1);
490
523
                    $inmsgid = 1;
491
524
                }
 
525
                $inmsgctxt = 0;
492
526
                $inmsgstr = 0;
493
 
                $nextfuzzy = 0;
494
527
            }
495
528
 
496
529
            if (/^msgstr "((\\.|[^\\]+)*)"/) 
497
530
            {
498
531
                $msgstr = unescape_po_string($1);
499
532
                $inmsgstr = 1;
 
533
                $inmsgctxt = 0;
500
534
                $inmsgid = 0;
501
535
            }
502
536
 
503
537
            if (/^"((\\.|[^\\]+)*)"/) 
504
538
            {
 
539
                $msgctxt .= unescape_po_string($1) if $inmsgctxt;
505
540
                $msgid .= unescape_po_string($1) if $inmsgid;
506
541
                $msgstr .= unescape_po_string($1) if $inmsgstr;
507
542
            }
814
849
 
815
850
        print $fh "<$nodename", $outattr;
816
851
        if ($translate) {
817
 
            $lookup = getXMLstring($content, $spacepreserve);
 
852
            $content = getXMLstring($content, $spacepreserve);
818
853
            if (!$spacepreserve) {
819
 
                $lookup =~ s/^\s+//s;
820
 
                $lookup =~ s/\s+$//s;
 
854
                $content =~ s/^\s+//s;
 
855
                $content =~ s/\s+$//s;
 
856
            }
 
857
            if (exists $attrs->{"msgctxt"}) {
 
858
                my $context = entity_decode ($attrs->{"msgctxt"});
 
859
                $context =~ s/^["'](.*)["']/$1/;
 
860
                $lookup = "$context\004$content";
 
861
            } else {
 
862
                $lookup = $content;
821
863
            }
822
864
 
823
865
            if ($lookup || $translate == 2) {
824
866
                my $translation = $translations{$language, $lookup} if isWellFormedXmlFragment($translations{$language, $lookup});
825
867
                if ($MULTIPLE_OUTPUT && ($translation || $translate == 2)) {
826
 
                    $translation = $lookup if (!$translation);
 
868
                    $translation = $content if (!$translation);
827
869
                    print $fh " xml:lang=\"", $language, "\"" if $language;
828
870
                    print $fh ">";
829
871
                    if ($translate == 2) {
840
882
                    if ($translate == 2) {
841
883
                        translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
842
884
                    } else {
843
 
                        print $fh $lookup;
 
885
                        print $fh $content;
844
886
                    }
845
887
                    print $fh "</$nodename>";
846
888
                }
859
901
                        my $localattrs = getAttributeString($attrs, 1, $lang, \$translate);
860
902
                        my $translation = $translations{$lang, $lookup} if isWellFormedXmlFragment($translations{$lang, $lookup});
861
903
                        if ($translate && !$translation) {
862
 
                            $translation = $lookup;
 
904
                            $translation = $content;
863
905
                        }
864
906
 
865
907
                        if ($translation || $translate) {