Python Forum
Django translation 2 languages( Deutsch and Austrian)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django translation 2 languages( Deutsch and Austrian)
#1
Hello!
Short version of question: Does django have de-at(Austrian version of Deutsch) and how can I define it?
I need to create website with 2 languages (standart Deutsch and Austrian version)
There is one problem, setting in settings.py :
LANGUAGES = (
    ('en', _('English')),
    ('de', _('German')),
    ('de-at', _('Austrian'))
)
doesn't work.
Everything is set: contextprocessor, i18n is True, localemiddleware is set.
In my template:
 <form action="{% url 'set_language' %}" method="post">
                        {% csrf_token %}
                        <input name="next" type="hidden" value="{{ redirect_to }}" />
                            <select style="border:1px dotted black" name="language">
                              {% get_current_language as LANGUAGE_CODE %}
                              {% get_available_languages as LANGUAGES %}
                              {% get_language_info_list for LANGUAGES as languages %}
                              {% for language in languages %}
                             <option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
                                {{ language.name_local }} ({{ language.code }})
                             </option>
                            {% endfor %}
                            </select>
                             <input class="btn-primary" type="submit" value="{% trans 'Change' %}" />
                    </form>
Using documentation - creates select dropdown menu with languages, where de-at and de versions are equal, I mean, that django defines them as same languages. I made
makemessages -l de_AT
- doesn't work, tried -
makemessages -l de-at
- same. On template side there are 3 languages: english and 2 Deutsch(de)(no sublanguages Confused ). Doesn't matter I'll choose first Deutsch(de)- Austrian version or second - original Deutsch django translates website in standard Deutsch.
Reply
#2
From the docs: https://docs.djangoproject.com/en/2.0/to...anslation/

Quote:If a base language is available but the sublanguage specified is not, Django uses the base language. For example, if a user specifies de-at (Austrian German) but Django only has de available, Django uses de.

Also see: https://djangobook.com/internationalization/
Reply
#3
Thanks for reply. I saw this docs and stackoverflow questions. I can't understand how to set sublanguage. If sublanguage means setting de-at language in setting.py + creating de_AT .po and .mo files I did it but it doesn't work.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,247 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020