NYCPHP Meetup

NYPHP.org

[nycphp-talk] multilingual strategies

Anirudh Zala xml at aumcomputers.com
Thu Dec 4 06:25:04 EST 2003


Hi,

We have been providing multilingual support for websites since 4 years. To
store language variables we use File system instead of DB, as DB access for
each and every page is not recommended from performance point of view in
general sense. Just think how many DB interactions you will need for each
and every request if you store language variables in DB.

We don't do embedded programming, rather we keep pur PHP code and GUI part
separately, hence we store all language variables in 1 php file depnding
upon how much language support u require. While displaying those language
specific items, we store language variable in session variable or in cookie
at client side and use it across our all php files. Whenever new language is
selected (by flag or caption name) 1,2 or 3 or 4 will be stored in session
which will determine which language file is to be included. My structure is
like below.

....Config variables or Config files

....Language files say 1.inc or 2.inc (1 and 2 are stored in session)

....Other files or Main code

....Parse your language variables here

....Print out put to browser

For exmaple your 1.inc file (which is in english) contains variables like
below

$cap[hello]="Hello";
$msg[hello]="Welcome to Foo site";

And 2.inc (which is in spanish langauge) contains variables like below

$cap[hello]="Hola";
$msg[hello]="Welcome ... .. site";

And similarly 3.inc, 4.inc etc.. While GUI part your html files contains
variables like this

{WELCOME}
{WELCOME_MSG}

Finally 1 of your common parsing file, like ** rFastTemplate.php** in our
case using "assign" method, will parse php realted variables into html
template and will send output to browser. code can be like below:

[.....code.....includable files..code...]

$tp->assign(array(WELCOME=>$cap[hello],WELCOME_MSG=>$msg[hello]));

[...print output...]

By this way effieceint multilingual implementation can be achieved without
any extra efforts. Maximum benefit is that we don't require DB connections
here, as this system is absolutely dependent upon File system.

Thanks

Anirudh Zala
-------------------------------------------------------------------------
Anirudh Zala (Project Manager),           Tel: +91 281 2451894
AUM Computers, 317 Star Plaza,        anirudh at aumcomputers.com
Rajkot-360001, Gujarat, INDIA          http://www.aspl.info
-------------------------------------------------------------------------
----- Original Message -----
From: "Marc Antony Vose" <suzerain at suzerain.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Thursday, 04 December, 2003 7:18 AM
Subject: [nycphp-talk] multilingual strategies


> Hi there.
>
> I develop sites with my own custom publishing engine that I've been
> adding to since about 1998...all in PHP.  My goals are to keep it as
> modular as possible, so I can easily plug in different bits of
> functionality, and provide my clients with the greatest amount of
> flexibility in terms of what it can be used for.
>
> So, with that mindset, I'm interested in how people here have
> approached multilingual sites in a PHP/MySQL environment?  In
> particular, I have an upcoming cultural project that will be
> translated into an unknown number of languages, and only in bits and
> pieces.  So, at any given point in the content hierarchy, the system
> will need to look for a preferred language, and if it isn't found, go
> to the next on the list, and so on.
>
> (This is similar to the way Mac OS X works if any of you have used it.)
>
> The content will vary in terms of scope, length and type; right now,
> I tend to utilize MySQL for text data storage about 80% of the time,
> and the other 20% of the time I store textual content in text files,
> as serialized PHP objects.  I always store graphics in the filesystem.
>
> So, I have my own ideas on how I am going to approach this, but here
> are my questions.
>
> How do you handle multilingual sites?  Do you tend to store data in
> text files, in a database, or some other way?  Do you maintain
> different entire databases for each language, or different tables in
> the same database, or just different columns in the same table(s)?
>
> Looking for abstract answers here about strategy.
>
> Thanks much,
>
> --
> Marc Antony Vose
> http://www.suzerain.com/
>
> Never underestimate the power of human stupidity.
> -- Lazarus Long
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
>




More information about the talk mailing list