如何同时使用 i18n_patterns 和 set_language 在 django 站点上显示 / 而不是 /en/ ?
How to display / on django site instead of /en/ using i18n_patterns and set_language at the same time?
我正在使用 https://docs.djangoproject.com/en/1.8/topics/i18n/translation/ 中的 i18n_patterns,但我想显示英语的默认根 /(默认设置为 LANGUAGE_CODE
),而不是 /en/
在我的 Django 网站上。
我尝试使用 solid_i18n 包,但我没有找到如何使其与 url(r'^i18n/', include('django.conf.urls.i18n'))
兼容,使用户能够在语言之间切换。
如何强制我的 LANGUAGE_CODE
使用默认根目录 /
url,同时仍然使用 https://docs.djangoproject.com/en/1.8/_modules/django/views/i18n/#set_language 启用 url(r'^i18n/', include('django.conf.urls.i18n'))
时间?
谢谢
我是用 django-solid-i18n-urls 做的。
你应该有:
SOLID_I18N_USE_REDIRECTS = True
In that case, for root paths (without prefix), django will try to discover user preferred language. If it doesn't equal to default language, redirect to path with corresponding prefix will occur. If preferred language is the same as default, then that request path will be processed (without redirect).
我正在使用 https://docs.djangoproject.com/en/1.8/topics/i18n/translation/ 中的 i18n_patterns,但我想显示英语的默认根 /(默认设置为 LANGUAGE_CODE
),而不是 /en/
在我的 Django 网站上。
我尝试使用 solid_i18n 包,但我没有找到如何使其与 url(r'^i18n/', include('django.conf.urls.i18n'))
兼容,使用户能够在语言之间切换。
如何强制我的 LANGUAGE_CODE
使用默认根目录 /
url,同时仍然使用 https://docs.djangoproject.com/en/1.8/_modules/django/views/i18n/#set_language 启用 url(r'^i18n/', include('django.conf.urls.i18n'))
时间?
谢谢
我是用 django-solid-i18n-urls 做的。
你应该有:
SOLID_I18N_USE_REDIRECTS = True
In that case, for root paths (without prefix), django will try to discover user preferred language. If it doesn't equal to default language, redirect to path with corresponding prefix will occur. If preferred language is the same as default, then that request path will be processed (without redirect).