A number of doc strings were not localized, wrap them in _().
Some messages were not localized, wrap them in _()

Fix a couple of failing tests:
The method name in RPC should not be unicode.
The doc attribute must use the .msg attribute for comparison.

Also clean up imports of _() The import should come from
ipalib or ipalib.text, not ugettext from request.

Pavel: You'll need to make a fix to plugins/migration.py, look for the FIXME comment. What you're doing with the doc string won't work with our localization framework. I implemented a workaround for the time being.

--
John Dennis <[email protected]>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
>From f0d9d2eebc9a297e6b1e05576c03f2c324be086b Mon Sep 17 00:00:00 2001
From: John Dennis <[email protected]>
Date: Fri, 5 Mar 2010 16:11:21 -0500
Subject: [PATCH 5/5] localize doc strings
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

A number of doc strings were not localized, wrap them in _().
Some messages were not localized, wrap them in _()

Fix a couple of failing tests:
The method name in RPC should not be unicode.
The doc attribute must use the .msg attribute for comparison.

Also clean up imports of _() The import should come from
ipalib or ipalib.text, not ugettext from request.
---
 ipalib/cli.py                        |    2 +-
 ipalib/frontend.py                   |    6 ++--
 ipalib/output.py                     |    7 +++--
 ipalib/plugins/aci.py                |    2 +-
 ipalib/plugins/baseldap.py           |    8 +++---
 ipalib/plugins/cert.py               |    2 +-
 ipalib/plugins/config.py             |    2 +-
 ipalib/plugins/group.py              |    2 +-
 ipalib/plugins/migration.py          |   46 ++++++++++++++++++---------------
 ipalib/plugins/misc.py               |    8 +++---
 ipalib/plugins/netgroup.py           |    2 +-
 ipalib/plugins/pwpolicy.py           |    2 +-
 ipalib/plugins/service.py            |    2 +-
 ipaserver/plugins/dogtag.py          |    2 +-
 ipaserver/plugins/join.py            |    9 +++---
 ipaserver/plugins/selfsign.py        |    2 +-
 tests/test_ipalib/test_output.py     |    1 +
 tests/test_ipalib/test_parameters.py |    6 ++--
 tests/test_ipalib/test_rpc.py        |    4 +-
 tests/util.py                        |    2 -
 20 files changed, 61 insertions(+), 56 deletions(-)

diff --git a/ipalib/cli.py b/ipalib/cli.py
index a05722d..904d34d 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -40,7 +40,7 @@ import util
 from errors import PublicError, CommandError, HelpError, InternalError, NoSuchNamespaceError, ValidationError, NotFound
 from constants import CLI_TAB
 from parameters import Password, Bytes, File
-from request import ugettext as _
+from text import _
 
 
 def to_cli(name):
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index e3828bf..ba2e44e 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -782,12 +782,12 @@ class Command(HasParam):
             if isinstance(o, (Entry, ListOfEntries)):
                 yield Flag('all',
                     cli_name='all',
-                    doc='retrieve all attributes',
+                    doc=_('retrieve all attributes'),
                     exclude='webui',
                 )
                 yield Flag('raw',
                     cli_name='raw',
-                    doc='print entries as stored on the server',
+                    doc=_('print entries as stored on the server'),
                     exclude='webui',
                 )
                 return
@@ -880,7 +880,7 @@ class LocalOrRemote(Command):
 
     takes_options = (
         Flag('server?',
-            doc='Forward to server instead of running locally',
+            doc=_('Forward to server instead of running locally'),
         ),
     )
 
diff --git a/ipalib/output.py b/ipalib/output.py
index 757e715..354d802 100644
--- a/ipalib/output.py
+++ b/ipalib/output.py
@@ -24,6 +24,7 @@ Simple description of return values.
 from inspect import getdoc
 from types import NoneType
 from plugable import ReadOnly, lock
+from text import _
 
 
 class Output(ReadOnly):
@@ -88,7 +89,7 @@ class Output(ReadOnly):
 
 class Entry(Output):
     type = dict
-    doc = 'A dictionary representing an LDAP entry'
+    doc = _('A dictionary representing an LDAP entry')
 
 
 emsg = """%s.validate_output() => %s.validate():
@@ -96,7 +97,7 @@ emsg = """%s.validate_output() => %s.validate():
 
 class ListOfEntries(Output):
     type = (list, tuple)
-    doc = 'A list of LDAP entries'
+    doc = _('A list of LDAP entries')
 
     def validate(self, cmd, entries):
         assert isinstance(entries, self.type)
@@ -107,7 +108,7 @@ class ListOfEntries(Output):
                 )
 
 
-result = Output('result', doc='All commands should at least have a result')
+result = Output('result', doc=_('All commands should at least have a result'))
 
 summary = Output('summary', (unicode, NoneType),
     'User-friendly description of action performed'
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 4914efe..03e5639 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -78,7 +78,7 @@ _valid_permissions_values = [
 
 class ListOfACI(output.Output):
     type = (list, tuple)
-    doc = 'A list of ACI values'
+    doc = _('A list of ACI values')
 
     def validate(self, cmd, entries):
         assert isinstance(entries, self.type)
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 2266d85..31f4b4e 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -381,11 +381,11 @@ class LDAPAddMember(LDAPModMember):
         output.Entry('result'),
         output.Output('failed',
             type=dict,
-            doc='Members that could not be added',
+            doc=_('Members that could not be added'),
         ),
         output.Output('completed',
             type=int,
-            doc='Number of members added',
+            doc=_('Number of members added'),
         ),
     )
 
@@ -454,11 +454,11 @@ class LDAPRemoveMember(LDAPModMember):
         output.Entry('result'),
         output.Output('completed',
             type=int,
-            doc='Number of members removed',
+            doc=_('Number of members removed'),
         ),
         output.Output('failed',
             type=dict,
-            doc='Members that could not be removed',
+            doc=_('Members that could not be removed'),
         ),
     )
 
diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py
index e266c9a..a2ecce4 100644
--- a/ipalib/plugins/cert.py
+++ b/ipalib/plugins/cert.py
@@ -201,7 +201,7 @@ class cert_request(VirtualCommand):
     has_output = (
         Output('result',
             type=dict,
-            doc='Dictionary mapping variable name to value',
+            doc=_('Dictionary mapping variable name to value'),
         ),
     )
 
diff --git a/ipalib/plugins/config.py b/ipalib/plugins/config.py
index 31e29f5..b89f17c 100644
--- a/ipalib/plugins/config.py
+++ b/ipalib/plugins/config.py
@@ -85,7 +85,7 @@ class config(LDAPObject):
         Str('ipagroupsearchfields?',
             cli_name='groupsearch',
             label='Group search fields',
-            doc='A comma-separated list of fields to search when searching for groups',
+            doc=_('A comma-separated list of fields to search when searching for groups'),
         ),
         Bool('ipamigrationenabled?',
             cli_name='enable_migration',
diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
index 14b73ce..a785294 100644
--- a/ipalib/plugins/group.py
+++ b/ipalib/plugins/group.py
@@ -148,7 +148,7 @@ class group_mod(LDAPUpdate):
     takes_options = LDAPUpdate.takes_options + (
         Flag('posix',
              cli_name='posix',
-             doc='change to posix group',
+             doc=_('change to posix group'),
         ),
     )
 
diff --git a/ipalib/plugins/migration.py b/ipalib/plugins/migration.py
index 5ae6356..d64aeac 100644
--- a/ipalib/plugins/migration.py
+++ b/ipalib/plugins/migration.py
@@ -32,14 +32,13 @@ from ipalib import Command, List, Password, Str
 from ipalib.cli import to_cli
 from ipaserver.plugins.ldap2 import ldap2
 from ipalib import _
+from ipalib.text import Gettext # FIXME: remove once the other Gettext FIXME is removed
 
 
 # USER MIGRATION CALLBACKS AND VARS
 
-_krb_err_msg = 'Kerberos principal %s already exists. ' \
-               'Use \'ipa user-mod\' to set it manually.'
-_grp_err_msg = 'Failed to add user to the default group. ' \
-               'Use \'ipa group-add-member\' to add manually.'
+_krb_err_msg = _('Kerberos principal %s already exists. Use \'ipa user-mod\' to set it manually.')
+_grp_err_msg = _('Failed to add user to the default group. Use \'ipa group-add-member\' to add manually.')
 
 
 def _pre_migrate_user(ldap, pkey, dn, entry_attrs, failed, config, ctx):
@@ -168,7 +167,7 @@ class migrate_ds(Command):
         ),
         Password('bindpw',
             cli_name='password',
-            doc='bind password',
+            doc=_('bind password'),
         ),
     )
 
