I'm rebuilding the language system on my php application to make it easier to create translations.
one of the things I did was convert everything to one big array $lang; here is an example of what that looks like:
$lang['common:login'] = "Login";
$lang['common:signup'] = "Sign Up";
$lang['index:title'] = "Home Page";
$lang['messages:newmessages'] = "You have %s new messages";
I load it by using the following code:
require_once "lang/en/lang.php";
calling $lang['common:login'] will wqork with no problem, the problems occurred once I made a function for loading these compared to the other way I've done it in the past.
function outputLanguage($tag) {
global $lang;
//see if tag exists.
if (!in_array($tag, $lang)) {
return $tag." is an invalid language tag.";
} else {
return $lang[$tag];
}
}
it seems that in_array() doesn't like to work with arrays that included from another source.
I honestly would like to have some validation in case someone made a mistake, so does anyone know of a good solution?
Thanks.