Closed
Bug 808580
Opened 12 years ago
Closed 12 years ago
Trans blocks loose translations after second reload
Categories
(www.mozilla.org :: Bedrock, defect)
www.mozilla.org
Bedrock
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: rik, Unassigned)
References
(Blocks 1 open bug)
Details
Steps to reproduce:
1. Launch your server
2. Go to http://localhost:8000/de/foundation/annualreport/2011/
3. Refresh
Expected result:
First paragragh says "Mozillas Vision des Internets ist ein Ort" etc.
Actual result:
First paragragh says "Mozilla‘s vision of the Internet" etc.
Reporter | ||
Updated•12 years ago
|
Summary: Trans blocks loose translations after .lang file is updated → Trans blocks loose translations after second reload
Reporter | ||
Comment 1•12 years ago
|
||
I can confirm that this behaviour only happens with {% trans %} blocks and not with _()
Reporter | ||
Comment 2•12 years ago
|
||
Setting cache_size to 0 in the jinja config does not change this.
On the second load, dotlang.translate() is not called. We don't know why yet.
Reporter | ||
Comment 3•12 years ago
|
||
In my testing, jinja2.ext.InternationalizationExtension.parse returns the same thing after first and second run:
MarkSafeIfAutoescape(expr=Call(node=Name(name='gettext', ctx='load'), args=[Const(value=u'In less than 20 years the Internet has changed our lives. It is a powerful platform with unprecedented opportunity and connectedness. But even with great growth and innovation there are significant challenges to this vision of a healthy Internet.')], kwargs=[], dyn_args=None, dyn_kwargs=None))
Reporter | ||
Comment 4•12 years ago
|
||
So by commenting l10n_utils.helpers.gettext, I don't see the translation on the firstrun. I think we should now look into install_gettext_translations or install_gettext_callables (http://jinja.pocoo.org/docs/extensions/#environment-methods) to register properly and get called everytime.
Comment 5•12 years ago
|
||
registering functions via `install_gettext_callables` does nothing to solve the issue, but does result in all translated text reverting to english on reload, including calls to `_()`. Somehow registering these functions with the environment and i18n extension causes them to be called only on the first run. I've tested with the test client in the shell and seen the same result. Even calling `jinja2.utils.clear_caches` between calls, which should clear all in memory caches, didn't help.
My theory at this point is that something in Jinja2 or Django is causing our registered gettext functions to be overridden by the builtin gettext functions, making ours only be called the first time, and subsequent calls appear to be noop.
Comment 6•12 years ago
|
||
FOUND IT!!
https://github.com/clouserw/tower/blob/master/tower/__init__.py#L86
Tower resets the gettext functions to its own every time `activate` is called :(
It's late now. But at least we know what it is and should have a fix tomorrow.
Comment 7•12 years ago
|
||
Comment 8•12 years ago
|
||
Commit pushed to master at https://github.com/mozilla/bedrock
https://github.com/mozilla/bedrock/commit/b26f3312f6d1014ed71663f9edb2a63cbda6af37
Correctly install gettext into Jinja2. Fix bug 808580.
Updated•12 years ago
|
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 9•12 years ago
|
||
This has been pushed to production.
You need to log in
before you can comment on or make changes to this bug.
Description
•