Need words of advise for language system

Hi,
I'm busy building a site, using php. I designed it so that the php just returns xml to the browser, and combines this with a style sheet.
What I'd like to do is be able to use multiple languages on this pages, part of wich can be contained in the xsl style sheet. But some output must be generated by the php (such as input field labels). I could place every message in a db (using postgresql) and query everything I need, but that might slow down this page to much. Or I could have everything in a php script and access it by a function or just load it as variable (or constant).

I need some suggestions, advise or even some benchmarking perhaps, to make up my mind.

Thanks,
Tim
LVL 3
stimno1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marcus BointonCommented:
I use a custom Smarty extension I wrote that does queries on a translation DB. It's a whole load better than using the ugly gettext approach. The key way to keep performance up when using a DB for translations is to use caching (works especially well if your translations do not change much). Try using one of PEAR's caching modules, or use ADOdb (what I use in my Smarty extension) to talk to your DB as it has query caching built-in.

If you're sending only XML and XSL, then your browser compatibility will be way down - better to transform it at the server end.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alberthendriksCommented:
For smaller sites, the variable approach will suit.

en.php:
DEFINE('_HELLO','hello');

nl.php:
DEFINE('_HELLO','hallo');

config.php
$lang='en';

index.php:
require_once("config.php");
require_once($lang.".php");
echo _HELLO;
0
stimno1Author Commented:
@squinky
Can you tell me more about these pear modules? pear.php.net doesn't return much on a search for cache or caching.
I think I like smarty, although I do not agree on bad browser compatability with xml/xsl since xml is w3c standard (and I have solved all the problems I have encountered so far using mozilla ff and ie).
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Marcus BointonCommented:
http://pear.php.net/packages.php?catpid=3&catname=Caching

I think ADOdb is a little more elegant for DB applications than these generic caching packages.

I don't doubt that it's a W3C standard (and I'm generally very keen on sticking to W3C specs), it's just that many browsers I encounter don't have XSLT that works (let alone HTML or CSS in the case of IE), nor do I see many sites that try to use it. If you're going to have to implement server-side transformations to support those browsers anyway, there's not a huge amount to be gained by doing the client-side version in the first place. I'd like to see your site!
0
stimno1Author Commented:
Isn't caching just taking the data from the database and save it in a file? Why can't I do that myself.

I mean: I caching is so good, why don't I use that technique in the first place?

So: how does proper caching work? Or is it to complicated and should I stick to ready made developed stuff.
Thanks.
0
stimno1Author Commented:
I've taken a look at squirrel mail language support, and there solution used a getText module.
They've written there own function (or simply copied, don't know) to support the usability when the module is not installed. I took a fair glance at there code and decided to write a similar thing for myself.
I now load a file that seperates the name from the translation by ';' and use {$1} to replace by parameters.
The hole lot is loaded into a hash array, and is kept alive passing it through by session (I don't yet know wheter this is better than file reading every time). (The session save was used in squirrel because getText supports 'fuzzy translations' for when the original is slightly changed, and the translationfile is not yet updated. getText then searches for the best match. Because this takes a lot of cpu the best match is preserved to prevent continuous matching)

I know that i bare a couple of the getText features, but i don't think i'll ever need lft-to-rgt language support. So I'll save myself the trouble of getting into yet another extention..
Greedz
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.