Display each language in its own language.

23 views
Skip to first unread message

Cody Scott

unread,
May 23, 2013, 3:26:04 PM5/23/13
to django...@googlegroups.com

I would like the language selector to display each language in its own language. So for example English will always be displayed as 'English'. Even if the current language is French it will still be 'English' and not Anglais.


<li>
  <form id="locale_switcher" method="POST" action="{% url 'localeurl_change_locale' %}">
    {% csrf_token %}
    <select name="locale" onchange="$('#locale_switcher').submit()" class="btn btn-inverse">
      {% for lang in LANGUAGES %}
        <option class="btn btn-inverse" value="{{ lang.0 }}" 
          {% ifequal lang.0 LANGUAGE_CODE %}
            selected="selected"
          {% endifequal %}>
          {{ lang.1 }}</option>
      {% endfor %}
    </select>
  </form>
</li>

I think all language selector forms should be like this.

Cody Scott

unread,
May 24, 2013, 9:54:26 AM5/24/13
to django...@googlegroups.com
In my settings.py I have 

#Used for translations

gettext = lambda s: s

#languages written as they would be displayed in the language selector form

LANGUAGES = (

  ('en', gettext('English')),

  ('fr', gettext('French')),

  ('ja', gettext('Japanese')),

)

and I was thinking of writing each language in its own language

LANGUAGES = (

('en', gettext('English')),

('fr', gettext('Français')),

('ja', gettext('日本人')),

)

But I get an error for having a non ascii character in settings.py




--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/mBTgoUNIj30/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tom Evans

unread,
May 24, 2013, 10:03:44 AM5/24/13
to django...@googlegroups.com
On Fri, May 24, 2013 at 2:54 PM, Cody Scott <cody.j....@gmail.com> wrote:
> In my settings.py I have
>
> #Used for translations
>
> gettext = lambda s: s
>
> #languages written as they would be displayed in the language selector form
>
> LANGUAGES = (
>
> ('en', gettext('English')),
>
> ('fr', gettext('French')),
>
> ('ja', gettext('Japanese')),
>
> )
>
> and I was thinking of writing each language in its own language
>
> LANGUAGES = (
>
> ('en', gettext('English')),
>
> ('fr', gettext('Français')),
>
> ('ja', gettext('日本人')),
>
> )
>
> But I get an error for having a non ascii character in settings.py
>

If you don't want language names to be translated into other
languages, then don't mark them up as translatable strings that will
have their values retrieved from the active message catalogue. IE:

LANGUAGES = (
('en', u'English'),
('fr', u'Français'),
('ja', u'日本人'),
)

Cheers

Tom

Cody Scott

unread,
May 24, 2013, 10:18:04 AM5/24/13
to django...@googlegroups.com
ok I also had to add 
# -*- coding: utf-8 -*- 
to the top of the file



Reply all
Reply to author
Forward
0 new messages