~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export_pot.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-14 16:54:26 UTC
  • mfrom: (6216.1.1 remove-this-file)
  • Revision ID: pqm@pqm.ubuntu.com-20111014165426-tjix4e6idryf1r2z
(jelmer) Remove an accidentally committed .THIS file. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    errors,
29
29
    help_topics,
30
30
    plugin,
 
31
    help,
31
32
    )
32
33
from bzrlib.trace import (
33
34
    mutter,
34
35
    note,
35
36
    )
 
37
from bzrlib.i18n import gettext
36
38
 
37
39
 
38
40
def _escape(s):
118
120
        if getattr(opt, 'title', None):
119
121
            lineno = offsets.get(opt.title, 9999)
120
122
            if lineno == 9999:
121
 
                note("%r is not found in bzrlib/option.py" % opt.title)
 
123
                note(gettext("%r is not found in bzrlib/option.py") % opt.title)
122
124
            _poentry(outf, path, lineno, opt.title,
123
125
                     'title of %r option' % name)
124
126
        if getattr(opt, 'help', None):
125
127
            lineno = offsets.get(opt.help, 9999)
126
128
            if lineno == 9999:
127
 
                note("%r is not found in bzrlib/option.py" % opt.help)
 
129
                note(gettext("%r is not found in bzrlib/option.py") % opt.help)
128
130
            _poentry(outf, path, lineno, opt.help,
129
131
                     'help of %r option' % name)
130
132
 
167
169
    _command_options(outf, path, cmd)
168
170
 
169
171
 
170
 
def _command_helps(outf):
 
172
def _command_helps(outf, plugin_name=None):
171
173
    """Extract docstrings from path.
172
174
 
173
175
    This respects the Bazaar cmdtable/table convention and will
180
182
        command = _mod_commands.get_cmd_object(cmd_name, False)
181
183
        if command.hidden:
182
184
            continue
183
 
        note("Exporting messages from builtin command: %s", cmd_name)
 
185
        if plugin_name is not None:
 
186
            # only export builtins if we are not exporting plugin commands
 
187
            continue
 
188
        note(gettext("Exporting messages from builtin command: %s"), cmd_name)
184
189
        _write_command_help(outf, command)
185
190
 
186
191
    plugin_path = plugin.get_core_plugin_path()
187
192
    core_plugins = glob(plugin_path + '/*/__init__.py')
188
193
    core_plugins = [os.path.basename(os.path.dirname(p))
189
194
                        for p in core_plugins]
190
 
    # core plugins
 
195
    # plugins
191
196
    for cmd_name in _mod_commands.plugin_command_names():
192
197
        command = _mod_commands.get_cmd_object(cmd_name, False)
193
198
        if command.hidden:
194
199
            continue
195
 
        if command.plugin_name() not in core_plugins:
 
200
        if plugin_name is not None and command.plugin_name() != plugin_name:
 
201
            # if we are exporting plugin commands, skip plugins we have not specified.
 
202
            continue
 
203
        if plugin_name is None and command.plugin_name() not in core_plugins:
196
204
            # skip non-core plugins
197
205
            # TODO: Support extracting from third party plugins.
198
206
            continue
199
 
        note("Exporting messages from plugin command: %s in %s",
200
 
             cmd_name, command.plugin_name())
 
207
        note(gettext("Exporting messages from plugin command: {0} in {1}").format(
 
208
             cmd_name, command.plugin_name() ))
201
209
        _write_command_help(outf, command)
202
210
 
203
211
 
221
229
            continue
222
230
        fmt = getattr(klass, "_fmt", None)
223
231
        if fmt:
224
 
            note("Exporting message from error: %s", name)
 
232
            note(gettext("Exporting message from error: %s"), name)
225
233
            _poentry(outf, 'bzrlib/errors.py',
226
234
                     offsets.get(fmt, 9999), fmt)
227
235
 
234
242
                    outf,
235
243
                    'dummy/help_topics/'+key+'/detail.txt',
236
244
                    1, doc)
237
 
 
 
245
        elif callable(doc): # help topics from files
 
246
            _poentry_per_paragraph(
 
247
                    outf,
 
248
                    'en/help_topics/'+key+'.txt',
 
249
                    1, doc(key))
238
250
        summary = topic_registry.get_summary(key)
239
251
        if summary is not None:
240
252
            _poentry(outf, 'dummy/help_topics/'+key+'/summary.txt',
241
253
                     1, summary)
242
254
 
243
 
def export_pot(outf):
 
255
def export_pot(outf, plugin=None):
244
256
    global _FOUND_MSGID
245
257
    _FOUND_MSGID = set()
246
 
    _standard_options(outf)
247
 
    _command_helps(outf)
248
 
    _error_messages(outf)
249
 
    # disable exporting help topics until we decide  how to translate it.
250
 
    #_help_topics(outf)
 
258
    if plugin is None:
 
259
        _standard_options(outf)
 
260
        _command_helps(outf)
 
261
        _error_messages(outf)
 
262
        _help_topics(outf)
 
263
    else:
 
264
        _command_helps(outf, plugin)