tags:

views:

24

answers:

2

What's the best way to store language data?


Keep it as variables in some kind of lang.php file...

$l_ipsum = 'smth';

$l_rand = 'string';


Or select them from a database? I'm in search of your advice.

+1  A: 

Keep them in an array, so you don't pollute the global namespace.

    $lang = array(
        'ipsum' => 'smth',
        'rand' => 'string',
    );

Plus, you can create a helper function to get the string

    function translate($string) {
        global $lang;
        return isset($lang[$string]) ? $lang[$string] : $string;
    }

Of course, there are a thousand ways to do this (and I personally wouldn't use global variables, but it's all up to your skill level and personal preferences)...

ircmaxell
A: 

Here is a list of a Zend_Translate adapters to give you idea of how it could look like

http://framework.zend.com/manual/en/zend.translate.adapter.html

zzz