yac/yii18n

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

i18n for javascript files

Installs: 330

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 2

Open Issues: 0

Type:yii2-extension

dev-master 2017-03-08 13:15 UTC

This package is not auto-updated.

Last update: 2018-10-28 08:52:23 UTC


README

Requirements

  • PHP >= 5.6.x
  • Yii >= 2.0.x

Installation

Add in your composer.json file "yac/yii18n": "dev-master"

Then run in your terminal: composer update

Usage

You must add the translator module in your config/web.php

    'modules' => [
        'translator' => [
            'class' => 'yac\yii18n\TranslatorModule'
        ]
    ],

Add the class message source with class 'yac\yii18n\PhpMessageSource'

    'components' => [
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yac\yii18n\PhpMessageSource',  // Add This class
                    'fileMap' => [
                        'app' => 'app.php',
                        'app/error' => 'error.php',
                    ],
                ],
            ],
        ],
    ],

note: you need set urlmanager > enablePrettyUrl as true

in your view you must add the translator asset:

    yac\yii18n\TranslatorAsset::register($this);

then it's already to use you can use like yii::t() style

in your js file:

    yii.t('category', 'message', 'params');

Todo

  • Remove sync request
  • Add plural
  • Add ordinal