Add enable_cache parameter to lazy_gettext

This commit is contained in:
birdi 2019-07-18 16:19:53 +03:00
parent e77f5142b6
commit 92334a57be

View file

@ -107,7 +107,7 @@ class I18nMiddleware(BaseMiddleware):
else: else:
return translator.ngettext(singular, plural, n) return translator.ngettext(singular, plural, n)
def lazy_gettext(self, singular, plural=None, n=1, locale=None) -> LazyProxy: def lazy_gettext(self, singular, plural=None, n=1, locale=None, enable_cache=True) -> LazyProxy:
""" """
Lazy get text Lazy get text
@ -115,9 +115,10 @@ class I18nMiddleware(BaseMiddleware):
:param plural: :param plural:
:param n: :param n:
:param locale: :param locale:
:param enable_cache:
:return: :return:
""" """
return LazyProxy(self.gettext, singular, plural, n, locale) return LazyProxy(self.gettext, singular, plural, n, locale, enable_cache=enable_cache)
# noinspection PyMethodMayBeStatic,PyUnusedLocal # noinspection PyMethodMayBeStatic,PyUnusedLocal
async def get_user_locale(self, action: str, args: Tuple[Any]) -> str: async def get_user_locale(self, action: str, args: Tuple[Any]) -> str: