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)
You may want to have a look at Transurlvania as it allows you to map a domain to a language: