From a95eaeac8e07b8ccd173b0f408575cc9a0d508fc Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 4 Jul 2012 08:52:47 -0400 Subject: Internationalization for public errors Currently, we throw many public exceptions without proper i18n. Wrap natural-language error messages in _() so they can be translated. In the service plugin, raise NotFound errors using handle_not_found helper so the error message contains the offending service. Use ScriptError instead of NotFoundError in bindinstance install. https://fedorahosted.org/freeipa/ticket/1953 --- ipalib/plugins/entitle.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ipalib/plugins/entitle.py') diff --git a/ipalib/plugins/entitle.py b/ipalib/plugins/entitle.py index 67e7f959..1b821053 100644 --- a/ipalib/plugins/entitle.py +++ b/ipalib/plugins/entitle.py @@ -147,7 +147,8 @@ def get_uuid(ldap): entry_attrs, 'ipaentitlementid', api.env.container_entitlements, ) if not ldap.can_read(dn, 'userpkcs12'): - raise errors.ACIError(info='not allowed to perform this command') + raise errors.ACIError( + info=_('not allowed to perform this command')) if not 'userpkcs12' in result: return (None, uuid, None, None) @@ -338,7 +339,9 @@ class entitle_consume(LDAPUpdate): available = result['quantity'] - result['consumed'] if quantity > available: - raise errors.ValidationError(name='quantity', error='There are only %d entitlements left' % available) + raise errors.ValidationError( + name='quantity', + error=_('There are only %d entitlements left') % available) try: cp = UEPConnection(handler='/candlepin', cert_file=certfile, key_file=keyfile) @@ -508,12 +511,13 @@ class entitle_register(LDAPCreate): def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): dn = DN(self.obj.container_dn, self.api.env.basedn) if not ldap.can_add(dn): - raise errors.ACIError(info='No permission to register') + raise errors.ACIError(info=_('No permission to register')) os.environ['LANG'] = 'en_US' locale.setlocale(locale.LC_ALL, '') if 'ipaentitlementid' in options: - raise errors.ValidationError(name='ipaentitlementid', error='Registering to specific UUID is not supported yet.') + raise errors.ValidationError(name='ipaentitlementid', + error=_('Registering to specific UUID is not supported yet.')) try: registrations = api.Command['entitle_find']() -- cgit