Added all common modules in conductor directory
[optf/has.git] / conductor / conductor / i18n.py
1 #
2 # -------------------------------------------------------------------------
3 #   Copyright (c) 2015-2017 AT&T Intellectual Property
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #
17 # -------------------------------------------------------------------------
18 #
19
20 """oslo.i18n integration module.
21
22 See http://docs.openstack.org/developer/oslo.i18n/usage.html
23
24 """
25
26 import oslo_i18n
27
28 DOMAIN = "conductor"
29
30 _translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
31
32 # The primary translation function using the well-known name "_"
33 _ = _translators.primary
34
35 # The contextual translation function using the name "_C"
36 # requires oslo.i18n >=2.1.0
37 _C = _translators.contextual_form
38
39 # The plural translation function using the name "_P"
40 # requires oslo.i18n >=2.1.0
41 _P = _translators.plural_form
42
43 # Translators for log levels.
44 #
45 # The abbreviated names are meant to reflect the usual use of a short
46 # name like '_'. The "L" is for "log" and the other letter comes from
47 # the level.
48 _LI = _translators.log_info
49 _LW = _translators.log_warning
50 _LE = _translators.log_error
51 _LC = _translators.log_critical
52
53
54 def translate(value, user_locale):
55     return oslo_i18n.translate(value, user_locale)
56
57
58 def get_available_languages():
59     return oslo_i18n.get_available_languages(DOMAIN)