diff -ur gettext-0.18.1.1.orig/gettext-tools/doc/msgexec.texi gettext-0.18.1.1/gettext-tools/doc/msgexec.texi --- gettext-0.18.1.1.orig/gettext-tools/doc/msgexec.texi 2010-06-06 14:49:57.000000000 +0200 +++ gettext-0.18.1.1/gettext-tools/doc/msgexec.texi 2010-06-09 14:04:51.363290597 +0200 @@ -25,7 +25,10 @@ variable @code{MSGEXEC_LOCATION} is bound to the location in the PO file of the message. If the message has a context, the environment variable @code{MSGEXEC_MSGCTXT} is bound to the message's msgctxt, otherwise it is -unbound. +unbound. If the message has a plural form, environment variable +@code{MSGEXEC_MSGID_PLURAL} is bound to the message's msgid_plural and +@code{MSGEXEC_PLURAL_FORM} is bound to the order number of the plural +actually processed (starting with 0), otherwise both are unbound. @cindex catalog encoding and @code{msgexec} output Note: It is your responsibility to ensure that the @var{command} can cope diff -ur gettext-0.18.1.1.orig/gettext-tools/doc/msgfilter.texi gettext-0.18.1.1/gettext-tools/doc/msgfilter.texi --- gettext-0.18.1.1.orig/gettext-tools/doc/msgfilter.texi 2010-06-06 14:49:57.000000000 +0200 +++ gettext-0.18.1.1/gettext-tools/doc/msgfilter.texi 2010-06-09 16:25:49.275293701 +0200 @@ -16,7 +16,10 @@ variable @code{MSGFILTER_LOCATION} is bound to the location in the PO file of the message. If the message has a context, the environment variable @code{MSGFILTER_MSGCTXT} is bound to the message's msgctxt, otherwise it is -unbound. +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. @subsection Input file location diff -ur gettext-0.18.1.1.orig/gettext-tools/src/msgexec.c gettext-0.18.1.1/gettext-tools/src/msgexec.c --- gettext-0.18.1.1.orig/gettext-tools/src/msgexec.c 2010-06-06 14:49:58.000000000 +0200 +++ gettext-0.18.1.1/gettext-tools/src/msgexec.c 2010-06-08 16:47:13.684665066 +0200 @@ -370,6 +370,10 @@ else unsetenv ("MSGEXEC_MSGCTXT"); xsetenv ("MSGEXEC_MSGID", mp->msgid, 1); + if (mp->msgid_plural != NULL) + xsetenv ("MSGEXEC_MSGID_PLURAL", mp->msgid_plural, 1); + else + unsetenv ("MSGEXEC_MSGID_PLURAL"); location = xasprintf ("%s:%ld", mp->pos.file_name, (long) mp->pos.line_number); xsetenv ("MSGEXEC_LOCATION", location, 1); @@ -408,6 +412,7 @@ { const char *msgstr = mp->msgstr; size_t msgstr_len = mp->msgstr_len; + unsigned int i = 0; const char *p; /* Process each NUL delimited substring separately. */ @@ -415,6 +420,14 @@ { size_t length = strlen (p); + if (mp->msgid_plural != NULL) + { + char plural_form_string[12]; + sprintf (plural_form_string, "%d", i++); + xsetenv ("MSGEXEC_PLURAL_FORM", plural_form_string, 1); + } + else + unsetenv ("MSGEXEC_PLURAL_FORM"); process_string (mp, p, length); p += length + 1; diff -ur gettext-0.18.1.1.orig/gettext-tools/src/msgfilter.c gettext-0.18.1.1/gettext-tools/src/msgfilter.c --- gettext-0.18.1.1.orig/gettext-tools/src/msgfilter.c 2010-06-06 14:49:58.000000000 +0200 +++ gettext-0.18.1.1/gettext-tools/src/msgfilter.c 2010-06-09 16:33:20.535291995 +0200 @@ -619,6 +619,7 @@ char **substrings; size_t total_len; char *total_str; + unsigned int i = 0; const char *p; char *q; size_t k; @@ -628,8 +629,8 @@ return; /* Set environment variables for the subprocess. - Note: These environment variables, especially MSGEXEC_MSGCTXT and - MSGEXEC_MSGCTXT, may contain non-ASCII characters. The subprocess + Note: These environment variables, especially MSGFILTER_MSGCTXT and + MSGFILTER_MSGCTXT, may contain non-ASCII characters. The subprocess may not interpret these values correctly if the locale encoding is different from the PO file's encoding. We want about this situation, above. @@ -644,6 +645,10 @@ else unsetenv ("MSGFILTER_MSGCTXT"); xsetenv ("MSGFILTER_MSGID", mp->msgid, 1); + if (mp->msgid_plural != NULL) + xsetenv ("MSGFILTER_MSGID_PLURAL", mp->msgid_plural, 1); + else + unsetenv ("MSGFILTER_MSGID_PLURAL"); location = xasprintf ("%s:%ld", mp->pos.file_name, (long) mp->pos.line_number); xsetenv ("MSGFILTER_LOCATION", location, 1); @@ -661,6 +666,14 @@ char *result; size_t length; + if (mp->msgid_plural != NULL) + { + char plural_form_string[12]; + sprintf (plural_form_string, "%d", i++); + xsetenv ("MSGFILTER_PLURAL_FORM", plural_form_string, 1); + } + else + unsetenv ("MSGFILTER_PLURAL_FORM"); process_string (p, strlen (p), &result, &length); result = (char *) xrealloc (result, length + 1); result[length] = '\0';