diff options
author | Daiki Ueno <ueno@gnu.org> | 2014-05-31 11:28:39 +0900 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2014-05-31 14:56:52 +0900 |
commit | 3a78eca9e7bd70521a0f64657b4c5904797927df (patch) | |
tree | 73061803fae529755ff55b9039e6aafe72fcc5cf /gettext-tools | |
parent | ce27989475881c28198c436ddb9855bdf0645e7f (diff) | |
download | external_gettext-3a78eca9e7bd70521a0f64657b4c5904797927df.zip external_gettext-3a78eca9e7bd70521a0f64657b4c5904797927df.tar.gz external_gettext-3a78eca9e7bd70521a0f64657b4c5904797927df.tar.bz2 |
msgfilter: Pass previous msgid to the child process
Suggested by Pavel Kharitonov in:
<http://lists.gnu.org/archive/html/bug-gettext/2014-05/msg00022.html>.
* msgfilter.c (process_message): Set MSGFILTER_PREV_* envvar.
Diffstat (limited to 'gettext-tools')
-rw-r--r-- | gettext-tools/doc/ChangeLog | 6 | ||||
-rw-r--r-- | gettext-tools/doc/msgfilter.texi | 8 | ||||
-rw-r--r-- | gettext-tools/src/ChangeLog | 7 | ||||
-rw-r--r-- | gettext-tools/src/msgfilter.c | 12 | ||||
-rw-r--r-- | gettext-tools/tests/ChangeLog | 5 | ||||
-rwxr-xr-x | gettext-tools/tests/msgfilter-6 | 20 |
6 files changed, 55 insertions, 3 deletions
diff --git a/gettext-tools/doc/ChangeLog b/gettext-tools/doc/ChangeLog index 5f236dd..257b46d 100644 --- a/gettext-tools/doc/ChangeLog +++ b/gettext-tools/doc/ChangeLog @@ -1,3 +1,9 @@ +2014-05-31 Daiki Ueno <ueno@gnu.org> + + * msgfilter.texi: Document the environment variable + MSGFILTER_PREV_MSGCTXT, MSGFILTER_PREV_MSGID, and + MSGFILTER_PREV_MSGID_PLURAL. + 2014-05-15 Stanislav Brabec <sbrabec@suse.cz> (tiny change) * msgfilter.texi: Document the environment variable diff --git a/gettext-tools/doc/msgfilter.texi b/gettext-tools/doc/msgfilter.texi index 22fbab7..1fae251 100644 --- a/gettext-tools/doc/msgfilter.texi +++ b/gettext-tools/doc/msgfilter.texi @@ -13,6 +13,9 @@ translation catalog. @vindex MSGFILTER_MSGID_PLURAL@r{, environment variable} @vindex MSGFILTER_LOCATION@r{, environment variable} @vindex MSGFILTER_PLURAL_FORM@r{, environment variable} +@vindex MSGFILTER_PREV_MSGCTXT@r{, environment variable} +@vindex MSGFILTER_PREV_MSGID@r{, environment variable} +@vindex MSGFILTER_PREV_MSGID_PLURAL@r{, environment variable} During each @var{filter} invocation, the environment variable @code{MSGFILTER_MSGID} is bound to the message's msgid, and the environment variable @code{MSGFILTER_LOCATION} is bound to the location in the PO file @@ -22,6 +25,11 @@ unbound. If the message has a plural form, environment variable @code{MSGFILTER_MSGID_PLURAL} is bound to the message's msgid_plural and @code{MSGFILTER_PLURAL_FORM} is bound to the order number of the plural actually processed (starting with 0), otherwise both are unbound. +If the message has a previous msgid (added by @code{msgmerge}), +environment variable @code{MSGFILTER_PREV_MSGCTXT} is bound to the +message's previous msgctxt, @code{MSGFILTER_PREV_MSGID} is bound to +the previous msgid, and @code{MSGFILTER_PREV_MSGID_PLURAL} is bound to +the previous msgid_plural. @subsection Input file location diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 596e3a5..8247050 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2014-05-31 Daiki Ueno <ueno@gnu.org> + + msgfilter: Pass previous msgid to the child process + Suggested by Pavel Kharitonov in: + <http://lists.gnu.org/archive/html/bug-gettext/2014-05/msg00022.html>. + * msgfilter.c (process_message): Set MSGFILTER_PREV_* envvar. + 2014-05-19 Daiki Ueno <ueno@gnu.org> * Makefile.am (po-gram-gen2.h): Adjust the directory to which diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c index f172a45..961b1f1 100644 --- a/gettext-tools/src/msgfilter.c +++ b/gettext-tools/src/msgfilter.c @@ -671,6 +671,18 @@ process_message (message_ty *mp) (long) mp->pos.line_number); xsetenv ("MSGFILTER_LOCATION", location, 1); free (location); + if (mp->prev_msgctxt != NULL) + xsetenv ("MSGFILTER_PREV_MSGCTXT", mp->prev_msgctxt, 1); + else + unsetenv ("MSGFILTER_PREV_MSGCTXT"); + if (mp->prev_msgid != NULL) + xsetenv ("MSGFILTER_PREV_MSGID", mp->prev_msgid, 1); + else + unsetenv ("MSGFILTER_PREV_MSGID"); + if (mp->prev_msgid_plural != NULL) + xsetenv ("MSGFILTER_PREV_MSGID_PLURAL", mp->prev_msgid_plural, 1); + else + unsetenv ("MSGFILTER_PREV_MSGID_PLURAL"); /* Count NUL delimited substrings. */ for (p = msgstr, nsubstrings = 0; diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 4eb30b3..1b421f5 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,8 @@ +2014-05-31 Daiki Ueno <ueno@gnu.org> + + * msgfilter-6: Test MSGFILTER_PREV_MSGID and + MSGFILTER_PREV_MSGID_PLURAL. + 2014-05-15 Daiki Ueno <ueno@gnu.org> tests: Add test for msgfilter plural handling diff --git a/gettext-tools/tests/msgfilter-6 b/gettext-tools/tests/msgfilter-6 index 81ef318..ddf7869 100755 --- a/gettext-tools/tests/msgfilter-6 +++ b/gettext-tools/tests/msgfilter-6 @@ -15,6 +15,8 @@ msgstr "'Votre commande, s'il vous plait', dit le garcon." # Les gateaux allemands sont les meilleurs du monde. #, c-format +#| msgid "a piece of bread" +#| msgid_plural "%d pieces of bread" msgid "a piece of cake" msgid_plural "%d pieces of cake" msgstr[0] "un morceau de gateau" @@ -38,6 +40,8 @@ cat >> mf-test6.tmp <<MEOF $MSGFILTER_MSGID $MSGFILTER_MSGID_PLURAL $MSGFILTER_PLURAL_FORM +$MSGFILTER_PREV_MSGID +$MSGFILTER_PREV_MSGID_PLURAL MEOF cat EOF @@ -58,22 +62,32 @@ cat <<\EOF > mf-test6.ok + + ========================= mf-test6.po:8 ========================= 'Your command, please?', asked the waiter. -========================= mf-test6.po:14 ========================= + + +========================= mf-test6.po:16 ========================= a piece of cake %d pieces of cake 0 -========================= mf-test6.po:14 ========================= +a piece of bread +%d pieces of bread +========================= mf-test6.po:16 ========================= a piece of cake %d pieces of cake 1 -========================= mf-test6.po:20 ========================= +a piece of bread +%d pieces of bread +========================= mf-test6.po:22 ========================= %s is replaced by %s. + + EOF : ${DIFF=diff} |