#9192 closed defect (fixed)
Better i18n code for TracAnnouncer
Reported by: | Jun Omae | Owned by: | Steffen Hoffmann |
---|---|---|---|
Priority: | normal | Component: | AnnouncerPlugin |
Severity: | normal | Keywords: | i18n |
Cc: | Robert Corsaro, Jordi Mallach | Trac Release: | 0.12 |
Description
In prefs_announcer_manage_subscriptions.html
, extract_messages
command extracts a generic word rules
. The term will be difficult to translate into Japanese. I think it should use i18n:msg
in the element like the following.
-
announcer/templates/prefs_announcer_manage_subscriptions.html
diff --git a/announcer/templates/prefs_announcer_manage_subscriptions.html b/announcer/templates/prefs_announcer_manage_subscription index 242bb71..e3de7bb 100644
a b 19 19 </p> 20 20 <div class="announcer_preference_box"> 21 21 <div py:for="distributor, rules in data['rules'].iteritems()" class="ruleset"> 22 <div class="announcer_preference_title" >22 <div class="announcer_preference_title" i18n:msg="distributor"> 23 23 ${distributor} rules 24 24 </div> 25 25 <div class="announcer_preference_options">
In ticket_email_mimic.html
, the template has no i18n:*
derectives and it seems that the plugin always sends English notification mail. If we don't need to translate, we can use xml:lang="en"
which isn't extracted from the element and the children.
-
announcer/templates/ticket_email_mimic.html
diff --git a/announcer/templates/ticket_email_mimic.html b/announcer/templates/ticket_email_mimic.html index b5ed455..fd2124c 100644
a b 1 1 <html xmlns="http://www.w3.org/1999/xhtml" 2 2 xmlns:py="http://genshi.edgewall.org/" 3 xmlns:xi="http://www.w3.org/2001/XInclude"> 3 xmlns:xi="http://www.w3.org/2001/XInclude" 4 xml:lang="en"> 4 5 <head> 5 6 <title>#${ticket.id}: ${ticket['summary']}</title> 6 7
Attachments (0)
Change History (11)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
This plugin passes formatted string to gettext
method. I think that codes should be as the following patch.
-
announcer/distributors/mail.py
diff --git a/announcer/distributors/mail.py b/announcer/distributors/mail.py index 3a9f6d6..122ad92 100644
a b class EmailDistributor(Component): 408 408 self._charset.input_codec = None 409 409 self._charset.output_charset = 'ascii' 410 410 else: 411 raise TracError(_('Invalid email encoding setting: %s'%pref)) 411 raise TracError(_("Invalid email encoding setting: %(encoding)s", 412 encoding=pref)) 412 413 413 414 def _message_id(self, realm): 414 415 """Generate a predictable, but sufficiently unique message ID.""" -
announcer/locale/de/LC_MESSAGES/announcer.po
diff --git a/announcer/locale/de/LC_MESSAGES/announcer.po b/announcer/locale/de/LC_MESSAGES/announcer.po index a850ce7..eaa0158 100644
a b msgstr "Ticket-Abonnement basierend auf Komponenten" 77 77 78 78 #: announcer/subscribers.py:526 79 79 #, python-format 80 msgid "notify me when I'm listed in any of the (% s) fields"80 msgid "notify me when I'm listed in any of the (%(fields)s) fields" 81 81 msgstr "" 82 "Benachrichtigung an mich, wenn ich in einem der (% s) Felder eingetragen"83 " bin"82 "Benachrichtigung an mich, wenn ich in einem der (%(fields)s) Felder " 83 "eingetragen bin" 84 84 85 85 #: announcer/subscribers.py:583 86 86 msgid "notify me on ticket changes in one of my subscribed groups" … … msgstr "Allgemeine Wiki-Abonnements" 132 132 133 133 #: announcer/distributors/mail.py:411 134 134 #, python-format 135 msgid "Invalid email encoding setting: % s"136 msgstr "Ungültige Einstellung der E-Mail-Codierung: % s"135 msgid "Invalid email encoding setting: %(encoding)s" 136 msgstr "Ungültige Einstellung der E-Mail-Codierung: %(encoding)s" 137 137 138 138 #: announcer/distributors/mail.py:444 139 139 msgid "EmailDistributor crypto operaton successful." -
announcer/locale/ru/LC_MESSAGES/announcer.po
diff --git a/announcer/locale/ru/LC_MESSAGES/announcer.po b/announcer/locale/ru/LC_MESSAGES/announcer.po index 75725ec..2869d78 100644
a b msgstr "Подписки по компонентам" 75 75 76 76 #: announcer/subscribers.py:526 77 77 #, python-format 78 msgid "notify me when I'm listed in any of the (% s) fields"78 msgid "notify me when I'm listed in any of the (%(fields)s) fields" 79 79 msgstr "" 80 80 81 81 #: announcer/subscribers.py:583 … … msgstr "Общие извещения Wiki" 118 118 119 119 #: announcer/distributors/mail.py:411 120 120 #, python-format 121 msgid "Invalid email encoding setting: % s"122 msgstr "Неправильный выбор почтовой кодировки: % s"121 msgid "Invalid email encoding setting: %(encoding)s" 122 msgstr "Неправильный выбор почтовой кодировки: %(encoding)s" 123 123 124 124 #: announcer/distributors/mail.py:444 125 125 msgid "EmailDistributor crypto operaton successful." -
announcer/locale/zh_CN/LC_MESSAGES/announcer.po
diff --git a/announcer/locale/zh_CN/LC_MESSAGES/announcer.po b/announcer/locale/zh_CN/LC_MESSAGES/announcer.po index fe120dd..735e2bd 100644
a b msgstr "" 75 75 76 76 #: announcer/subscribers.py:526 77 77 #, python-format 78 msgid "notify me when I'm listed in any of the (% s) fields"78 msgid "notify me when I'm listed in any of the (%(fields)s) fields" 79 79 msgstr "" 80 80 81 81 #: announcer/subscribers.py:583 … … msgstr "高级Wiki订阅" 118 118 119 119 #: announcer/distributors/mail.py:411 120 120 #, python-format 121 msgid "Invalid email encoding setting: % s"122 msgstr "无效的邮件编码设置: % s"121 msgid "Invalid email encoding setting: %(encoding)s" 122 msgstr "无效的邮件编码设置: %(encoding)s" 123 123 124 124 #: announcer/distributors/mail.py:444 125 125 msgid "EmailDistributor crypto operaton successful." -
announcer/subscribers.py
diff --git a/announcer/subscribers.py b/announcer/subscribers.py index 67f4918..7050913 100644
a b class TicketCustomFieldSubscriber(Component): 522 522 523 523 def description(self): 524 524 if self.custom_cc_fields: 525 return _("notify me when I'm listed in any of the (%s) " 526 "fields"%(','.join(self.custom_cc_fields),)) 525 return _("notify me when I'm listed in any of the (%(fields)s) " 526 "fields", 527 fields=','.join(self.custom_cc_fields)) 527 528 528 529 def default_subscriptions(self): 529 530 if self.custom_cc_fields:
comment:3 Changed 13 years ago by
Cc: | Jordi Mallach added |
---|
comment:4 follow-up: 6 Changed 13 years ago by
(In [10920]) AnnouncerPlugin: Refactor i18n in a more compatible way, refs #7314, #7666, #7380, #8062 and #9192.
Lessons learned meanwhile with other plugins, so the code applied here has actually been tested and proven to work. This reverts [8409] effectively, but let's keep proper Babel and Trac versions for i18n explicitly as an extra.
After these changes the plugin finally loads cleanly in Trac 0.11 again.
comment:5 Changed 13 years ago by
I've switched from running the 0.11 branch to the Announcer trunk @ r10920. I'll report if I find any issues on 0.11.7 (though I'll be upgrading to 0.12.2 soon).
comment:6 Changed 13 years ago by
Replying to hasienda:
After these changes the plugin finally loads cleanly in Trac 0.11 again.
I think I didn't read your message carefully enough. I was seeing some error about environment object not having attribute with_transaction so I had to roll-back. Since I'm moving to 0.12.2 soon, I might just wait to upgrade.
comment:7 follow-up: 8 Changed 13 years ago by
Sorry, I'm still in the process of sorting out code for 0.11 and 0.13 . I.e. to get the most out of the new decorator-based connections, we should really use read-only with_query(db)
as much as possible.
comment:8 Changed 12 years ago by
Cc: | Robert Corsaro added; Steffen Hoffmann removed |
---|---|
Keywords: | i18n added |
Owner: | changed from Robert Corsaro to Steffen Hoffmann |
Replying to hasienda:
Sorry, I'm still in the process of sorting out code for 0.11 and 0.13 . I.e. to get the most out of the new decorator-based connections, we should really use read-only
with_query(db)
as much as possible.
I'll really have to deal with this first, because it even blocks use with Trac-1.0 right now. I18n will be next, thanks for your patience.
comment:9 Changed 8 years ago by
Owner: | Steffen Hoffmann deleted |
---|
comment:10 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:11 Changed 8 years ago by
Owner: | set to Steffen Hoffmann |
---|
And all text templates use
NewTextTemplate
syntax in the plugin. It should setgenshi.template:NewTextTemplate
inmessage_extractors
parameter of setup.py.See trac:changeset:8999, http://genshi.edgewall.org/browser/branches/stable/0.6.x/genshi/template/text.py#L16.
setup.py
TextTemplate'