Merge "Add i18n translation to common 2/5"

This commit is contained in:
Jenkins 2017-01-17 21:24:20 +00:00 committed by Gerrit Code Review
commit 154932cfb4
2 changed files with 8 additions and 7 deletions

View File

@ -77,7 +77,7 @@ class Limit(object):
self.remaining = int(value)
if value <= 0:
raise ValueError("Limit value must be > 0")
raise ValueError(_("Limit value must be > 0"))
self.last_request = None
self.next_request = None
@ -299,15 +299,15 @@ class Limiter(object):
for group in limits.split(';'):
group = group.strip()
if group[:1] != '(' or group[-1:] != ')':
raise ValueError("Limit rules must be surrounded by "
"parentheses")
raise ValueError(_("Limit rules must be surrounded by "
"parentheses"))
group = group[1:-1]
# Extract the Limit arguments
args = [a.strip() for a in group.split(',')]
if len(args) != 5:
raise ValueError("Limit rules must contain the following "
"arguments: verb, uri, regex, value, unit")
raise ValueError(_("Limit rules must contain the following "
"arguments: verb, uri, regex, value, unit"))
# Pull out the arguments
verb, uri, regex, value, unit = args
@ -321,7 +321,7 @@ class Limiter(object):
# Convert unit
unit = unit.upper()
if unit not in Limit.UNIT_MAP:
raise ValueError("Invalid units specified")
raise ValueError(_("Invalid units specified"))
unit = Limit.UNIT_MAP[unit]
# Build a limit

View File

@ -18,6 +18,7 @@
from oslo_utils.importutils import import_class
from trove.common import cfg
from trove.common.i18n import _
from trove.common import remote
CONF = cfg.CONF
@ -91,7 +92,7 @@ class RemoteModelBase(ModelBase):
# if the object is a list, it will turn it into a list of hash's again
def data(self, **options):
if self._data_object is None:
raise LookupError("data object is None")
raise LookupError(_("data object is None"))
if isinstance(self._data_object, list):
return [self._data_item(item) for item in self._data_object]
else: