From: Daiki Ueno Date: Sat, 31 May 2014 02:28:39 +0000 (+0900) Subject: msgfilter: Pass previous msgid to the child process X-Git-Tag: v0.19~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a78eca9e7bd70521a0f64657b4c5904797927df;p=thirdparty%2Fgettext.git msgfilter: Pass previous msgid to the child process Suggested by Pavel Kharitonov in: . * msgfilter.c (process_message): Set MSGFILTER_PREV_* envvar. --- diff --git a/gettext-tools/doc/ChangeLog b/gettext-tools/doc/ChangeLog index 5f236dd91..257b46da1 100644 --- a/gettext-tools/doc/ChangeLog +++ b/gettext-tools/doc/ChangeLog @@ -1,3 +1,9 @@ +2014-05-31 Daiki Ueno + + * msgfilter.texi: Document the environment variable + MSGFILTER_PREV_MSGCTXT, MSGFILTER_PREV_MSGID, and + MSGFILTER_PREV_MSGID_PLURAL. + 2014-05-15 Stanislav Brabec (tiny change) * msgfilter.texi: Document the environment variable diff --git a/gettext-tools/doc/msgfilter.texi b/gettext-tools/doc/msgfilter.texi index 22fbab759..1fae2514b 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 596e3a53a..8247050e6 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,10 @@ +2014-05-31 Daiki Ueno + + msgfilter: Pass previous msgid to the child process + Suggested by Pavel Kharitonov in: + . + * msgfilter.c (process_message): Set MSGFILTER_PREV_* envvar. + 2014-05-19 Daiki Ueno * 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 f172a4585..961b1f115 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 4eb30b334..1b421f567 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,8 @@ +2014-05-31 Daiki Ueno + + * msgfilter-6: Test MSGFILTER_PREV_MSGID and + MSGFILTER_PREV_MSGID_PLURAL. + 2014-05-15 Daiki Ueno tests: Add test for msgfilter plural handling diff --git a/gettext-tools/tests/msgfilter-6 b/gettext-tools/tests/msgfilter-6 index 81ef3185d..ddf78696e 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 < 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}