如何在 Django 中获取当前语言?

2022-01-18 00:00:00 python django internationalization

问题描述

如何在模型或管理员的当前线程中获取当前语言?

How can I get the current language in the current thread in a model or in the admin?


解决方案

特别感兴趣的函数是 django.utils.translation.get_language(),它返回当前线程中使用的语言.请参阅文档.

Functions of particular interest are django.utils.translation.get_language() which returns the language used in the current thread. See documentation.

相关文章