I am using django-localeurl to change the language of a project based on a suffix after the domain (example.com/en , example.com/hu etc). However I also have subdomains for the countries which are exactly the same as the suffixes.
How can I modify the locale-url or add another filter to the links so that I could change the suffix and subdomain at the same time?
f.e.
example.com -> hu.example.com/hu -> es.example.com/es etc.
Here there is the localeurl chlocale function:
def chlocale(url, locale):
"""
Changes the URL's locale prefix if the path is not locale-independent.
Otherwise removes locale prefix.
"""
_, path = utils.strip_script_prefix(url)
_, path = utils.strip_path(path)
return utils.locale_url(path, locale)
chlocale = stringfilter(chlocale)
register.filter('chlocale', chlocale)
That's my call as URL href:
<a href="{{ request.path|chlocale:"hu" }}">Hungary</a>