PHP code example of muroi / phalcon-translate-adapter-nestednativearray
1. Go to this page and download the library: Download muroi/phalcon-translate-adapter-nestednativearray library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
muroi / phalcon-translate-adapter-nestednativearray example snippets
app/messages/ja.php
app/messages/en.php
php
// app/messages/ja.php
$messages = [
'test' => [
'hello' => 'こんにちは'
],
'test1' => [
'test2' => [
'test3' => 'テスト3'
]
]
];
php
use Phalcon\Mvc\Controller;
use Muroi\Phalcon\Translate\Adapter\NestedNativeArray;
class UserController extends Controller
{
protected function getTranslation()
{
// Ask browser what is the best language
$language = $this->request->getBestLanguage();
$translationFile = "app/messages/" . $language . ".php";
// Check if we have a translation file for that lang
if (file_exists($translationFile)) {