@@ -198,30 +197,34 @@ class migrate_ds(Command):
     has_output = (
         output.Output('result',
             type=dict,
-            doc='Lists of objects migrated; categorized by type.',
+            doc=_('Lists of objects migrated; categorized by type.'),
         ),
         output.Output('failed',
             type=dict,
-            doc='Lists of objects that could not be migrated; ' \
-                'categorized by type.',
+            doc=_('Lists of objects that could not be migrated; categorized by type.'),
         ),
         output.Output('enabled',
             type=bool,
-            doc='False if migration mode was disabled.',
+            doc=_('False if migration mode was disabled.'),
         ),
     )
 
-    exclude_doc = 'comma-separated list of %s to exclude from migration'
-    truncated_err_msg = 'search results for objects to be migrated ' \
-                        'have been truncated by the server; migration ' \
-                        'process might be uncomplete\n'
-    migration_disabled_msg = 'Migration mode is disabled. ' \
-                             'Use \'ipa config-mod\' to enable it.'
-    pwd_migration_msg = 'Passwords have been migrated in pre-hashed format. ' \
-                        'IPA is unable to generate Kerberos keys unless provided ' \
-                        'with clear text passwords. All migrated users need to ' \
-                        'login at https://your.domain/ipa/migration/ before they ' \
-                        'can use their Kerberos accounts.'
+    exclude_doc = _('comma-separated list of %s to exclude from migration')
+
+    truncated_err_msg = _('''\
+search results for objects to be migrated
+have been truncated by the server;
+migration process might be uncomplete\n''')
+
+    migration_disabled_msg = _('''\
+Migration mode is disabled. Use \'ipa config-mod\' to enable it.''')
+
+    pwd_migration_msg = _('''\
+Passwords have been migrated in pre-hashed format.
+IPA is unable to generate Kerberos keys unless provided
+with clear text passwords. All migrated users need to
+login at https://your.domain/ipa/migration/ before they
+can use their Kerberos accounts.''')
 
     def get_options(self):
         """
@@ -233,7 +236,8 @@ class migrate_ds(Command):
         for ldap_obj_name in self.migrate_objects:
             ldap_obj = self.api.Object[ldap_obj_name]
             name = 'exclude_%ss' % to_cli(ldap_obj_name)
-            doc = self.exclude_doc % ldap_obj.object_name_plural
+            # FIXME: can't substitute strings static Gettext instance
+            doc = Gettext(self.exclude_doc % ldap_obj.object_name_plural)
             yield List(
                 '%s?' % name, cli_name=name, doc=doc, default=tuple(),
                 autofill=True
diff --git a/ipalib/plugins/misc.py b/ipalib/plugins/misc.py
index 0584654..428c712 100644
--- a/ipalib/plugins/misc.py
+++ b/ipalib/plugins/misc.py
@@ -43,15 +43,15 @@ class env(LocalOrRemote):
     has_output = (
         Output('result',
             type=dict,
-            doc='Dictionary mapping variable name to value',
+            doc=_('Dictionary mapping variable name to value'),
         ),
         Output('total',
             type=int,
-            doc='Total number of variables env (>= count)',
+            doc=_('Total number of variables env (>= count)'),
         ),
         Output('count',
             type=int,
-            doc='Number of variables returned (<= total)',
+            doc=_('Number of variables returned (<= total)'),
         ),
         summary,
     )
@@ -100,7 +100,7 @@ class plugins(LocalOrRemote):
         Output('result', dict, 'Dictionary mapping plugin names to bases'),
         Output('count',
             type=int,
-            doc='Number of plugins loaded',
+            doc=_('Number of plugins loaded'),
         ),
         summary,
     )
diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py
index 124b860..6fd0670 100644
--- a/ipalib/plugins/netgroup.py
+++ b/ipalib/plugins/netgroup.py
@@ -65,7 +65,7 @@ class netgroup(LDAPObject):
         Str('ipauniqueid?',
             cli_name='uuid',
             label='IPA unique ID',
-            doc='IPA unique ID',
+            doc=_('IPA unique ID'),
             flags=['no_create', 'no_update'],
         ),
         Str('member_user?',
diff --git a/ipalib/plugins/pwpolicy.py b/ipalib/plugins/pwpolicy.py
index a10d07d..d906605 100644
--- a/ipalib/plugins/pwpolicy.py
+++ b/ipalib/plugins/pwpolicy.py
@@ -277,7 +277,7 @@ class pwpolicy_del(crud.Delete):
     msg_summary = _('Deleted policy for group "%(value)s"')
     takes_options = (
         Str('group',
-            doc='Group to remove policy from',
+            doc=_('Group to remove policy from'),
         ),
     )
 
diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py
index 36988bd..0a878ca 100644
--- a/ipalib/plugins/service.py
+++ b/ipalib/plugins/service.py
@@ -141,7 +141,7 @@ class service_add(LDAPCreate):
     member_attributes = ['managedby']
     takes_options = (
         Flag('force',
-            doc='force principal name even if not in DNS',
+            doc=_('force principal name even if not in DNS'),
         ),
     )
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
diff --git a/ipaserver/plugins/dogtag.py b/ipaserver/plugins/dogtag.py
index 19e2328..4c572da 100644
--- a/ipaserver/plugins/dogtag.py
+++ b/ipaserver/plugins/dogtag.py
@@ -1201,7 +1201,7 @@ from ipaserver.plugins import rabase
 from ipalib.errors import NetworkError, CertificateOperationError
 from ipalib.constants import TYPE_ERROR
 from ipapython import dogtag
-from ipalib.request import ugettext as _
+from ipalib import _
 
 class ra(rabase.rabase):
     """
