git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] PRItime: wrap PRItime for better l10n compatibility

From
Jiang Xin <worldhello.net@gmail.com>
Date
Jul 21, 2017, 23:13 UTC
Message-ID
<CANYiYbF+XDANNbpZJ-jL7y81QhggW_snBuWeONSCUc4CPn2zMw@mail.gmail.com>
In-Reply-To
<xmqqvamlfm6s.fsf@gitster.mtv.corp.google.com>
2017-07-22 6:40 GMT+08:00 Junio C Hamano <gitster@pobox.com>:
Show 14 quoted lines
> Jiang Xin <worldhello.net@gmail.com> writes:
>
>> Sorry, I'm late. I want to try a safer way to change PRItime to
>> PRInMax using a hacked version of gettext.
>
> Why?  A vanilla version of gettext tool that is fed a known PRIuMAX
> in its input would be a safer choice, I would have thought.
>
> I've already queued the patch you responded to on 'master', but
> haven't tagged -rc1 yet, so it is possible for you to update on top
> of it before -rc1 is tagged.  I do not yet understand why you think
> a modified version of gettext would be a safer way to go, though.
>
> Thanks.

A very small hack on gettext. When extract l10n messages to pot file with `xgettext`, will grep "PRItime", and do "sed s/PRItime/PRIuMAX" inside `xgettext`.

See this patch: https://github.com/jiangxin/gettext/commit/b0a726431c93b5a1ca0fe749de376b0752e75fb0

    ---
     gettext-tools/src/x-c.c      | 17 ++++++++++++++++-
     gettext-tools/src/xgettext.c |  2 +-
     2 files changed, 17 insertions(+), 2 deletions(-)
    diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c
    index 1844a5df7..51dd0a9bc 100644
    --- a/gettext-tools/src/x-c.c
    +++ b/gettext-tools/src/x-c.c
    @@ -1802,6 +1802,12 @@ phase6_unget (token_ty *tp)
     static bool
     is_inttypes_macro (const char *name)
     {
    +  /* PRItime is a maro for timestamp_t in git.git. */
    +  if (!strncmp(name, "PRItime", 7))
    +    {
    +      return true;
    +    }
    +
       /* Syntax:
          P R I { d | i | o | u | x | X }
          { { | LEAST | FAST } { 8 | 16 | 32 | 64 } | MAX | PTR }  */
    @@ -1843,8 +1849,17 @@ phase8a_get (token_ty *tp)
       phase6_get (tp);
       if (tp->type == token_type_name && is_inttypes_macro (tp->string))
         {
    +      char *new_string;
           /* Turn PRIdXXX into "<PRIdXXX>".  */
    -      char *new_string = xasprintf ("<%s>", tp->string);
    +      if (!strncmp(tp->string, "PRItime", 7))
    +        {
    +          /* Replace PRItime with PRIuMAX for git.git project */
    +          new_string = xasprintf ("<%s>", "PRIuMAX");
    +        }
    +      else
    +        {
    +          new_string = xasprintf ("<%s>", tp->string);
    +        }
           free (tp->string);
           tp->string = new_string;
           tp->comment = add_reference (savable_comment);
    diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
    index f848d76d1..0350a1bee 100644
    --- a/gettext-tools/src/xgettext.c
    +++ b/gettext-tools/src/xgettext.c
    @@ -676,7 +676,7 @@ main (int argc, char *argv[])
       /* Version information requested.  */
       if (do_version)
         {
    -      printf ("%s (GNU %s) %s\n", basename (program_name),
PACKAGE, VERSION);
    +      printf ("%s (GNU %s) %s (PRItime to PRIuMAX for
git.git)\n", basename (program_name), PACKAGE, VERSION);
           /* xgettext: no-wrap */
           printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\
     License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\n\
    --
    2.14.0.rc0.1.g3ccfa2fb49
-- 
蒋鑫

华为技术有限公司
邮件: xin.jiang@huawei.com, worldhello.net@gmail.com
博客: http://www.worldhello.net/
微博: http://weibo.com/gotgit/
电话: 18601196889
Previous: Junio C HamanoNext: Junio C Hamano
Message 25 of 45 in “[L10N] Kickoff of translation for Git 2.14.0 round 1”
  1. Jiang XinJul 15, 2017
  2. Jean-Noël AvilaJul 15, 2017
  3. Jiang XinJul 17, 2017
  4. Johannes SchindelinJul 17, 2017
  5. Jiang XinJul 18, 2017
  6. PRItime: wrap PRItime for better l10n compatibilityJiang Xin, Jul 17, 2017
  7. Junio C HamanoJul 17, 2017
  8. Jiang XinJul 18, 2017
  9. Junio C HamanoJul 18, 2017
  10. Jiang XinJul 19, 2017
  11. Johannes SchindelinJul 19, 2017
  12. Junio C HamanoJul 19, 2017
  13. Junio C HamanoJul 19, 2017
  14. Junio C HamanoJul 20, 2017
  15. Junio C HamanoJul 20, 2017
  16. Junio C HamanoJul 20, 2017
  17. Jean-Noël AvilaJul 21, 2017
  18. Junio C HamanoJul 21, 2017
  19. Johannes SchindelinJul 22, 2017
  20. Junio C HamanoJul 22, 2017
  21. Johannes SchindelinJul 25, 2017
  22. Junio C HamanoJul 25, 2017
  23. Jiang XinJul 21, 2017
  24. Junio C HamanoJul 21, 2017
  25. Jiang XinJul 21, 2017
  26. Junio C HamanoJul 21, 2017
  27. Jiang XinJul 22, 2017
  28. Makefile: generate pot file using a tweaked version of xgettextJiang Xin, Jul 22, 2017
  29. Junio C HamanoJul 22, 2017
  30. Johannes SchindelinJul 22, 2017
  31. Junio C HamanoJul 22, 2017
  32. Jiang XinJul 24, 2017
  33. Johannes SchindelinJul 25, 2017
  34. Junio C HamanoJul 25, 2017
  35. Jiang XinJul 24, 2017
  36. Junio C HamanoJul 24, 2017
  37. Johannes SchindelinJul 25, 2017
  38. Jean-Noël AVILAJul 23, 2017
  39. Junio C HamanoJul 23, 2017
  40. Jiang XinJul 24, 2017
  41. Junio C HamanoJul 24, 2017
  42. Kaartic SivaraamJul 22, 2017
  43. Jean-Noël AvilaJul 23, 2017
  44. Jordi MasJul 19, 2017
  45. Jiang XinJul 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.