From fc842e36504d39221fbfdafbaf8996b63e20de57 Mon Sep 17 00:00:00 2001 From: Pavel Zuna Date: Mon, 21 Feb 2011 14:54:05 -0500 Subject: Use pygettext to generate translatable strings from plugin files. This patch replaces xgettext with a custom pygettext to generate translatable strings from plugin files in ipalib/plugins. pygettext was modified to handle plural forms (credit goes to Jan Hendrik Goellner) and had some bugs fixed by myself. We only use it for plugins, because it's the only place where we need to extract docstrings for the built-in help system. I also had to make some changes to the way the built-in documentation systems gets docstrings from modules for this to work. --- ipalib/cli.py | 2 +- ipalib/plugable.py | 5 ++--- ipalib/plugins/internal.py | 10 +++------- 3 files changed, 6 insertions(+), 11 deletions(-) (limited to 'ipalib') diff --git a/ipalib/cli.py b/ipalib/cli.py index fa1dba8d..60afb7d0 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -706,7 +706,7 @@ class help(frontend.Local): self.print_commands(name) elif name in self.Command: cmd = self.Command[name] - print 'Purpose: %s' % cmd.doc + print 'Purpose: %s' % unicode(cmd.doc).strip() self.Backend.cli.build_parser(cmd).print_help() elif mod_name in sys.modules: self.print_commands(name) diff --git a/ipalib/plugable.py b/ipalib/plugable.py index da02d87f..92e6392a 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -182,9 +182,8 @@ class Plugin(ReadOnly): self.bases = tuple( '%s.%s' % (b.__module__, b.__name__) for b in cls.__bases__ ) - doc = inspect.getdoc(cls) - self.doc = _(doc) - if doc is None: + self.doc = _(cls.__doc__) + if self.doc is None: self.summary = '<%s>' % self.fullname else: self.summary = unicode(self.doc).split('\n\n', 1)[0] diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index f25e429e..ae8bf3b9 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -114,14 +114,11 @@ class i18n_messages(Command): "privilege_withdrawn":_("Privilege Withdrawn"), "aa_compromise":_("AA Compromise"), "revoke_confirmation":_( - "To confirm your intention to revoke this certificate, "+ - "select a reason from the pull-down list, and click "+ - "the \"Revoke\" button."), + "To confirm your intention to revoke this certificate, select a reason from the pull-down list, and click the \"Revoke\" button."), "note":_("Note"), "reason":_("Reason for Revocation"), "restore_confirmation":_( - "To confirm your intention to restore this certificate, "+ - "click the \"Restore\" button."), + "To confirm your intention to restore this certificate, click the \"Restore\" button."), "issued_to":_("Issued To"), "common_name":_("Common Name"), "organization":_("Organization"), @@ -351,8 +348,7 @@ class i18n_messages(Command): "unselect_all":_("Unselect All"), "delete_confirm":_("Are you sure you want to delete selected entries?"), "truncated":_( - "Query returned results than configured size limit will show. " + - "First ${counter} results shown."), + "Query returned results than configured size limit will show. First ${counter} results shown."), }, "details":{ "general":_("General"), -- cgit