diff --git a/ipaserver/plugins/join.py b/ipaserver/plugins/join.py
index fe9f88d..e2f72bf 100644
--- a/ipaserver/plugins/join.py
+++ b/ipaserver/plugins/join.py
@@ -25,6 +25,7 @@ from ipalib import api, util
 from ipalib import Command, Str
 from ipalib import errors
 import krbV
+from ipalib import _
 
 def get_realm():
     """
@@ -50,7 +51,7 @@ class join(Command):
         Str('cn',
             validate_host,
             cli_name='hostname',
-            doc="The hostname to register as",
+            doc=_("The hostname to register as"),
             create_default=lambda **kw: unicode(util.get_fqdn()),
             autofill=True,
             #normalizer=lamda value: value.lower(),
@@ -58,17 +59,17 @@ class join(Command):
     )
     takes_options= (
         Str('realm',
-            doc="The IPA realm",
+            doc=_("The IPA realm"),
             create_default=lambda **kw: get_realm(),
             autofill=True,
         ),
         Str('nshardwareplatform?',
             cli_name='platform',
-            doc='Hardware platform of the host (e.g. Lenovo T61)',
+            doc=_('Hardware platform of the host (e.g. Lenovo T61)'),
         ),
         Str('nsosversion?',
             cli_name='os',
-            doc='Operating System and version of the host (e.g. Fedora 9)',
+            doc=_('Operating System and version of the host (e.g. Fedora 9)'),
         ),
     )
 
diff --git a/ipaserver/plugins/selfsign.py b/ipaserver/plugins/selfsign.py
index 7dbe053..67b8efe 100644
--- a/ipaserver/plugins/selfsign.py
+++ b/ipaserver/plugins/selfsign.py
@@ -46,7 +46,7 @@ from ipaserver.plugins import rabase
 from ipaserver.install import certs
 import tempfile
 from pyasn1 import error
-from ipalib.request import ugettext as _
+from ipalib import  _
 from pyasn1.codec.der import encoder
 from ipalib.plugins.cert import get_csr_hostname
 
diff --git a/tests/test_ipalib/test_output.py b/tests/test_ipalib/test_output.py
index ceb825c..19d728f 100644
--- a/tests/test_ipalib/test_output.py
+++ b/tests/test_ipalib/test_output.py
@@ -24,6 +24,7 @@ Test the `ipalib.output` module.
 from tests.util import raises, ClassChecker
 from ipalib import output
 from ipalib.frontend import Command
+from ipalib import _
 
 class test_Output(ClassChecker):
     """
