ngettext
ngettext is a function used in software localization to select the correct plural form of a translated string based on a numeric quantity. It is part of the GNU gettext framework and is available in C, C++, Python, and many other languages through bindings. The function takes three arguments: a singular form, a plural form, and a number n. It looks up the translation of the singular form in the active translation catalog for the current locale, applies the locale’s pluralization rules to n, and returns the corresponding translated string. If a translation is unavailable, ngettext falls back to the appropriate form of the original English text.
The selection of the plural form depends on the locale’s plural-forms rules, defined in the locale data.
Usage typically involves combining ngettext with the program’s formatting. For example, a line might format the