Replacing the line with "Plural-Forms: nplurals=2; plural= (n != 1);\n"
in all the occurences of .po files shdould get you going!
gettext usually translates word to word when you use Django translations (i18n & l10n). But it gets trickier when you want to translate (mostly) nouns, into its singular/plural form.
For instance, consider this example:
if n == 1:
string = "%d file is deleted"%n
else:
string = "%d files are deleted"%n
To handle the translation of plurals in internationalization, Plural-forms is the standard to follow. Python-Django implements ngettext in the following manner:
(visit doc for your Django version)
ngettext('%d file is deleted', '%d files are deleted', n) % n
In most of the languages, n!=1 is considered plural. In the above example, when n=1
Django has to consider '%d file is deleted'
and '%d files are deleted'
when n!=1
for translations. Hence the denifition for plural-forms in .po files goes like this: "Plural-Forms: nplurals=2; plural= (n != 1);\n"
Now, when you run makemessages
, Django is trying to help you by adding "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
line in the .po files, hinting this line has to be replaced with our definition of plural-forms.
Note:
Not every language would have 2 plurals, for instance, Japanese, Vietnamese, Korean, Thai doesn't need to differentiate between singular and plural (hence Plural-Forms: nplurals=1; plural=0;
). On the other hand, there are some languages like Romanian, Lithuanian, Russian, Polish where nplurals=3
. Check out this link for further examples.
Hopefully in your case, nplurals=1. If not visit this link for plurals-form.