diff --git a/tests/test_ipalib/test_parameters.py b/tests/test_ipalib/test_parameters.py
index b5a01fd..038941b 100644
--- a/tests/test_ipalib/test_parameters.py
+++ b/tests/test_ipalib/test_parameters.py
@@ -31,7 +31,7 @@ from tests.data import binary_bytes, utf8_bytes, unicode_str
 from ipalib import parameters, request, errors, config
 from ipalib.constants import TYPE_ERROR, CALLABLE_ERROR, NULLS
 from ipalib.errors import ValidationError
-
+from ipalib import _
 
 class test_DefaultFrom(ClassChecker):
     """
@@ -192,9 +192,9 @@ class test_Param(ClassChecker):
         assert o.flags == frozenset()
 
         # Test that doc defaults from label:
-        o = self.cls('my_param', doc='Hello world')
+        o = self.cls('my_param', doc=_('Hello world'))
         assert o.label.msg == 'my_param'
-        assert o.doc == 'Hello world'
+        assert o.doc.msg == 'Hello world'
 
         o = self.cls('my_param', label='My Param')
         assert o.label == 'My Param'
diff --git a/tests/test_ipalib/test_rpc.py b/tests/test_ipalib/test_rpc.py
index d5dd38c..83092b5 100644
--- a/tests/test_ipalib/test_rpc.py
+++ b/tests/test_ipalib/test_rpc.py
@@ -128,7 +128,7 @@ def test_xml_dumps():
     # Test serializing an RPC request:
     data = f(params, 'the_method')
     (p, m) = loads(data)
-    assert_equal(m, u'the_method')
+    assert_equal(m, 'the_method')
     assert type(p) is tuple
     assert rpc.xml_unwrap(p) == params
 
@@ -159,7 +159,7 @@ def test_xml_loads():
     # Test un-serializing an RPC request:
     data = dumps(wrapped, 'the_method', allow_none=True)
     (p, m) = f(data)
-    assert_equal(m, u'the_method')
+    assert_equal(m, 'the_method')
     assert_equal(p, params)
 
     # Test un-serializing an RPC response:
diff --git a/tests/util.py b/tests/util.py
index 4d5fea6..f3215e7 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -31,8 +31,6 @@ import ipalib
 from ipalib.plugable import Plugin
 from ipalib.request import context
 
-
-
 class TempDir(object):
     def __init__(self):
         self.__path = tempfile.mkdtemp(prefix='ipa.tests.')
-- 
1.6.6.1

_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to