Commit 2723668e authored by Ad Schellevis's avatar Ad Schellevis

(mvc) some gettext stuff

parent f730946c
......@@ -31,7 +31,7 @@ namespace OPNsense\Base;
use OPNsense\Core\Config;
use OPNsense\Core\ACL;
use Phalcon\Mvc\Controller;
use Phalcon\Translate\Adapter\NativeArray;
use Phalcon\Translate\Adapter\Gettext;
/**
* Class ControllerBase implements core controller for OPNsense framework
......@@ -45,11 +45,19 @@ class ControllerBase extends Controller
*/
public function getTranslator()
{
// TODO: implement language service
$messages = array();
return new NativeArray(array(
"content" => $messages
));
if (function_exists("gettext")) {
// gettext installed, return gettext translator
return new Gettext(array(
"locale" => locale_get_default(),
"directory" => "/usr/local/share/locale/",
'file' => 'LC_MESSAGES/OPNsense.pot',
));
} else {
// no gettext installed, return original content
return new Gettext(array(
"content" => array()
));
}
}
/**
......@@ -91,8 +99,13 @@ class ControllerBase extends Controller
case "help":
case "hint":
case "label":
// translate text items
$result[$key] = gettext((string)$node);
// translate text items if gettext is enabled
if (function_exists("gettext")) {
$result[$key] = gettext((string)$node);
} else {
$result[$key] = (string)$node;
}
break;
default:
// default behavior, copy in value as key/value data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment