Internationalization of strings in a database
|Reported by:||Owned by:||nobody|
|Severity:||Keywords:||Internationalization, Translation, Database, Models, Flatpages|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
While building up my website I worried aubout providing it in more than one language someday. At this point I tried to figure out how Djangos I18N-Tool works from the Documentation and if it would cover all my needs. But surprisingly it wouldn't. My problem was to translate strings in database, which can only be reached via an implemented search engine. But doing this was not explained. On request in the German Python forum I was told that this would be impossible (or very hard work) with Django itself. But I think this should get a feature of Django - not because it is possible in any other framework (I haven't yet tried any others) - but because it would improve Django considerably. It would be a new challenge on your way to version 1.0, but it would be worth to face. Therefore I hope, this ticket will get into further discussion and perhaps be kept in mind while developing and improving Django to reach its peak.
One way to get around this problem would be, to give the programmer (the perfectionist) a possibility to mark translatable database columns in the models. The function - or whatever collects the translatable strings - would then only have to add all strings in this database column to the language file. I'm not an expert in Django, but I think this should work, because the real translation or substitution is done after running all the other Python code and therefore wouldn't differ from a translation of a hardcoded (I know you hate this word) string.
It would also be useful, but not this essential, to bring up an easy way for translating flatpages. One way to reach this would be to add another data field to the flatpages, which stores the language code. If requested, Django could then first look up, if the flatpage exists in the preferenced language. If this failed, it could look for any other languages to be supported and then perhaps return another variable (e.g. flatpage.tranlation) which tells, that the translation failed (in the requested language).
If you could manage to implement this features it would be another good reason to use Django (there can't be enough) and would match perfect with Djangos philosophies.
Yours sincerely, Klaus Weidinger