project/templatetags/lang_extras.py
def change_lang(context, lang=None, *args, **kwargs):
    """
    Returns the translated version of the current URL.

    Example:
        <a href="{% change_lang 'en' %}">English version</a>

    Adapted from:
    https://stackoverflow.com/a/57578343
    """
    path = context['request'].path
    return translate_url(path, lang)

    Returns the translated version of the current URL.

    Example:
        <a href="{% change_lang 'en' %}">English version</a>

    Adapted from:
    https://stackoverflow.com/a/57578343
    
Returns the translated version of the current URL.
Returns the translated version of the current URL .
def change_lang(context, lang=None, *args, **kwargs):
    path = context['request'].path
    return translate_url(path, lang)
def change_lang ( context , lang = None , * args , ** kwargs ) : path = context [ 'request' ] . path return translate_url ( path , lang )
Returns the translated version of the current URL.
Returns the translated version of the current URL .
"""
    Returns the translated version of the current URL.

    Example:
        <a href="{% change_lang 'en' %}">English version</a>

    Adapted from:
    https://stackoverflow.com/a/57578343
    """
context
lang
examples
None