Opened 22 months ago

Last modified 8 months ago

#34297 closed Bug

raise ValueError('invalid token in plural form: %s' % value) , ValueError: invalid token in plural form: EXPRESSION when adding new language — at Initial Version

Reported by: Azat Owned by: nobody
Component: Utilities Version: 4.1
Severity: Normal Keywords: gettext, i18n, l10n
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I used this guide on [stackoverflow](https://stackoverflow.com/questions/12946830/how-to-add-new-languages-into-django-my-language-uyghur-or-uighur-is-not-su) to setup my language:

Here is my code:
` python
# ======== support locale =========
# https://stackoverflow.com/questions/12946830/how-to-add-new-languages-into-django-my-language-uyghur-or-uighur-is-not-su
LOCALE_PATHS = [BASE_DIR / "locale"]
LANGUAGES = (

('en', _('English')),
('tr', _('Turkish')),
('uly', gettext_noop('Uyghur')),
# ('uay', gettext_noop('Uyghur')),

)

EXTRA_LANG_INFO = {

'uly': {

'bidi': False, # right-to-left
'code': 'uly',
'name': 'Uyghur',
'name_local': 'Uyghur', # unicode codepoints here

},

}
`
When i try to run the code, it gives me this error:
`
Internal Server Error: /uly/admin/
Traceback (most recent call last):

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner

response = get_response(request)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/deprecation.py", line 135, in call

response = self.process_request(request)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/middleware/locale.py", line 35, in process_request

translation.activate(language)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/translation/init.py", line 181, in activate

return _trans.activate(language)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/translation/trans_real.py", line 298, in activate

_active.value = translation(language)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/translation/trans_real.py", line 287, in translation

_translations[language] = DjangoTranslation(language)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/translation/trans_real.py", line 166, in init

self._add_local_translations()

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/translation/trans_real.py", line 226, in _add_local_translations

translation = self._new_gnu_trans(localedir)

File "/Users/azat/Developer/Django/izdinish/venv/lib/python3.10/site-packages/django/utils/translation/trans_real.py", line 193, in _new_gnu_trans

return gettext_module.translation(

File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 602, in translation

t = _translations.setdefault(key, class_(fp))

File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 261, in init

self._parse(fp)

File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 439, in _parse

self.plural = c2py(plural)

File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 183, in c2py

result, nexttok = _parse(_tokenize(plural))

File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 116, in _parse

nexttok = next(tokens)

File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/gettext.py", line 93, in _tokenize

raise ValueError('invalid token in plural form: %s' % value)

ValueError: invalid token in plural form: EXPRESSION
[27/Jan/2023 09:23:38] "GET /uly/admin/ HTTP/1.1" 500 135230
/Users/azat/Developer/Django/izdinish/izdinish/settings.py changed, reloading.
`

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top