/**
* Perform a language translation
*
* @param string $text Text for translation.
* @param string $textdomain Textdomain for the text, may be class name, filename, or something made up by you. If ommitted, a debug backtrace will attempt to determine it automatically.
* @param string $context Name of context - DO NOT USE with this function for translation as it won't be parsed for translation. Use only with the _x() function, which will be parsed.
* @return string Translated text or original text if translation not available.
*
*
*/
function __($text, $textdomain = null, $context = '')
{
if (!Wire::getFuel('languages')) {
return $text;
}
if (!($language = Wire::getFuel('user')->language)) {
return $text;
}
if (!$language->id) {
return $text;
}
if (is_null($textdomain)) {
$traces = @debug_backtrace(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
if (isset($traces[0]) && $traces[0]['file'] != __FILE__) {
$textdomain = $traces[0]['file'];
} else {
if (isset($traces[1]) && $traces[1]['file'] != __FILE__) {
$textdomain = $traces[1]['file'];
}
}
if (is_null($textdomain)) {
$textdomain = 'site';
}
}
return htmlspecialchars($language->translator()->getTranslation($textdomain, $text, $context), ENT_QUOTES, 'UTF-8');
}