The code isn't the problem. It's gettext() not loading the locale, and I don't know how to install it. The system works perfectly for en_US, but when I pass it fr_FR it fails.
But if you insist:
function translate($language, $flushcache = false){
//veritas3-0\webroot\Locale\[language]\LC_MESSAGES will need clearing of duplicate mo files
//$language="fr_CA";
putenv("LANG=$language"
;
putenv("LANGUAGE=$language"
;
putenv("LC_ALL=$language"
;
setlocale(LC_ALL, $language);//.UTF-8
$domain = 'default';
$dir= getcwd() . "/Locale";
if($flushcache){//MUST NOT USE ON LIVE!
$path = $dir . "/" . $language . "/LC_MESSAGES/";
$filename = $path . $domain . ".mo" ;
$mtime = filemtime($filename);
$filename_new = $path . $domain . $mtime . ".mo" ;
if (!file_exists($filename_new)){
copy($filename,$filename_new);
}
$domain = $domain . $mtime;
}
bindtextdomain($domain, $dir);//www/veritsa3-0/, Locale
textdomain($domain);
if(gettext("test"
=="test"
{
echo $language . " is not installed on this system.";
}
return $language;
}