Mercurial > libervia-backend
comparison sat/core/i18n.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 | 20 |
21 from sat.core.log import getLogger | 21 from sat.core.log import getLogger |
22 | |
22 log = getLogger(__name__) | 23 log = getLogger(__name__) |
23 | 24 |
24 try: | 25 try: |
25 | 26 |
26 import gettext | 27 import gettext |
27 | 28 |
28 _ = gettext.translation('sat', 'i18n', fallback=True).ugettext | 29 _ = gettext.translation("sat", "i18n", fallback=True).ugettext |
29 _translators = {None: gettext.NullTranslations()} | 30 _translators = {None: gettext.NullTranslations()} |
30 | 31 |
31 def languageSwitch(lang=None): | 32 def languageSwitch(lang=None): |
32 if not lang in _translators: | 33 if not lang in _translators: |
33 _translators[lang] = gettext.translation('sat', languages=[lang], fallback=True) | 34 _translators[lang] = gettext.translation( |
35 "sat", languages=[lang], fallback=True | |
36 ) | |
34 _translators[lang].install(unicode=True) | 37 _translators[lang].install(unicode=True) |
38 | |
35 | 39 |
36 except ImportError: | 40 except ImportError: |
37 | 41 |
38 log.warning("gettext support disabled") | 42 log.warning("gettext support disabled") |
39 _ = lambda msg: msg # Libervia doesn't support gettext | 43 _ = lambda msg: msg # Libervia doesn't support gettext |
44 | |
40 def languageSwitch(lang=None): | 45 def languageSwitch(lang=None): |
41 pass | 46 pass |
42 | 47 |
43 | 48 |
44 D_ = lambda msg: msg # used for deferred translations | 49 D_ = lambda msg: msg # used for deferred translations |
45 |