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

(mvc) some gettext stuff

parent f730946c
...@@ -31,7 +31,7 @@ namespace OPNsense\Base; ...@@ -31,7 +31,7 @@ namespace OPNsense\Base;
use OPNsense\Core\Config; use OPNsense\Core\Config;
use OPNsense\Core\ACL; use OPNsense\Core\ACL;
use Phalcon\Mvc\Controller; use Phalcon\Mvc\Controller;
use Phalcon\Translate\Adapter\NativeArray; use Phalcon\Translate\Adapter\Gettext;
/** /**
* Class ControllerBase implements core controller for OPNsense framework * Class ControllerBase implements core controller for OPNsense framework
...@@ -45,12 +45,20 @@ class ControllerBase extends Controller ...@@ -45,12 +45,20 @@ class ControllerBase extends Controller
*/ */
public function getTranslator() public function getTranslator()
{ {
// TODO: implement language service if (function_exists("gettext")) {
$messages = array(); // gettext installed, return gettext translator
return new NativeArray(array( return new Gettext(array(
"content" => $messages "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()
)); ));
} }
}
/** /**
* convert xml form definition to simple data structure to use in our Volt templates * convert xml form definition to simple data structure to use in our Volt templates
...@@ -91,8 +99,13 @@ class ControllerBase extends Controller ...@@ -91,8 +99,13 @@ class ControllerBase extends Controller
case "help": case "help":
case "hint": case "hint":
case "label": case "label":
// translate text items // translate text items if gettext is enabled
if (function_exists("gettext")) {
$result[$key] = gettext((string)$node); $result[$key] = gettext((string)$node);
} else {
$result[$key] = (string)$node;
}
break; break;
default: default:
// default behavior, copy in value as key/value data // 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