承接 romeoz/rock-i18n 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

romeoz/rock-i18n

最新稳定版本:0.11.0

Composer 安装命令:

composer require romeoz/rock-i18n

包简介

i18n library for PHP

README 文档

README

Latest Stable Version Total Downloads Build Status HHVM Status Coverage Status License

Features

Installation

From the Command Line:

composer require romeoz/rock-i18n

In your composer.json:

{
    "require": {
        "romeoz/rock-i18n": "*"
    }
}

Quick Start

use rock\i18n\i18n;

$i18n = new i18n;

$i18n->add('hello', 'Hello {{placeholder}}');

$i18n->translate('hello', ['placeholder' => 'world!']); // output: Hello world!

// or 

i18n::t('hello', ['placeholder' => 'Rock!']); // output: Hello Rock!

Documentation

####addMulti(array $data)

Adds list i18-records as array.

use rock\i18n\i18n;

$i18n = new i18n;

$i18n->addMulti([
    'en' => [                // locale
        'lang' => [         // category
            'hello' => 'Hello world!'
        ]
    ],
    'ru' => [
        'lang' => [
            'hello' => 'Привет мир!'
        ]
    ]
]);

####addDicts(array $dicts)

Adds dicts as paths.

use rock\i18n\i18n;

$config = [
    'pathDicts' => [ 
        'en' => [
                'path/to/en/lang.php',
                'path/to/en/validate.php',
            ]
        ]
     ]   
];
$i18n = new i18n($config);

// or

$paths = [ 
    'en' => [
         'path/to/en/lang.php',
         'path/to/en/validate.php',
     ]
];
$i18n->addDicts($paths);

###translate(string|array $keys, array $placeholders = [])

$keys can be a string, composite string (months.nov), or array (['months', 'nov']).

$i18n->translate('hello');

###static t(string|array$keys, array $placeholders = [], $category = null, $locale = null)

Translation via the static method.

i18n::t('hello');

###locale(string $locale)

Select locale.

use rock\i18n\i18n;

$i18n = new i18n;
$i18n->locale('fr');
$i18n->translate('hello');

###category($category)

Select category.

use rock\i18n\i18n;

$i18n = new i18n;
$i18n->locale('fr')->category('validate');
$i18n->translate('required');

Requirements

  • PHP 5.4+

License

Rock i18n library is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 901
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-31