On Fri, 27 Nov 2009 15:34:56 +0000 Miguel Vaz said:

> Hi,
> 
> This is my first post, and could use some points of view on the subject.
> Have a project that will have several languages for its records, for places,
> for example, whose names and descriptions will be in 3 languages.
> 
> Have already read several sites about it but always end up with several
> perspectives:
> 
> 1 - Tables for each language: places_pt, places_en, places_es, with fields:
> id, name, description; Seems superfluous, but will leave less records on
> each table, although adding a great amount of tables, the more languages i
> have;
> 
> 2 - Rows for each language: id, lang, name, description - the field "lang"
> will have "pt", "en" or "es", and when displaying, i will have to lookup the
> active language and get the proper record; Will add tremendously to the
> record #;
> 
> 3 - Fields for each language: table "places", with fields: id, name_pt,
> name_en, name_es, description_pt,description_en,description_es - not likely
> to add a new language, but still adding new field adds complexity.
> 
> Is there a "proper" way to do things? Any usual way of handling several
> languages on a project? Any help is highly appreciated, thanks.
> 
> MV

Back when I internationalized my site, I used a table thus:

| locale | varchar(5)   | NO   | PRI | en      |       |
| strid  | varchar(127) | NO   | PRI |         |       | 
| strval | tinyblob     | YES  |     | NULL    |       | 
+--------+--------------+------+-----+---------+-------+
 and populated it w/ the english phrases first:
('en', 'Country',  'Country')
('en', 'Total', 'Total') 
('en', 'Day', 'Day')  
... etc.
 
Then I added different languages:
('de', 'Country', 'Land')
('de', 'Total', 'Summen')
('de', 'Day', 'Tag') ... 

When the user logs in, it scans all the 'en' (english) tokens and stores
it in a PHP array('Day' => 'Day', 'Total' => 'Total' ...

Once you figure out the user's locale (either from a user table or
parsing the http headers) you re-scan using the proper locale,
modifying the array as necessary: 'Day' => 'Tag', 'Total' =>
'Summen' ...

That way if you don't know or haven't yet found the proper translation
for a phrase it will default to the english language.

* Note the locale field is varchar(5). 
There is a de, a de_DE, and a de_CH locale!

Have fun!

-- 
Don Read                                        don_r...@att.net
     It's always darkest before the dawn. So if you are going to
     steal the neighbor's newspaper, that's the time to do it.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to