Django internationalization switching between languages

I have a french and a english site up, very basic. I created my fr language file. I have a few translated strings to test this to make sure it works but I am confused as how to set up the actual link to swap between languages. I have followed this, https://docs.djangoproject.com/en/1.3/topics/i18n/internationalization/#the-set-language-redirect-view but receive a 404 for /next/page, am i doing this correctly? Here is my code if this helps:

                <form action="/i18n/setlang/" method="post">
                {% csrf_token %}
                <input name="next" type="hidden" value="/next/page/" />
                <select name="language">
                {% get_language_info_list for LANGUAGES as languages %}
                {% for lang in LANGUAGES %}
                    {% if lang.0 != '' %}
                        <option value="{{lang.0}}">{{lang.1}}</option>
                    {% endif %}
                {% endfor %}
                </select>
                <input type="submit" value="Go" />
            </form>

I have also added my urls like so:

(r'^i18n/', include('django.conf.urls.i18n')),

And I have this in my settings for middleware and language:

'django.middleware.locale.LocaleMiddleware',

LANGUAGES = (
    ('en', 'English'),
    ('fr', 'French'),
)

I am confused as to how to have this working so i can swap between the 2 languages, or, If I am doing it correctly, why am I getting that 404 error with the /next/page when trying to change languages?

Thanks!

Jeff

Answers


In this line

<input name="next" type="hidden" value="/next/page/" />

you have to substitute "/next/page/" with the page that you want to load after the language change.

In case that you want to load the same page, you should write value="".


Need Your Help

iPhone:Twitter integration

iphone twitter

I followed the below link to integrate Twitter into my application.