alpakaio / i18next-php
PHP版的i18next JS库移植
v1.0.6
2021-11-18 17:42 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
This package is not auto-updated.
Last update: 2024-09-21 06:18:37 UTC
README
PHP版的i18next。包含REST API。(即将推出 [tm])
此仓库中的代码主要基于JavaScript原始代码库,用PHP重写。本项目只关注i18next的最新版本,不考虑与旧版本的兼容性。
警告!
此版本可用,但可能包含错误。如果您发现任何问题,请报告它们或创建PR。
特性
- PSR3日志支持(psr/log是硬性要求,但您不需要实际使用记录器)
- API与JS版本极其相似
- 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 alpakaio/i18next-php
待办事项
- 添加事件发射
Packagist
访问此页面