I'm localizing my site and using an array to store language strings. This is my architecture:
One file per language, for example: language_en.php
for English, language_fr.php
for French that gets included in the beginning of the script.
In each language file I have an array (consisting of about 2000 elements):
static $phrases = array();
$phrases['del'] = 'Remove';
...
Then I have a function:
function phrase($key) {
global $phrases;
return $phrases[$key]
}
Where-ever I need a localized string further in my app, I use:
phrase('del');
Couple of questions around this architecture:
$language
is global, does this have negative performance effects when the array gets larger and larger?- Would it be better to add the array right into the
phrase()
function and avoid it to be global?