diff options
author | wbolster <> | 2008-07-25 17:55:03 +0000 |
---|---|---|
committer | wbolster <> | 2008-07-25 17:55:03 +0000 |
commit | 0fb0dc678319fc940930a96a79c3bced2e020aad (patch) | |
tree | dd7cc89432d950f85dba2165ded902aaeea6285c /intltool-extract.in | |
parent | abf9f73f21510a8817a55d33775619fc3a8a57f3 (diff) | |
download | intltool-0fb0dc678319fc940930a96a79c3bced2e020aad.tar.gz |
2008-07-25 Wouter Bolsterlee <wbolster@svn.gnome.org>
reviewed by: Rodney Dawes <dobey.pwns@gmail.com>
* intltool-extract.in:
* intltool-merge.in:
* tests/cases/az.po:
* tests/cases/fr.po:
* tests/selftest.pl.in:
Bug 458794 – Context support works only for single
context on a msgid. Patch and test case by Dan Winship
<danw@gnome.org>.
Diffstat (limited to 'intltool-extract.in')
-rw-r--r-- | intltool-extract.in | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/intltool-extract.in b/intltool-extract.in index 403c856..0dd360a 100644 --- a/intltool-extract.in +++ b/intltool-extract.in @@ -47,6 +47,7 @@ my $VERSION_ARG = "0"; my $UPDATE_ARG = "0"; my $QUIET_ARG = "0"; my $SRCDIR_ARG = "."; +my $NOMSGCTXT_ARG = "0"; my $FILE; my $OUTFILE; @@ -76,6 +77,7 @@ GetOptions ( "update" => \$UPDATE_ARG, "quiet|q" => \$QUIET_ARG, "srcdir=s" => \$SRCDIR_ARG, + "nomsgctxt" => \$NOMSGCTXT_ARG, ) or &error; &split_on_argument; @@ -445,6 +447,11 @@ sub traverse $lookup =~ s/^\s+//s; $lookup =~ s/\s+$//s; } + if (exists $attrs->{"msgctxt"}) { + my $context = entity_decode ($attrs->{"msgctxt"}); + $context =~ s/^["'](.*)["']/$1/; + $lookup = "$context\004$lookup"; + } if ($lookup && $translate != 2) { $comments{$lookup} = $XMLCOMMENT if $XMLCOMMENT; @@ -833,6 +840,7 @@ sub msg_write { for my $message (@msgids) { my $offsetlines = 1; + my $context = undef; $offsetlines++ if $message =~ /%/; if (defined ($comments{$message})) { @@ -847,12 +855,30 @@ sub msg_write { if defined $comments{$message}; print OUT "/* xgettext:no-c-format */\n" if $message =~ /%/; + if ($message =~ /(.*)\004(.*)/) { + $context = $1; + $message = $2; + } my @lines = split (/\n/, $message, -1); for (my $n = 0; $n < @lines; $n++) { if ($n == 0) { - print OUT "char *s = N_(\""; + if (defined $context) + { + if ($NOMSGCTXT_ARG) + { + print OUT "char *s = N_(\"", $context, "|"; + } + else + { + print OUT "char *s = C_(\"", $context, "\", \""; + } + } + else + { + print OUT "char *s = N_(\""; + } } else { |