erneststaug/i18next-php

PHP 版本的 i18next JS 库移植

安装次数: 11,216

依赖关系: 0

建议者: 0

安全性: 0

星标: 0

关注者: 0

分支: 0

类型:项目

1.0.6 2020-03-06 17:25 UTC

This package is not auto-updated.

Last update: 2024-09-19 03:42:49 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

访问页面 此处

捐赠

如果您想,请通过点击此处为我买杯咖啡