From: Junio C Hamano Date: Wed, 06 Jul 2016 16:08:59 GMT Subject: Re: [PATCH 3/5] index-pack: correct "len" type in unpack_data() Message-ID: In-Reply-To: Junio C Hamano writes: > Duy Nguyen writes: > >> What can I say, gettext is smart. In gc.c we already have this >> >> die(_("gc is already running on machine '%s' pid %"PRIuMAX" (use >> --force if not)"), name, (uintmax_t)pid); >> >> and vi.po shows >> >> #: builtin/gc.c:397 >> #, c-format >> msgid "" >> "gc is already running on machine '%s' pid % (use --force if not)" > > And translators are expcted to keep "%" in their translated > .po files, and whatever translates .po into .mo knows what > % should be mapped to? > > That is surprising. gettext.info answered me ;-) The ‘gettext’ tools and library have special support for these ‘’ macros. You can therefore simply write printf (gettext ("The amount is %0" PRId64 "\n"), number); The PO file will contain the string "The amount is %0\n". The translators will provide a translation containing "%0" as well, and at runtime the ‘gettext’ function’s result will contain the appropriate constant string, "d" or "ld" or "lld". This works only for the predefined ‘’ macro... Nice.