PHP - Language Data
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.
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)...
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
精彩评论