~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export_pot.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-28 11:39:48 UTC
  • mfrom: (5993.1.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20110628113948-nrljydmsqi6kf01c
(vila) Start implementing command help text localization (Inada Naoki)

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
           'msgid %s\n' % _normalize(s) +
77
77
           'msgstr ""\n')
78
78
 
79
 
def _poentry_per_paragraph(outf, path, lineno, msgid):
 
79
def _poentry_per_paragraph(outf, path, lineno, msgid, filter=lambda x: False):
80
80
    # TODO: How to split long help?
81
81
    paragraphs = msgid.split('\n\n')
82
82
    for p in paragraphs:
 
83
        if filter(p):
 
84
            continue
83
85
        _poentry(outf, path, lineno, p)
84
86
        lineno += p.count('\n') + 2
85
87
 
145
147
                     'help of %r option of %r command' % (name, cmd.name()))
146
148
 
147
149
 
148
 
def _write_command_help(outf, cmd_name, cmd):
 
150
def _write_command_help(outf, cmd):
149
151
    path = inspect.getfile(cmd.__class__)
150
152
    if path.endswith('.pyc'):
151
153
        path = path[:-1]
155
157
    lineno = offsets[cmd.__doc__]
156
158
    doc = inspect.getdoc(cmd)
157
159
 
158
 
    _poentry_per_paragraph(outf, path, lineno, doc)
 
160
    def filter(p):
 
161
        # ':Usage:' has special meaning in help topics.
 
162
        # This is usage example of command and should not be translated.
 
163
        if p.splitlines()[0] == ':Usage:':
 
164
            return True
 
165
 
 
166
    _poentry_per_paragraph(outf, path, lineno, doc, filter)
159
167
    _command_options(outf, path, cmd)
160
168
 
 
169
 
161
170
def _command_helps(outf):
162
171
    """Extract docstrings from path.
163
172
 
172
181
        if command.hidden:
173
182
            continue
174
183
        note("Exporting messages from builtin command: %s", cmd_name)
175
 
        _write_command_help(outf, cmd_name, command)
 
184
        _write_command_help(outf, command)
176
185
 
177
186
    plugin_path = plugin.get_core_plugin_path()
178
187
    core_plugins = glob(plugin_path + '/*/__init__.py')
189
198
            continue
190
199
        note("Exporting messages from plugin command: %s in %s",
191
200
             cmd_name, command.plugin_name())
192
 
        _write_command_help(outf, cmd_name, command)
 
201
        _write_command_help(outf, command)
193
202
 
194
203
 
195
204
def _error_messages(outf):