Part 1:
Let's say I do something which throws an exception like:
function do_something($somepar)
{
if (inexistent())
return TRUE;
else
return FALSE;
}
if (do_something("SMART"))
echo "Everything went right";
else
echo "Something failed";
I got
Fatal error: Call to undefined function inexistent() in xyz.php on line 123
Is it possible to localize this message? I hoped
setlocale(LC_ALL,'it_IT');
could do that but it didn't.
Part 2:
which is your recommendation to handle localized errors. Let's say I want to create a general function to public it on the web and can be used by people who want it to use their own language.
function do_something($somepar)
{
if (whatever())
{
return TRUE;
}
else
{
$error_message = localizeThis("How to translate this?");
trigger_error($error_message, E_USER_ERROR);
return FALSE;
}
}
if (do_something("SMART"))
echo "Everything went right";
else
echo "Something failed";
Also how to set the correct output language?