I'm trying to figure out the best way to translate actual database values (textual strings, not date formats or anything complicated) when internationalizing my Django application. The most logical ways I could come up with were to either:
description_en
, description_de
, description_fr
, ...) orschema_en
, schema_fr
, schema_de
, ...).Are these the best options, or is there something else I'm missing? Thanks.
Use the lazy versions of translation functions in django. utils. translation (easily recognizable by the lazy suffix in their names) to translate strings lazily – when the value is accessed rather than when they're called. These functions store a lazy reference to the string – not the actual translation.
The goal of internationalization and localization is to allow a single web application to offer its content in languages and formats tailored to the audience. Django has full support for translation of text, formatting of dates, times and numbers, and time zones.
Multilingual Support − Django supports multilingual websites through its built-in internationalization system. So you can develop your website, which would support multiple languages. Framework Support − Django has built-in support for Ajax, RSS, Caching and various other frameworks.
I was reading up on my django extensions, and found the django-modeltranslation plugin. It seems to do exactly what you want it to do.
I also found this small project which purpose is to synchronize localized strings into standard message files for fields of registered models.
Example:
import vinaigrette vinaigrette.register(YourModel, ['name', 'description'])
The standard command
$ manage.py makemessages
Would maintain messages for each distinct values found in registered fields.
I have not had the occasion to try it yet.
But this seems for me to be the simplest way to translate data from db.
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