We are working on a .po file editor for translators. And the translators need to see the changes they are doing on the live website.
We managed to reload the .mo files for the current process/thread. but not for every process/thread.
Is there a possibility to accomplish this without bigger performance problems?
Use the --noreload option to disable the use of the auto-reloader. This means any Python code changes you make while the server is running will not take effect if the particular Python modules have already been loaded into memory. The development server is multithreaded by default.
gettext_lazy() In definitions like forms or models you should use gettext_lazy because the code of this definitions is only executed once (mostly on django's startup); gettext_lazy translates the strings in a lazy fashion, which means, eg.
Overview. In order to make a Django project translatable, you have to add a minimal number of hooks to your Python code and templates. These hooks are called translation strings. They tell Django: “This text should be translated into the end user's language, if a translation for this text is available in that language. ...
We had the same problem. Users must write translations direct on website. I've found middleware for django 1.1, that clear translation cache and try to use it in view with django 1.4. order:
function below to clear cache
from django.utils import translation
from django.utils.translation import trans_real, get_language
from django.conf import settings
import gettext
if settings.USE_I18N:
try:
# Reset gettext.GNUTranslation cache.
gettext._translations = {}
# Reset Django by-language translation cache.
trans_real._translations = {}
# Delete Django current language translation cache.
trans_real._default = None
# Delete translation cache for the current thread,
# and re-activate the currently selected language (if any)
translation.activate(get_language())
except AttributeError:
pass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With