def reverse(*args, **kwargs): reverse_kwargs = kwargs.get('kwargs') or {} locale = utils.supported_language(reverse_kwargs.pop( 'locale', translation.get_language())) url = django_reverse(*args, **kwargs) _, path = utils.strip_script_prefix(url) return utils.locale_url(path, locale)
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)