erneststaug / i18next-php
PHP 版本的 i18next JS 库移植
1.0.6
2020-03-06 17:25 UTC
Requires
- php: >=7.3
- ext-json: *
- ext-mbstring: *
- psr/log: ^1.1
Requires (Dev)
- monolog/monolog: ^2.0
- phpunit/phpunit: 6.*
Suggests
- monolog/monolog: An excellent logging solution, integrates seamlessly
README
PHP 版本的 i18next,包含 REST API。(即将推出 [tm])
此仓库中的代码主要基于 JavaScript 原始代码库,用 PHP 重新编写。本项目只关注 i18next 的最新版本,不考虑与旧版本的兼容性。
警告!
此版本可使用,但可能包含错误。如果您发现任何问题,请报告或创建 PR。
特性
- PSR3 日志支持(psr/log 是强制要求,但您不必实际使用记录器)
- 与 JS 版本极为相似的 API
- PHP 特定功能,如模块接口
- PHP 7.3+
- 自动语言检测支持
使用方法
基本示例
// You can also use I18n globally via I18n::get() $i18n = new I18n([ 'lng' => 'en', 'resources' => [ 'en' => [ 'translation' => [ 'key' => 'Value', 'key_plural' => 'Value plural' 'deeper' => [ 'key' => 'Deep value' ] ] ] ] ]); $i18n->t('key'); // "Value" $i18n->t('key', ['count' => 5]); // "Value plural" $i18n->t('deeper.key'); // "Depp value"
Composer
只需进入您的项目目录并运行
composer require pkly/i18next-php
待办事项
- 添加事件发射
Packagist
访问页面 此处
捐赠
如果您想,请通过点击此处为我买杯咖啡