summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis A. Garcia <luis@linux.vnet.ibm.com>2013-10-31 16:44:59 +0000
committerLuis A. Garcia <luis@linux.vnet.ibm.com>2013-10-31 16:44:59 +0000
commit221eb702651ffc747fca39a551291a81beee92cd (patch)
treee3c2b329233ce6004b57c05f9c566e2409fe26a3
parent4ad655eb9cecec931b92a894538f92306b438af4 (diff)
downloadoslo-serialization-221eb702651ffc747fca39a551291a81beee92cd.tar.gz
Translation Message improvements
The improvements to the current Message implementation include: * Implementing a new method translate() to explicitely perform the translation of a Message object, instead of relying on setting the 'locale' property. * All of the codebase assumes _() is a unicode object, so make the Message unicode, that will always behave as unicode, except for the fact that it has the extra ability to translate() on demand. * Remove the internal representation of the translated Message (i.e. the data property) and rely on parent implementations. * Enhancement to the corresponding TestTranslation class to enable fake translations for multiple locales. With this patch the REST API translation in the other projects will work with very minimal or no impact after re-enabling the 'lazy' _(). Partially implements: bp i18n-messages Change-Id: I2dbddf422e79fd4474dede1e7c7ed229c89dc30c
-rw-r--r--tests/unit/test_jsonutils.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py
index c545ef1..6700924 100644
--- a/tests/unit/test_jsonutils.py
+++ b/tests/unit/test_jsonutils.py
@@ -183,14 +183,14 @@ class ToPrimitiveTestCase(test.BaseTestCase):
def test_message_with_param(self):
message_with_params = 'A message with param: %s'
- msg = gettextutils.Message(message_with_params, 'test_domain')
+ msg = gettextutils.Message(message_with_params, domain='test_domain')
msg = msg % 'test_domain'
ret = jsonutils.to_primitive(msg)
self.assertEqual(msg, ret)
def test_message_with_named_param(self):
message_with_params = 'A message with params: %(param)s'
- msg = gettextutils.Message(message_with_params, 'test_domain')
+ msg = gettextutils.Message(message_with_params, domain='test_domain')
msg = msg % {'param': 'hello'}
ret = jsonutils.to_primitive(msg)
self.assertEqual(msg, ret)