[Django] #34297: raise ValueError('invalid token in plural form: %s' % value) , ValueError: invalid token in plural form: EXPRESSION when adding new language

321 views
Skip to first unread message

Django

unread,
Jan 27, 2023, 4:30:22 AM1/27/23
to django-...@googlegroups.com
#34297: raise ValueError('invalid token in plural form: %s' % value) , ValueError:
invalid token in plural form: EXPRESSION when adding new language
-------------------------------------+-------------------------------------
Reporter: azataiot | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Keywords: gettext, i18n, l10n
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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/pyt...@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/pyt...@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/pyt...@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/pyt...@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/pyt...@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/pyt...@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.
```

--
Ticket URL: <https://code.djangoproject.com/ticket/34297>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 27, 2023, 4:31:23 AM1/27/23
to django-...@googlegroups.com
#34297: raise ValueError('invalid token in plural form: %s' % value) , ValueError:
invalid token in plural form: EXPRESSION when adding new language
-------------------------------------+-------------------------------------
Reporter: azataiot | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: 4.1
Severity: Normal | Resolution:

Keywords: gettext, i18n, l10n | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by azataiot:

Old description:

New 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:


{{{

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34297#comment:1>

Django

unread,
Jan 27, 2023, 4:45:45 AM1/27/23
to django-...@googlegroups.com
#34297: raise ValueError('invalid token in plural form: %s' % value) , ValueError:
invalid token in plural form: EXPRESSION when adding new language
-------------------------------------+-------------------------------------
Reporter: Azat | Owner: nobody
Type: Bug | Status: closed
Component: Utilities | Version: 4.1
Severity: Normal | Resolution: invalid

Keywords: gettext, i18n, l10n | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Please don't use Trac as a support channel. Closing per
TicketClosingReasons/UseSupportChannels.

--
Ticket URL: <https://code.djangoproject.com/ticket/34297#comment:2>

Reply all
Reply to author
Forward
0 new messages