#8063 closed enhancement (fixed)
[Patch] Better i18n codes
| Reported by: | Jun Omae | Owned by: | Steffen Hoffmann |
|---|---|---|---|
| Priority: | normal | Component: | AccountManagerPlugin |
| Severity: | normal | Keywords: | i18n |
| Cc: | Trac Release: | 0.12 |
Description
I created the patch for better i18n codes for account-manager plugin.
- Use
dgettext()instead offrom acct_mgr.api import _hack in admin_*.html. - Replace
verification codetoverification tokenin acct_mgr/templates/register.html. All the other phrases areverfication token. - Remove
hrefini18n:msgattribute in reset_password.html. The value is not used. - Add
i18n:msgattributes to<p py:when="reset.sent_to_email">in reset_password.html. It's too hard to translate in Japanese. - Add
%(link)snamed-parameter. The separated message makes the translations difficult.
Please apply the patch, if you can.
Attachments (1)
Change History (9)
Changed 15 years ago by
| Attachment: | better-i18n.diff added |
|---|
comment:1 follow-up: 2 Changed 15 years ago by
| Status: | new → assigned |
|---|
comment:2 follow-up: 4 Changed 15 years ago by
Replying to hasienda:
Could you explain your preference for the direct dgettext call? This seems unusual, as we otherwise we try to use the translation utils from Trac as much as we can. If I understand better, I'll do better in future projects and correct same issue in other plugins as well. Thanks in advance for any hint.
I think that the calling dgettext in genshi templates is usual. If it's unusual, Chrome.populate_data() should not set dgettext.
- Chrome.populate_data() sets dgettext by default.
cf. trac:r7705#file2, Chrome._default_context_data. - babel extracts
dgettextkeyword. The default keywords includesdgettext.
cf. http://babel.edgewall.org/intertrac/source:branches/stable/0.9.x/babel/messages/extract.py@447:46#L40.
This is a hack, since Genshi seems able to accomplish the message extraction, but later fails on the required runtime translation. This has been discovered first with ScreenshotsPlugin, and the workaround is, what we came up there.
ScreenshotsPlugin does not need the hack. Pass gettext (or _) method with named _ from process_request().
-
tracscreenshots/core.py
166 166 167 167 # Return template and its data. 168 168 db.commit() 169 return (template + '.html', {'screenshots' : req.data }, content_type)169 return (template + '.html', {'screenshots' : req.data, '_': _}, content_type) 170 170 171 171 # Internal functions. 172 172
comment:3 Changed 15 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
(In [9435]) AccountManagerPlugin: Improve some i18n related code, closes #8063.
Changes contribute to better code readability and easier understandable msgid's - good for translators, as Jun Omae suggested. Please see #8063 for details. I took the chance to finally remove a leftover from changeset [4638].
comment:4 follow-up: 5 Changed 15 years ago by
Replying to jun66j5:
Replying to hasienda:
Could you explain ![...]
I think that the calling dgettext in genshi templates is usual. If it's unusual, Chrome.populate_data() should not set dgettext. ![...]
Ok, thanks for the insight given.
This is a hack, since Genshi seems able to accomplish the message extraction, but later fails on the required runtime translation. This has been discovered first with ScreenshotsPlugin, and the workaround is, what we came up there.
ScreenshotsPlugin does not need the hack. Pass ![...]
I'll not forget, but have to look at it later. Thanks for the recommendation. This is an especially clever looking one.
BTW, I've just pushed your Japanese translations out to t-h.o with changeset [9436] and to the back-store of our Transifex translation project at Bitbucket.
Are you sure, the '\n' markers get respected? While you've used them quite a lot, from my own experience with (German) translations I've seen no effect: Line breaks just don't follow these newline positions, neither with English default/fallback nor with my own translations. So I've totally removed them, without noticeable negative effects. Does your experience differ? Is it even depending on some configuration I don't know by now?
comment:5 follow-up: 6 Changed 15 years ago by
Replying to hasienda:
BTW, I've just pushed your Japanese translations out to t-h.o with changeset [9436] and to the back-store of our Transifex translation project at Bitbucket.
Thanks! ;-)
Are you sure, the '\n' markers get respected? While you've used them quite a lot, from my own experience with (German) translations I've seen no effect: Line breaks just don't follow these newline positions, neither with English default/fallback nor with my own translations. So I've totally removed them, without noticeable negative effects. Does your experience differ? Is it even depending on some configuration I don't know by now?
My experience is the same. No such a configration.
When a message is a part of HTML, \n does not effect. Then the removing \n has no problem.
When a message is a part of console messages, \n is effective.
I translate with care for "Lines shouldn't exceed a length of 79 characters".
comment:6 Changed 15 years ago by
Replying to jun66j5:
Replying to hasienda:
![...] Are you sure, the '\n' markers get respected? ![...]
When a message is a part of HTML,
\ndoes not effect. Then the removing\nhas no problem. When a message is a part of console messages,\nis effective. I translate with care for "Lines shouldn't exceed a length of 79 characters".
Don't we have
width = 72
or similar in <pluginroot>/setup.cfg for that purpose? I noticed some of your translations where actually reformatted to have different line break positions when I ran python ./setup.py update_catalog on them, and I do this on a regular base before commits. So your effort may not be effective. Personally I don't care for line breaks in PO files anymore, but write longer lines be intention and let babel tools reformat afterwards.
Thanks for the confirmation in general.
comment:7 Changed 13 years ago by
Very minor issue, there is a chunk of whitespace in the textarea. The following is one way to fix it:
-
acct_mgr/templates/admin_accountsnotification.html
44 44 usernames that get notified of the above actions: 45 45 </p> 46 46 <textarea cols="60" rows="2" id="notify_addresses" 47 name="notify_addresses">${ ' '.join(notify_addresses)} 47 name="notify_addresses"> 48 ${' '.join(notify_addresses)} 48 49 </textarea> 49 50 </fieldset> 50 51 <div class="buttons">
comment:8 Changed 13 years ago by
(In [12735]) AccountManagerPlugin: Prevent excessive white space in a textarea, refs #8063.
Thanks to Ryan J Ollos for his hint and proposing a fix.



Replying to jun66j5:
This is a hack, since Genshi seems able to accomplish the message extraction, but later fails on the required runtime translation. This has been discovered first with ScreenshotsPlugin, and the workaround is, what we came up there.
Could you explain your preference for the direct dgettext call? This seems unusual, as we otherwise we try to use the translation utils from Trac as much as we can. If I understand better, I'll do better in future projects and correct same issue in other plugins as well. Thanks in advance for any hint.
I can. :-) And I will. :-)) Thanks for another profound enhancement request.