I am working on a small project that consists of registration, login, reset password and user management on the internal server. I have to create translation files for different languages, and instead of using something like gettext (which I don’t know anything about), I decided to implement a very simple method using a static array for each language file as follows:
function plLang($phrase) {
$trimmed = trim($phrase);
static $lang = array(
'LNG_1' => 'some text',
'LNG_2' => 'some other text',
etc. ...
);
$returnedPhrase = (!array_key_exists($trimmed,$lang)) ? $trimmed : $lang[$trimmed];
echo $returnedPhrase;
}
It works great, very fast at this point, but now my markup is dotted with php tags, and I'm not sure I made the right decision. I have never done this before, so I have no idea what I'm looking forward to. It also seems that by the time I'm done, this file will be a mile long.
Is this a good way to do this? Is there a better way you could suggest?
!