Re: [PHP] Multilingual Web application - how to?

[email protected] (Jochem Maas)
Newsgroups php.general,php.i18n
Message-ID <[email protected]>
Denis Gerasimov wrote:
> Hello list,
> 
> I need to develop a multilingual web site and I am looking for the best way
> of handling this task. There are three main issues I know:
> 
> 1. Storing multilingual data in a database. Possible solutions I know:
> a. many tables, one per each supported language, e.g. news_en, news_de.
> b. one table having many columns with translations, e.g. (id, date, text_en,
> text_de)
> We use MySQL 4.1 as a back-end.

what about 1 table, 3 columns:

translatekey (varchar) 		- string to translate
lang		       		- lang code/id/name
translation  (varchar/text) 	- translated string

> 
> 2. Multilingual HTML templates, possible solutions:
> a. one generic template for everything, one per each language, like
> contents_en.tpl.html, contents_de.tpl.html
> b. many localized templates for each page, e.g news_en.tpl.html,
> news_de.tpl.html
> Template engine is Smarty.

using Smarty I sometimes assign an assoc array of translated strings:

$Lang['yes'] = 'yessiree';
$Lang['no']  = 'nocando';

then in Smarty:

<div class="LangExample">
'yes' is {$Lang.yes},
'no'  is {$Lang.no}
</div>

> 
> 3. Storing current language variable, possible solutions:
> a. inside the URL like /en/news/

best in terms of SEO.

> b. using cookies

handy for presistence.

> c. using sessions

provides cleaner URLS.

I see no reason to do all 3.

> Web server is Apache2+mod_rewrite with PHP5
> 
> What are pros and cons for each solution? What are other possible solutions
> for the above issues?
> 
> Best regards, Denis Gerasimov
> Outsourcing Services Manager,
> VEKOS, Ltd.
> www.vekos.ru
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.