Edgewall Software
Modify

Opened 12 years ago

Closed 11 years ago

#10900 closed enhancement (fixed)

i18n for the "reasons" for rejecting spam

Reported by: Christian Boos Owned by: Dirk Stöcker
Priority: normal Milestone: plugin - spam-filter
Component: plugin/spamfilter Version: 1.0
Severity: normal Keywords: i18n review
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

One last i18n update for today, on the SpamFilter.

But as it's non-trivial, I'd like to get some review on it before committing. Maybe I overlooked something…

The idea is to keep the model as is, and continue storing the reasons for changes like usual ("<filter-name> (score): reason for rejection (optional detail)"). The trick is to "parse" it back, in its four constituents.

Then I first tried to render it back in the template, but that was too much logic for too few markup, the code had to be duplicated in admin_spammonitor.html and admin_spamentry.html or a py:def macro should have been used, but an included template containing just that function would have been overkill as well.

So I think having a _render_reasons function in the code is not too bad. Next, I'll probably try to see how moving that to Javascript would look like (in the spirit of doing less server side and more client side).

Attachments (2)

t10900-i18n-reasons.patch (19.6 KB ) - added by Christian Boos 12 years ago.
the reasons retrieved from the log entries are now translated
t10900-i18n-reasons.2.patch (27.3 KB ) - added by Christian Boos 12 years ago.
encode/decode reasons in LogEntry; the rest of the code should manipulate reasons as structured objects, not as text

Download all attachments as: .zip

Change History (9)

by Christian Boos, 12 years ago

Attachment: t10900-i18n-reasons.patch added

the reasons retrieved from the log entries are now translated

comment:1 by Peter Suter, 12 years ago

Don't you also need _encode_reasons()? (From a list of tuples back to a list of strings so '\n'.join(reasons) in LogEntry.update() and LogEntry.insert() works again.)

Last edited 12 years ago by Peter Suter (previous) (diff)

comment:2 by Christian Boos, 12 years ago

Yes, good suggestion. Moreover, by looking closer at this side of the code (how reasons are retrieved from each filter strategy and passed to LogEntry), I see that the "detail" part might be a tuple…

#: tracspamfilter/filters/defensio.py:90
msgid "Defensio says content is not allowed (%s, %s, %s)"

#: tracspamfilter/filters/trapfield.py:58
msgid "Both trap fields says this is spam (%s, %s)"

… which complicates a bit the problem (I knew I overlooked something ;-) ).

by Christian Boos, 12 years ago

Attachment: t10900-i18n-reasons.2.patch added

encode/decode reasons in LogEntry; the rest of the code should manipulate reasons as structured objects, not as text

comment:3 by Dirk Stöcker, 12 years ago

Do I understand you right, that you want to store the text form and convert it back into structure? That wont work for a lot of languages.

The correct way is to store the individual entries in the LogEntry. I thought about using \x01 and \x02 as field separator and simply join them. Then they can easily be split again and there is no need to change the database structure.

comment:4 by Christian Boos, 12 years ago

Well, we only ever store the original (i.e. english) messages, don't we?

In the patch there's no change in what is currently stored; the only change is to parse it back in such a way that it can be translated again.

And if we do want to change the way the reasons are stored, then better use some neutral text representation (XML or JSON), rather than binary separator, as that would require at least in addition a base64 encoding (the way we do it for content).

comment:5 by Dirk Stöcker, 12 years ago

XML sounds good to me. Is also easy detectable to handle old entries.

comment:6 by Dirk Stöcker, 11 years ago

In r11750.

I don't know any remaining part which is not i18n clean. Only french translation needs updating a lot :-) German is complete…

comment:7 by Dirk Stöcker, 11 years ago

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dirk Stöcker.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Dirk Stöcker 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.