Is there any braindead simple way to select the language specific version of a page on a Django website based on the domain? (the URLs are and will be the same for both languages, except the language code, so I want to have mysite.com/teachers/manage same as mysite.com/en/teachers/manage (done with 'en' default) and mesito.es/teachers to be same as mesito.es/es/teachers - and no, the urls themselves like 'teachers/manage' will never be translated, so I don't want to configure 2 sets of urls for both languages).
Note: All other solutions I've found imply that I also want to translate the URLs, but I know I will never want to translate the URLs and manae 2 sets of them for this particular website.
Note 2 (forgot to add): Most of the website is actually django-cms based, so django-cms specific solutions would be helpful to...
OK, I got what I wanted with this ugly hack through a redirecting view (but still, isn't there a right AND simple way to do this?...):
## mysite.urls:
urlpatterns = patterns('',
(r'^$', 'mysite.views.language_router')
## mysite.views:
def language_router(request):
if request.META['HTTP_HOST'].find('myspanishdomain.com') != -1 \
and request.META['PATH_INFO'] == '/' :
return HttpResponseRedirect('http://www.myspanishdomain.com/es/')
return cms.views.details(request, '')
(site at myenglishdomain.com has the default language english)
Why don't you write your onw tiny middleware class that you add after the LocaleMiddleware, that simply adds the language, if no language has been identified yet based on the rules that you have explained here in that thread.
You may want to have a look at Transurlvania as it allows you to map a domain to a language:
MULTILANG_LANGUAGE_DOMAINS = {
'en': ('www.example-en.com', 'English Site'),
'fr': ('www.example-fr.com', 'French Site')
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With