#12511 closed defect (fixed)
Untranslated buttons in spam filter admin panel
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | plugin - spam-filter |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Fixed regression in [14814,14815] that led to untranslated buttons in the admin panels. |
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
After [14814,14815], labels in the buttons of spam filter admin are untranslated.
The gettext
in tracspamfilter.api
is not the same as gettext
in trac.util.translation
. Instead, we should use dgettext
and dngettext
with tracspamfilter
catalog like this:
- <input type="submit" name="cleantemp" value="${ngettext('Remove %(num)s temporary session', + <input type="submit" name="cleantemp" value="${dngettext('tracspamfilter', 'Remove %(num)s temporary session',
Those translation methods can easily be replaced by sed
.
for i in tracspamfilter/templates/*.html; do sed -i \ -e "s/\<_(/dgettext('tracspamfilter', /g" \ -e "s/\<gettext(/dgettext('tracspamfilter', /g" \ -e "s/\<ngettext(/dngettext('tracspamfilter', /g" \ $i done
Attachments (1)
Change History (11)
by , 9 years ago
Attachment: | untranslated-buttons.png added |
---|
comment:1 by , 9 years ago
Description: | modified (diff) |
---|
comment:2 by , 9 years ago
comment:3 by , 9 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Fixed in [14842].
comment:4 by , 9 years ago
Owner: | changed from | to
---|
comment:5 by , 9 years ago
Release Notes: | modified (diff) |
---|
follow-up: 8 comment:6 by , 8 years ago
Ok, so this fixes a regression in r14814, but wasn't that change a mistake in the first place?
With r11363 + r11377, you can see that the intent of replacing the _
function used in templates with the tracspamfilter.api._
one (which wraps the 'tracspamfilter'
domain gettext function), was to keep the simplicity of _("...")
instead of having to write the lengthier dgettext('tracspamfilter', "...")
as you did in r14842.
See CookBook/PluginL10N#MakethePythoncodetranslation-aware for details on domain_functions
. I should probably also document the data['_'] = _
trick in the next section, CookBook/PluginL10N#MaketheGenshitemplatestranslation-aware (unless, of course, you see a reason to not do things this way).
follow-up: 10 comment:7 by , 8 years ago
Yes, it was a mistake. However, I'm not sure it's worth changing until porting the templates to Jinja2.
follow-up: 9 comment:8 by , 8 years ago
Replying to Christian Boos:
See CookBook/PluginL10N#MakethePythoncodetranslation-aware for details on
domain_functions
. I should probably also document thedata['_'] = _
trick in the next section, CookBook/PluginL10N#MaketheGenshitemplatestranslation-aware (unless, of course, you see a reason to not do things this way).
I don't think we should use data['_'] = ...
trick in Genshi template. The _
variable is used in layout.html
and theme.html
, … in Trac core and expects messages
domain. For example, Search
msgid exists in another text domain (which is provided from a plugin), it can be translated to unexpected text.
comment:9 by , 8 years ago
Replying to Jun Omae:
I don't think we should use
data['_'] = ...
trick in Genshi template. The_
variable is used inlayout.html
andtheme.html
, … in Trac core and expectsmessages
domain. For example,Search
msgid exists in another text domain (which is provided from a plugin), it can be translated to unexpected text.
Ok, I don't think this is very likely, but point taken. Well, we could pick another shorthand then (e.g. __
, also adding it as a keyword in the appropriate setup.cfg section).
I think that dgettext('<domain>', "...")
should really be reserved for the rare case in which <domain>
is not the expected domain, as repeating 'tracspamfilter'
everywhere as we do in r14842 seems heavy handed.
comment:10 by , 8 years ago
sReplying to Ryan J Ollos:
Yes, it was a mistake. However, I'm not sure it's worth changing until porting the templates to Jinja2.
By the way, I have yet to find a way to support translation domains in Jinja2 trans
directives…
Thanks for spotting. I'll apply your fix today.