php-i18n Digest 11 Apr 2005 01:04:49 -0000 Issue 282
Topics (messages 855 through 859):
Re: [PHP] Multilingual Web application - how to?
855 by: Jochem Maas
Re: Multilingual Web application - how to?
856 by: Allan Kolk
857 by: Eli
858 by: Marc Laporte
859 by: Ligaya Turmelle
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
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
I have used c) for a long time but as of recently I've become a
supporter of b). Reasoning: firstly, select-s are fastest this way due
to lower number of joins needed and secondly, MySQL as of 4.1 now
supports different collations for different columns. I use Unicode for
all the data but sorting order and such still depends on collation used.
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>
I completely agree with Jochem there. Unless your base layout is
different for each language involved, you should use common templates
for all languages and have localized texts displayed via {$lang.yes} and
similar. Clean and swift. And you can have your localized texts stored
in whatever format you wish - database, XML or PHP variable files.
3. Storing current language variable, possible solutions:
a. inside the URL like /en/news/
best in terms of SEO.
And therefore it is best used on informative sites that are mainly
visited via public side. Keeping the current language inside the URL
means that the customers can easily copy-paste links while keeping the
language selected. If the site is intended for internal use (intranet,
CRM, ERP etc) you might opt for storing the language in a session instead.
b. using cookies
handy for presistence.
I would personally use it as an addition to a) and c). Upon the first
visit to a site (session getting set up) the language is retrieved from
the cookie. Later on either session or URL are used.
c. using sessions
provides cleaner URLS.
And I would use this solution on sites intended for internal use, as
stated above.
HTH,
Allan Kolk
--- End Message ---
--- Begin Message ---
Denis Gerasimov wrote:
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:
Mabye consider of using gettext..
http://www.php.net/gettext
BTW: why doesn't Smarty support gettext?
How can gettext be implemented into Smarty (with simplier syntax)?
-thanks, Eli
--- End Message ---
--- Begin Message ---
Hi Denis,
You can look into using or analyzing a multilingual CMS. Last time I
looked, the following PHP open source CMSs offered this feature: TYPO3,
Glasnost, eZ publish and OVIDENTIA. (links are provided on
MultilingualDev). You may get some insight on how & why they chose
specific technical solutions to your 3 questions.
This page contains many links related to this matter. There is a great
video from eTranslate:
http://tikiwiki.org/MultilingualDev
Another issue is how to manage to keep all versions in sync and how to
handle untranslated pages. This page explains well the difference
between The "Two-Tree" concept and the "one-tree-fits-all-languages"
concept:
http://typo3.org/1220.0.html
Tiki CMS/Groupware handles multilingual content in upcoming version 1.9
It is still in developer release stage however, I have been using the
multilingual feature in production sites for several months. Tiki uses
Smarty as a template engine.
Best regards,
--
M ;-)
//////////////////////////////////////////////////////////////////
/ /
/ Marc Laporte <|> http://marclaporte.com /
/ Avantech.net <|> http://avantech.net /
/ Tiki CMS/Groupware <|> http://tikiwiki.org/UserPagemarclaporte /
/ /
//////////////////////////////////////////////////////////////////
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.
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.
3. Storing current language variable, possible solutions:
a. inside the URL like /en/news/
b. using cookies
c. using sessions
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
--- End Message ---
--- Begin Message ---
I am currently am using the IntSmarty extension to Smarty (you can get
it and more information at
http://www.coggeshall.org/oss/intsmarty/index.php/7/). With it the
translation(s) is stored as a flat file rather then a DB so it is easy
to pass along to the translators and load. I personally find it simple
to use and if the page is in the utf8 character set, capable of any
language (I have English and 2 Asian Languages). As for the current
language variable - it automagically loads the browsers current language
from the preferences. Let me know if you would be interested in it (I
have a _slightly_ hacked version to work with the utf8 character set
rather then the latin character sets).
other options I know of - gettext, PEAR has a couple of classes for
translations, and I also believe that there are a couple of classes at
phpclasses.org.
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.
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.
3. Storing current language variable, possible solutions:
a. inside the URL like /en/news/
b. using cookies
c. using sessions
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
--
Respectfully,
Ligaya Turmelle
"Life is a game.... so have fun"
--- End Message ---