Add common methods required to allow translation of REST API responses

REST API responses (particularly errors) are always returned to
consumers in the locale of the operating system. This change adds common
methods that will be required by other components in the process of
translating the API responses to a locale requested by the API consumer.

The patch set includes the following changes:

1) An installer for the lazy _() function is provided. Services that
want to use the Message class to do delayed translation will just have
to set the new 'lazy' flag in the existing gettext.install().

2) A method to retrieve all available languages in a given translation
domain in order to pick one that will be used to translate the
response to the user.

3) A utility method to translate a Message.

Co-authored-by: Mathew Odden <mrodden@us.ibm.com>
Co-authored-by: Ben Nemec <openstack@nemebean.com>

This partially implements bp user-locale-api.

Change-Id: I27640a3c8b255be51bc6396d238098bd25af61ec
This commit is contained in:
Luis A. Garcia
2013-07-19 22:18:59 +00:00
parent f58c936582
commit 319888102f
3 changed files with 165 additions and 35 deletions

View File

@@ -18,6 +18,7 @@ qpid-python
six
netaddr
pycrypto>=2.6
Babel>=0.9.6
-f http://tarballs.openstack.org/oslo.config/oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3
oslo.config>=1.2.0a3