]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgfilter: Implement plural support
authorStanislav Brabec <sbrabec@suse.cz>
Thu, 15 May 2014 03:00:53 +0000 (12:00 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 15 May 2014 06:39:22 +0000 (15:39 +0900)
* msgfilter.c (process_message): Set or unset
MSGFILTER_MSGID_PLURAL and MSGFILTER_PLURAL_FORM.

gettext-tools/doc/ChangeLog
gettext-tools/doc/msgfilter.texi
gettext-tools/src/ChangeLog
gettext-tools/src/msgfilter.c

index 740b6f61f32e168231cea025c60e12d290067a63..5f236dd916bf539677cde1828f568905417e0e17 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-15  Stanislav Brabec  <sbrabec@suse.cz>  (tiny change)
+
+       * msgfilter.texi: Document the environment variable
+       MSGFILTER_MSGID_PLURAL and MSGFILTER_PLURAL_FORM.
+
 2014-05-15  Stanislav Brabec  <sbrabec@suse.cz>  (tiny change)
 
        * msgexec.texi: Document the environment variable
index c26189e979660eeb6a48fdc1193275ad10f3022e..22fbab759eee2e1cb464a6a4b05875d96d8e121a 100644 (file)
@@ -10,13 +10,18 @@ translation catalog.
 
 @vindex MSGFILTER_MSGCTXT@r{, environment variable}
 @vindex MSGFILTER_MSGID@r{, environment variable}
+@vindex MSGFILTER_MSGID_PLURAL@r{, environment variable}
 @vindex MSGFILTER_LOCATION@r{, environment variable}
+@vindex MSGFILTER_PLURAL_FORM@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
 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
 
index bc262cb482e2f006f4645412ad46dbfdf4551426..418599664591d155780a1b23d02e09dc42623fca 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-15  Stanislav Brabec  <sbrabec@suse.cz>  (tiny change)
+
+       msgfilter: Implement plural support
+       * msgfilter.c (process_message): Set or unset
+       MSGFILTER_MSGID_PLURAL and MSGFILTER_PLURAL_FORM.
+
 2014-05-15  Stanislav Brabec  <sbrabec@suse.cz>  (tiny change)
 
        msgexec: Implement plural support
index bbfb05e1b300842751dfd21a9d7d52805d4eb20f..df6551f4aecdb9f028df9299d8cddf403b603c41 100644 (file)
@@ -663,6 +663,10 @@ process_message (message_ty *mp)
   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);
@@ -680,6 +684,15 @@ process_message (message_ty *mp)
       char *result;
       size_t length;
 
+      if (mp->msgid_plural != NULL)
+        {
+          char *plural_form_string = xasprintf ("%lu", k);
+
+          xsetenv ("MSGFILTER_PLURAL_FORM", plural_form_string, 1);
+          free (plural_form_string);
+        }
+      else
+        unsetenv ("MSGFILTER_PLURAL_FORM");
       process_string (p, strlen (p), &result, &length);
       result = (char *) xrealloc (result, length + 1);
       result[length] = '\0';