Ticket #9354 (closed enhancement: fixed)
Opened 21 months ago
Last modified 10 months ago
[patch] missing i18n for TicketClone demo plugin
| Reported by: | hasienda <hoff.st@…> | Owned by: | hasienda <hoff.st@…> |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.13 |
| Component: | i18n | Version: | 0.12dev |
| Severity: | normal | Keywords: | i18n plugin |
| Cc: | |||
| Release Notes: |
ticket: Added the ticket clone sample plugin as an optional component. |
||
| API Changes: | |||
Description
looking at the current version in Trac trunk is disappointing in that case:
not trace of i18n work at TicketClone plugin code, but it shouldn't go like this for 0.12, the i18n release
Attachments
Change History
comment:1 Changed 21 months ago by hasienda <hoff.st@…>
comment:2 Changed 21 months ago by cboos
Right, single file plugins can't be localized, I'm afraid.
The TicketClone plugin could however graduate to tracopt (see #4686 for background), then its messages could be translated in the default catalog.
comment:3 Changed 21 months ago by hasienda <hoff.st@…>
Thanks for the hint, was actually just studying plugins history (emerging from a part of template/ticket.html).
Would you prefer moving to tracopt then? This is crucial, since otherwise I'd arrange for separate translation. Actually already working on a setup.py for packaging, but now it's still time to change it.
Changed 21 months ago by hasienda <hoff.st@…>
1st version: move plugin script to /trunk/tracopt
Changed 21 months ago by hasienda <hoff.st@…>
1st version: add i18n function
Changed 21 months ago by hasienda <hoff.st@…>
- Attachment msg-markup added
1st version: mark text for translation
comment:4 Changed 21 months ago by hasienda <hoff.st@…>
1st implementation, for the sake of clarity it consists of three patch files (taken directly from my Mercurial Queue)
comment:5 Changed 21 months ago by hasienda <hoff.st@…>
- Summary changed from missing i18n for TicketClone demo plugin to [patch] missing i18n for TicketClone demo plugin
comment:6 Changed 21 months ago by rblank
You should not use the % operator to expand strings after a _() call, but named arguments inside the call:
_("Cloned from #%(id)s:\n----\n%(description)s", id=ticket.id, description=ticket['description'])
comment:7 Changed 21 months ago by hasienda <hoff.st@…>
still learning Python, will adjust this, thanks
comment:8 Changed 21 months ago by hasienda <hoff.st@…>
there are other scripts at the perimeter of Trac's core code, that would profit from localizable messages:
trunk/
- sample-plugins/
- HelloWorld.py (maybe a 'wont-fix', or even add a HelloWorldIntl.py with i18n support for demonstration?)
- ticket_clone.py (starter of this ticket)
- workflow/
- CodeReview.py
- DeleteTicket.py
- StatusFixer.py
- VoteOperation.py
any comment on how to handle these?
Changed 21 months ago by hasienda <hoff.st@…>
- Attachment msg-markup.2 added
2nd version: mark text for translation with named substitutions
comment:9 Changed 21 months ago by hasienda <hoff.st@…>
Please see 2nd version of markup patch, that has the suggested named arguments in; further comments?
comment:10 Changed 20 months ago by cboos
- Milestone set to 0.13
comment:11 Changed 17 months ago by cboos
ticket['summary'] + _(" (cloned)")
should be replaced by something like:
_("%(summary)s (cloned)", summary=ticket['summary'])
comment:12 Changed 12 months ago by cboos
So this seems to be a bit in contradiction with #9910 (turning that single file plugin into an sample packaged plugin).
I'd prefer making it an optional feature for the ticket module, which is much simpler, both for i18n as requested here and for later activation (via the Plugins admin panel).
comment:13 Changed 12 months ago by cboos
- Owner set to cboos
comment:14 Changed 10 months ago by rblank
- Release Notes modified (diff)
- Resolution set to fixed
- Status changed from new to closed
Patch applied in [10686] with a few cosmetic corrections and the missing registration of the plugin in setup.py.
comment:15 Changed 10 months ago by rblank
- Owner changed from cboos to hasienda <hoff.st@…>



since we have a botton text in here, i18n is needed,
however we'll loose a nice one-file plugin, since message catalog stuff needs to be done in separate files, hence this will ultimately require for packaging etc.
this is a nice little task for a rainy day, I need it for a localized production system, so most likely this will be done within few hours, cheer up