When getting a translation suggestion for a string that contains string
replacements (like %(foo)s), Yandex wraps string replacements in
annoying <code> tags, this commit strips those tags automatically.
Now we don't mess up with settings or rosetta_settings directly,
we just use the django tools to change settings in a given context (like the
``override_settings`` decorator).
When testing and using override_settings(), SETTINGS_MODULE is reset, so in case it is set to None, we try to guess it via the DJANGO_SETTINGS_MODULE env var.
* Added a RosettaSettings class that keep rosetta settings
* Settings are reloaded via the ``setting_changed`` django signal is sent
* this should be completely backwards compatible, unless for hacks like reading the settings file from disk (nobody does this right ?)
* Added a settings variable ``ROSETTA_LOGIN_URL`` that allows to
override the login URL for rosetta.
* No test is included because it is not possible to override this
particular setting variable due to how tests are organized (top level
import of rosetta_settings).
This commit will break the alert image for Django 1.8, but with the current code,
all versions after Django 1.8 are broken (.gif admin images were converted to .svg
during the 1.9 release).
In Python 2 if you query for text with unicode symbols,
an UnicodeEncodeError is raised.
It's because urlencode is called on unicode string.
urlencode should be called on encode strings in Python 2.
The fix is to use Django's force_bytes unility function
to pass encoded string (bytestring in Python 3) to urlencode.
Previously, state was extensively persisted in the cache. This
large-scale rewrite uses the cache only to persist changes to the
catalog file when it is read-only. State is now conveyed through the url
structure and through query string arguments.
The primary downside to this new approach is that there's no explicit
way of purging a cached catalog from memory, or refreshing it from
what's on disk. The user is forced (untransparently!) to wait until
the cached file falls out of the cache (untransparently!), which
is currently 24 hours after the last save (or after if the session
ends). Addressing this would require some design considerations,
and probably some new text that would require its own translation.