Python Forum

Full Version: Django translation 2 languages( Deutsch and Austrian)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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/
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.