#32737: get_language_info replaces requested language code with the one found in
django.conf.locale.LANG_INFO
-------------------------------------+-------------------------------------
     Reporter:  ruffni               |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:                       |                  Version:  dev
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n,                |             Triage Stage:  Accepted
  get_language_info, language code,  |
  LANG_INFO, documentation           |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

 * status:  closed => new
 * type:  Bug => Cleanup/optimization
 * version:  3.1 => dev
 * resolution:  invalid =>
 * stage:  Unreviewed => Accepted


Comment:

 Thanks a lot for the sample project. I'm reopening at least for the
 missing documentation which should tell that `get_language_info` and
 `get_language_info_list` only return information for languages included in
 Django.

 In your specific use case, I would simply rewrite your language selector
 as:
 {{{
 <select name="language" class="custom-select" id="lang_selection">
     {% get_current_language as LANGUAGE_CODE %}
     {% get_available_languages as LANGUAGES %}
     {% for code,lang_name in LANGUAGES %}
         <option value="{{ code }}" {% if code == LANGUAGE_CODE %}
 selected{% endif%}>
             {{ lang_name }} ({{code}})</option>
     {% endfor %}
 </select>
 }}}

 If we wanted custom languages data entering Django's `LANG_INFO`, it would
 require some deeper refactoring with language data embedded somewhere
 inside the locale folders (maybe in `__init__.py`?). Don't know if it's
 really worth the effort…

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32737#comment:5>
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/064.ea5b510f86ca1839a170f352914b6013%40djangoproject.com.

Reply via email to