Django translation ngettext not working with gettext in the same file
this is my setup to generate translations for both singular and plurar text
from django.utils.translations import ngettext as _
from django.utils.translations import gettext
num = 3
my_plural_string = _("{num} apple", "{num} apples", num).format(num=num)
my_single_string = gettext("this is a text")
When using ngettext
and gettext
in the same file the generated .po
file doesn't include the msgid_plural
attribute for the first string
#: .\test_app\test_translation.py:10
msgid "{num} apple"
msgstr ""
#: .\test_app\test_translation.py:11
msgid "this is a text"
msgstr ""
the weird part about this situation is if you change the imports like this
from django.utils.translation import ngettext
from django.utils.translation import gettext as _
It will work as expected :)