Django: How to get language code in template?

后端 未结 3 1171
你的背包
你的背包 2021-02-01 01:49

Is there\'s some global variable for gettin\' language code in django template or atleast passing it through view? something like: {{ LANG }} should produce \"en\"

3条回答
  •  被撕碎了的回忆
    2021-02-01 02:20

    It's an old topic. But some might find it useful.

    {% load i18n %}
    ...
    {% get_current_language as LANGUAGE_CODE %}
    

    Django reference and example.

提交回复
热议问题