Sunday, December 27, 2009

Anybody familiar with coding French/English websites?

A client wants me to add a ';French-only'; section of an English website. Would it be easier to:

-copy all the English pages and change the text? It'd make future design changes more difficult because I'd have to make each change twice.

-or install a cookie/session that could pull the appropriate text from the database based on the English/French decision? Then there'd only be 1 set of pages and future design changes would only need to happen once.

-or something else?Anybody familiar with coding French/English websites?
I'd use something similar to the above answer. But I'd use a more sensible table structure...

Use a table with ID, languageCode, text. You can then have a separate table containing the possible languageCodes ( to use as a foreign key ).

This would allow you to add languages as you want ( just a new record in your languageCode table ) and wouldn't need database changes. The data in your text table would need one row per item per language.

Then when you want the translations for a particular language, then something select text from languageText where languageCode = 'xxxxx'.Anybody familiar with coding French/English websites?
I have done several multi-lingual sites. In each case:

- A database table: id, en, fr, pt

- an entry: ';BUY';, ';Buy Now!';, ';Achetez Maintenant';, ';Compra J脿!';

- The global value ';$Lang'; (ie ';en';, ';fr';, ';pt';) by default ';en'; (english), and selected at a click of a flag, resets the global, saves in a cookie.

- A call in Php:

echo ( ';%26lt;img src=\';xxx\'; alt = \'; . p_text(';BUY';) . \'; %26gt;'; );

- The function p_text($id) {

$sql = ';select `';.$Lang.';` from `dbtexts` where `id`='';.$id.';' limit 1';;

$list = mysql_query($sql);

$lst = mysql_fetch_array($list);

$txt = $lst[0];

return(htmlentities($txt)); =%26gt; to display 脿, 锚, 莽, 卯 etc...


The function selects the column in the table according to $lang and return the text.


- Texts in French are about 12% longuer than in english! Make sure you have a liquid layout...

- English has no accentuation, French has: 脿, 茅, 锚 etc... won't show properly if you do not use htmlentities() in Php.

And example of multi-lingual:

It has two languages, but the table is in 6 languages (en, fr, pt, es, it, de). I just have to add the flags to get the other languages, or add a new column in the table to add another languages..
  • home facial
  • oil repair
  • natural shampoo
  • oil repair
  • No comments:

    Post a Comment