32

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:

  • hold a database column for every language (e.g. description_en, description_de, description_fr, ...) or
  • have a different database for every language (e.g. schema_en, schema_fr, schema_de, ...).

Are these the best options, or is there something else I'm missing? Thanks.

miikkas
  • 818
  • 1
  • 8
  • 25
sa125
  • 28,121
  • 38
  • 111
  • 153
  • also, this is a really small and simple app with perhaps 5 or less tiny tables. – sa125 Jan 07 '10 at 09:44
  • Is every installation supposed to have 1 single language, as opposed to have a language setting per user? – extraneon Jan 07 '10 at 09:59
  • the app supports language selection per user, so it must support all implemented translations in a single instance – sa125 Jan 07 '10 at 11:39
  • Duplicate of http://stackoverflow.com/questions/1984327/django-running-site-on-many-languages – Van Gale Jan 07 '10 at 15:10

2 Answers2

25

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.

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
extraneon
  • 23,575
  • 2
  • 47
  • 51
  • looks good at first glance, I'll have to play with it a bit - thanks! – sa125 Jan 09 '10 at 13:24
  • 6
    I'm coming late on this one to suggest a new solution for db translations, yawd-translations - github.com/yawd/yawd-translations. It allows to manage languages through the admin interface (at runtime) and implements an admin inline to easily manage translations. Since I'm developing for yawd I use a comment instead of a new answer not to be accused for self-promotion :) – ppetrid Nov 23 '12 at 16:29
5

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.

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • 1
    This means each time you add a new record in the database, you may have to re-run makemessages and check in po files if there's a new entry... just a warning. But anyway, this is what I was looking for, it's lighter than django-modeltranslation which adds a column in the tables that need translation for *each* language... – Olivier Pons Nov 13 '15 at 11:16