#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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070185f2903f85-81cd4365-913f-42c8-baac-6757ef788005-000000%40eu-central-1.amazonses.com.

Reply via email to