diff options
author | David Planella <david.planella@ubuntu.com> | 2013-01-28 00:45:01 +0100 |
---|---|---|
committer | David Planella <david.planella@ubuntu.com> | 2013-01-28 00:45:01 +0100 |
commit | bdc3acd8ac486617245d9bb4de7d5f4e801e4ebe (patch) | |
tree | 4d34a5f1eb2c50884a7cf43eea2adf21ab38de25 /intltool-extract.in | |
parent | 9c69b7fc7966f92a1da20e8a18abcf1ebff6c97e (diff) | |
download | intltool-bdc3acd8ac486617245d9bb4de7d5f4e801e4ebe.tar.gz |
Cleaned up qtdesigner code, added comments, updated test case and results
Diffstat (limited to 'intltool-extract.in')
-rw-r--r-- | intltool-extract.in | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/intltool-extract.in b/intltool-extract.in index 33bb447..610b5e3 100644 --- a/intltool-extract.in +++ b/intltool-extract.in @@ -840,19 +840,40 @@ sub type_qtdesigner { # extracomment maps to a developer comment in gettext # comment corresponds to "disambiguation" in the Qt Linguist API, and maps # to msgctxt in gettext + # + # Example: + # + # <string comment="Button" extracomment="TRANSLATORS: refers to the + # action of accepting something">Ok</string> + + # Read all <string> tags one by one and extract the translatable messages + # within them + while ($input =~ /<string + (?:\s+[^>]*notr\s*=\s*"([^"]*)")? + (?:\s+[^>]*\bcomment\b\s*=\s*"([^"]*)")? + (?:\s+[^>]*extracomment\s*=\s*"([^"]*)")? + [^>]*>([^<]+) + <\/string>/xsg) { + + # Skip string if notr="true" (i.e. string marked as non-translatable) + if (defined($1) && $1 eq "true") { + next; + } - # $1 $2 $3 $4 - while ($input =~ /<string(?:\s+[^>]*notr\s*=\s*"([^"]*)")?(?:\s+[^>]*\bcomment\b\s*=\s*"([^"]*)")?(?:\s+[^>]*extracomment\s*=\s*"([^"]*)")?[^>]*>([^<]+)<\/string>/sg) { - if (defined($1)){ - next; - } + # Read translatable message my $message = entity_decode($4); + + # Add msgctxt to the translatable message if present if (defined($2)) { $message = entity_decode($2) . "\004" . $message; } + + # Add message to the array of translatable messages (msgids) add_message($message); + + # Add developer comment to the comments hash if (defined($3)) { - $comments{$message} = entity_decode($3) ; + $comments{$message} = entity_decode($3); } } } |