blob: 9ea3fa03d6a7daa0613813b2bef0c8252cfbd7ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
=======
Usage
=======
To use in a project, create a small integration module containing:
::
from oslo.i18n import gettextutils
_translators = gettextutils.TranslatorFactory(domain='myapp')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
Then, in your application code, use the appropriate marker function
for your case:
::
from myapp.i18n import _, _LW
# ...
LOG.warn(_LW('warning message: %s'), var)
# ...
raise RuntimeError(_('exception message'))
|