2017 © Pedro Peláez
 

library phalcon-translate-adapter-nestednativearray

NestedNativeArray adapter for Translate.

image

muroi/phalcon-translate-adapter-nestednativearray

NestedNativeArray adapter for Translate.

  • Wednesday, September 21, 2016
  • by T.Muroi
  • Repository
  • 0 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 14 % Grown

The README.md

phalcon-translate-adapter-nestednativearray

翻訳の変換リストを多次元配列で定義出来るように対応したアダプタ, (*1)

Install

{
    "require": {
        "muroi/phalcon-translate-adapter-nestednativearray": "*"
    }
}

or, (*2)

``` shell php composer.phar require muroi/phalcon-translate-adapter-nestednativearray, (*3)


## Usage ### 翻訳リストファイルを作成

app/messages/ja.php app/messages/en.php, (*4)


* ファイルの中身 ``` php <?php // app/messages/ja.php $messages = [ 'test' => [ 'hello' => 'こんにちは' ], 'test1' => [ 'test2' => [ 'test3' => 'テスト3' ] ] ];

コントローラで呼び出す

``` php <?php, (*5)

use Phalcon\Mvc\Controller; use Muroi\Phalcon\Translate\Adapter\NestedNativeArray;, (*6)

class UserController extends Controller { protected function getTranslation() { // Ask browser what is the best language $language = $this->request->getBestLanguage();, (*7)

    $translationFile = "app/messages/" . $language . ".php";

    // Check if we have a translation file for that lang
    if (file_exists($translationFile)) {
        require $translationFile;
    } else {
        // Fallback to some default
        require "app/messages/en.php";
    }

    // Return a translation object
    return new NestedNativeArray(
        [
            "content" => $messages,
        ]
    );
}

public function indexAction()
{
    $this->view->t = $this->getTranslation();
}

}, (*8)


### View ``` volt <!-- こんにちは --> <p>{{ t._("test.hello") }}</p>

See

Phalcon Translate, (*9)

The Versions

21/09 2016

dev-master

9999999-dev https://github.com/intemous9/phalcon-translate-adapter-nestednativearray

NestedNativeArray adapter for Translate.

  Sources   Download

MIT

by Avatar T.Muroi

phalcon

21/09 2016

1.0.0

1.0.0.0 https://github.com/intemous9/phalcon-translate-adapter-nestednativearray

NestedNativeArray adapter for Translate.

  Sources   Download

MIT

by Avatar T.Muroi

phalcon