0.5: Django 3.2 support, drop Django<1.11, Python<3.6, remove some compatibility...
[fnpdjango.git] / fnpdjango / utils / settings.py
1 """
2 Utilities for global settings.
3 """
4 from django.utils.functional import Promise
5
6
7 class LazyUGettextLazy(Promise):
8     """You can use it to internationalize strings in settings.
9
10     Just import this class as gettext.
11     """
12     _ = lambda s: s
13     real = False
14
15     def __init__(self, text):
16         self.text = text
17
18     def __str__(self):
19         if not self.real:
20             from django.utils.translation import ugettext_lazy
21             LazyUGettextLazy._ = staticmethod(ugettext_lazy)
22             LazyUGettextLazy.real = True
23         return str(self._(self.text))
24
25