~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export_pot.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-27 15:42:09 UTC
  • mfrom: (5993 +trunk)
  • mto: (5993.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5994.
  • Revision ID: v.ladeuil+lp@free.fr-20110627154209-azubuhbuxsz109hq
Merge trunk

Show diffs side-by-side

added added

removed removed

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