433 | | The default `cleanup_keywords` (the `Option` subclasses) are not automatically `keywords` however. The corresponding option for the `extract_messages` section of the `setup.cfg` file should therefore contain the `cleandoc_` token, or the various `Config` subclasses together with the position of the doc argument in that subclass. |
434 | | As a (somewhat complex) example, see the following excerpt from Trac's [source:tags/trac-1.0/setup.cfg setup.cfg] file: |
| 433 | The default `cleanup_keywords` (the `Option` subclasses) are not automatically `keywords` however. The corresponding option for the `[extract_messages]` section of the `setup.cfg` file should therefore contain the `cleandoc_` token, or the various `Config` subclasses together with the position of the doc argument in that subclass. |
| 434 | As an example, see the following excerpt from the SpamFilter plugin [source:plugins/1.0/spam-filter/setup.cfg setup.cfg] file: |
438 | | copyright_holder = Edgewall Software |
439 | | msgid_bugs_address = trac-dev@googlegroups.com |
440 | | output_file = trac/locale/tracini.pot |
441 | | keywords = ConfigSection:2 Option:4 BoolOption:4 IntOption:4 FloatOption:4 ListOption:6 ChoiceOption:4 PathOption:4 ExtensionOption:5 OrderedExtensionsOption:6 |
442 | | no-default-keywords = yes |
443 | | mapping_file = tracini.cfg |
444 | | }}} |
445 | | |
| 438 | msgid_bugs_address = [...] |
| 439 | output_file = tracspamfilter/locale/messages.pot |
| 440 | keywords = _ ngettext:1,2 N_ tag_ Option:4 BoolOption:4 IntOption:4 ListOption:6 ExtensionOption:5 |
| 441 | width = 72 |
| 442 | }}} |
| 443 | This makes it possible for the extractor to get the doc strings from those options automatically. For example, in [source:plugins/1.0/spam-filter/tracspamfilter/adapters.py#?IntOption adapters.py]: |
| 444 | {{{#!python |
| 445 | class AttachmentFilterAdapter(Component): |
| 446 | """Interface to check attachment uploads for spam. |
| 447 | """ |
| 448 | implements(IAttachmentManipulator) |
| 449 | |
| 450 | sample_size = IntOption('spam-filter', 'attachment_sample_size', 16384, |
| 451 | """The number of bytes from an attachment to pass through the spam |
| 452 | filters.""", doc_domain='tracspamfilter') |
| 453 | }}} |
| 454 | as you can see, it's also necessary to specify the //domain//, otherwise the lookup of the translated message at runtime (within the ![[TracIni]] macro, typically) will fail. |