I am working on a small project that consists of registration, login, password reset and user management on the back-end. I have to create translation files for different languages and instead of using something like gettext (which I know nothing about), I decided to implement a very simple method using a static array for each language file like this:
function plLang($phrase) {
$trimmed = trim($phrase);
static $lang = array(
/* -----------------------------------
1. REGISTRATION HTML
----------------------------------- */
'LNG_1' => 'some text',
'LNG_2' => 'some other text',
etc. ...
);
$returnedPhrase = (!array_key_exists($trimmed,$lang)) ? $trimmed : $lang[$trimmed];
echo $returnedPhrase;
}
It works fine, it is very fast at this stage but my markup now is littered with php language tags and I'm not sure I've made the right decision. I've never done this before so I have no idea what I'm looking forward to. It also seems that by the time I am all done, this file is going to be a mile long.
Is this a good way of doing this? Is there a better way you could suggest?
Thank you!