How to translate the fields of a database model?

Posted by Tõnis M on Stack Overflow See other posts from Stack Overflow or by Tõnis M
Published on 2010-05-02T15:04:56Z Indexed on 2010/05/02 15:07 UTC
Read the original article Hit count: 196

Filed under:
|

I have some tables/models in a web app that will have multilingual content. For example a university, with it's description in a default language(english) and the user wants he can see the same information in another language( if the object has it's fields translated). If there were only a few languages then I would just add fields like name_en and name_de and so on, but the number of languages isn't fixed, so that' would create a mess. I could also just create a new object with the translated data but then foreign keys wouldn't work, and only some of the fields can be translated so that would create duplicate data. Storing the translations in a file and using gettext or something similar is also not an option since the objects fields can be translated by the website user, not only developers/admins.

What would be the best way to design/architect such a database? Searching from the translated data should also be not too complex - as it should not require creating complex joins which would make the queries slower

I'm using PostgreSQL and Ruby of Rails but I'm not looking for a technical solution but for a general idea how to design it.

© Stack Overflow or respective owner

Related posts about translation

Related posts about design