anatak Posted September 7, 2009 Share Posted September 7, 2009 I want to make a site available in multiple languages. I want to store all the text of the site in a mysql database. example of text would be "welcome to our site" I thought about 2 systems. 1 table with a column for the ID of the message and a column for every language. the advantage is that it is rather fast and easy to select messages in more than one language as every message has a single ID (primary key) The big disadavantage is that if I need to add a language to the site I have to add a column in this table. the other system I was thinking was to create a table with a column for the messageID a column for the languageID and a column for the message. The primary key is a combination of messageID and languageID. the advantage is that adding a language is easy but selecting the messages will (I think) take more time because not all the messages are always translated in all the languages. to select a message I will always have to select the default language and the user desired language. if the message is not available in the user desired language it has to be displayed in the default language. my question is what would you do ? Quote Link to comment https://forums.phpfreaks.com/topic/173379-solved-design-question-for-translation-table/ Share on other sites More sharing options...
fenway Posted September 8, 2009 Share Posted September 8, 2009 More likely it's better to either (a) have a single row per language or (b) have a single table per language. Quote Link to comment https://forums.phpfreaks.com/topic/173379-solved-design-question-for-translation-table/#findComment-915029 Share on other sites More sharing options...
cbolson Posted September 8, 2009 Share Posted September 8, 2009 Hi, I normally use a single table with column for each table. The fields are defined with _en, _es etc. Adding a new language is just a matter of adding a new column with the same format. I actually have a script that does this automatically - ie when I want to add a new language it loops through the tables, finds the fields that end with "_en" (I only use this system for language fields) and adds a new one with the new ending. So for example to add german to the web, if it finds a field such as "title_en" it will add "title_de". Chris Quote Link to comment https://forums.phpfreaks.com/topic/173379-solved-design-question-for-translation-table/#findComment-915065 Share on other sites More sharing options...
anatak Posted September 8, 2009 Author Share Posted September 8, 2009 Hey Chris, The way you described it is the way I did it in another site and I think it was the best way to do it. I was just looking if somebody else knew of a different way. I ll guess I ll do it the same way again. That makes it also easier in the copy paste department to fenway this was a design question maybe I posted it in the wrong forum ? Quote Link to comment https://forums.phpfreaks.com/topic/173379-solved-design-question-for-translation-table/#findComment-915095 Share on other sites More sharing options...
fenway Posted September 10, 2009 Share Posted September 10, 2009 Not really the wrong place... though at some level it might be considered app design, depending on whom you ask. Quote Link to comment https://forums.phpfreaks.com/topic/173379-solved-design-question-for-translation-table/#findComment-916296 Share on other sites More sharing options...
anatak Posted September 10, 2009 Author Share Posted September 10, 2009 I thought I had a better chance to get an answer here than in app design. closing topic since I have an answer thanks to both of you for helping. anatak Quote Link to comment https://forums.phpfreaks.com/topic/173379-solved-design-question-for-translation-table/#findComment-916379 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.