Need words of advise for language system

Posted on 2005-02-27
Medium Priority
Last Modified: 2008-03-10
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.

Question by:stimno1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 25

Accepted Solution

Marcus Bointon earned 195 total points
ID: 13418305
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.

Assisted Solution

alberthendriks earned 180 total points
ID: 13418421
For smaller sites, the variable approach will suit.




echo _HELLO;

Author Comment

ID: 13420219
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).
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

LVL 25

Expert Comment

by:Marcus Bointon
ID: 13420490

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!

Author Comment

ID: 13420947
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.

Author Comment

ID: 13574209
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..

Featured Post

Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question