emancypage / pkly-i18next-php
PHP版的i18next JS库的移植
dev-main
2021-11-15 13:46 UTC
Requires
- php: ^7.3|^8.0
- ext-json: *
- ext-mbstring: *
- psr/log: ^1.1
Requires (Dev)
- monolog/monolog: ^2.2
- phpunit/phpunit: ^9.3.3
Suggests
- monolog/monolog: An excellent logging solution, integrates seamlessly
This package is not auto-updated.
Last update: 2022-11-29 16:49:20 UTC
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
访问页面 此处
捐赠
如果您想,可以点击此处买我一杯咖啡