Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#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 Jun Omae)

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)

untranslated-buttons.png (42.2 KB ) - added by Jun Omae 8 years ago.

Download all attachments as: .zip

Change History (11)

by Jun Omae, 8 years ago

Attachment: untranslated-buttons.png added

comment:1 by Jun Omae, 8 years ago

Description: modified (diff)

comment:2 by Ryan J Ollos, 8 years ago

Thanks for spotting. I'll apply your fix today.

comment:3 by Ryan J Ollos, 8 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [14842].

comment:4 by Ryan J Ollos, 8 years ago

Owner: changed from Ryan J Ollos to Jun Omae

comment:5 by Ryan J Ollos, 8 years ago

Release Notes: modified (diff)

comment:6 by Christian Boos, 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).

comment:7 by Ryan J Ollos, 8 years ago

Yes, it was a mistake. However, I'm not sure it's worth changing until porting the templates to Jinja2.

in reply to:  6 ; comment:8 by Jun Omae, 8 years ago

Replying to Christian Boos:

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).

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.

in reply to:  8 comment:9 by Christian Boos, 8 years ago

Replying to Jun Omae:

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.

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.

in reply to:  7 comment:10 by Christian Boos, 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…

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.