NGETTEXT(3)
π¬ NGETTEXT, DNGETTEXT, DCNGETTEXT β the plural-form girlies of libintl π
okay bestie, so this is a page from the Library Functions Manual, and it's literally about translating messages AND picking the right plural form, which is such a vibe. no cap, plural forms are lowkey the drama of linguistics and this trio handles it for you. β¨
πΈ SYNOPSIS πΈ
#include <libintl.h>
char * ngettext (const char * msgid, const char * msgid_plural,
unsigned long int n);
char * dngettext (const char * domainname,
const char * msgid, const char * msgid_plural,
unsigned long int n);
char * dcngettext (const char * domainname,
const char * msgid, const char * msgid_plural,
unsigned long int n, int category);
like, three functions, three levels of extra. pick your fighter. π«Ά
β¨ DESCRIPTION β¨
so ngettext, dngettext and dcngettext are out here trying to translate a text string into the user's native language, by looking up the appropriate plural form of the translation in a message catalog. that's the whole job. iconique. π
now, plural forms are grammatical variants that depend on a number. some languages keep it simple with two forms β singular and plural. others are extra and have three forms, called singular, dual and plural. and yes, some languages out there have four forms. main character energy in every language fr fr. π
the way these work: ngettext, dngettext and dcngettext function exactly like gettext, dgettext and dcgettext respectively. the glow-up is that they also choose the appropriate plural form, which depends on the number n and on the language of the message catalog where the translation was found. π
in the "C" locale, or if none of the used catalogs contain a translation for msgid, then ngettext, dngettext and dcngettext return msgid if n == 1, or msgid_plural if n != 1. simple as that, no notes. β
π RETURN VALUE π
if a translation was found in one of the specified catalogs, the appropriate plural form is converted to the locale's codeset and returned. heads up though β the resulting string is statically allocated and must not be modified or freed. don't touch it, bestie, it's not yours. π
otherwise msgid or msgid_plural is returned, exactly as described above. β¨
π ERRORS π
errno is not modified.
that's it. that's the whole section. she's unbothered. π
π BUGS π
the return type ought to be const char *, but it's char * instead, to avoid warnings in C code predating ANSI C. ancient behavior, honestly, but we respect the elders. π§
π₯ SEE ALSO π₯
and that's the tea, bestie!! π this page came to you courtesy of GNU gettext 1.0, dated May 2001 β yeah she's been slaying since the early 2000s and she's still not done. iykyk. π¦β¨
π¦ where this page comes from
- alpine 3.24: gettext-doc 1.0-r0 Β· GPL-3.0-or-later AND LGPL-2.1-or-later AND MIT
- arch rolling: gettext 1.0-2 Β· GFDL-1.2-only AND GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.0-only
- nixos 26.05: gettext 1.0
- nixpkgs unstable: gettext 1.0
- ubuntu stonking: gettext-base 1.0-3 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms