Phalcon PHP NativeArray accessing multidimensional array using Volt Template -


i able add multi language support in phalcon using volt template.

but can't access phalcon multi dimensional nativearray in volt.

here gettranslation function:

private function _gettranslation() {     global $config;      if ( isset($config[$_server['http_host']]['language']) ) {         $language = $config[$_server['http_host']]['language'];     } else if ( $this->session->get('auth') ) {         $language = "pt";     } else {         //ask browser best language         $language = $this->request->getbestlanguage();     }      //check if have translation file lang     if (file_exists(__dir__ . "/../translations/".$language.".php")) {        require __dir__ . "/../translations/".$language.".php";     } else {        // fallback default        require __dir__ . "/../translations/en-us.php";     }      //return translation object     return new \phalcon\translate\adapter\nativearray(array(        "content" => $messages     )); } 

then setvar:

$this->view->setvar("t", $this->_gettranslation()); 

which load translation file this:

$messages = array( "pages" => array(     "index" => array(         "title" => "create account today",         "call_to_action" => "join now!",         "search_title" => "find:",         "search_option" => "i want to:",         "search_type" => "type:",         "search_where" => "located on:",         "search_button" => "go",     ) ); 

in volt template access like

$t['pages']['index']['call_to_action'] 

which in volt be:

<div class="call_to_action">{{ t._('pages').('index').('call_to_action') }}</div> 

but doesn't work!

is there way access nativearray multi dimensional elements within volt template?

try this..

for more information refer twig documentation

{{ dump(t['pages']['index']['call_to_action']) }} 

output example:

string 'join now!' (length=9) 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -