i18n.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright 2014 IBM Corp.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. """oslo.i18n integration module.
  15. See http://docs.openstack.org/developer/oslo.i18n/usage.html .
  16. """
  17. import oslo_i18n as i18n
  18. DOMAIN = 'coriolis'
  19. _translators = i18n.TranslatorFactory(domain=DOMAIN)
  20. # The primary translation function using the well-known name "_"
  21. _ = _translators.primary
  22. # Translators for log levels.
  23. #
  24. # The abbreviated names are meant to reflect the usual use of a short
  25. # name like '_'. The "L" is for "log" and the other letter comes from
  26. # the level.
  27. _LI = _translators.log_info
  28. _LW = _translators.log_warning
  29. _LE = _translators.log_error
  30. _LC = _translators.log_critical
  31. def enable_lazy(enable=True):
  32. return i18n.enable_lazy(enable)
  33. def translate(value, user_locale=None):
  34. return i18n.translate(value, user_locale)
  35. def get_available_languages():
  36. return i18n.get_available_languages(DOMAIN)