chunhei2008/hyperf-translation

此包已被弃用且不再维护。未建议替代包。

v1.0.0 2019-07-31 07:52 UTC

This package is auto-updated.

Last update: 2020-08-30 01:38:48 UTC


README

关于

chunhei2008/hyperf-translation 是 Laravel Translation 的移植(不包括门面和快捷函数部分),具体使用方法可以参考 Laravel Lang 的使用。

安装

composer require chunhei2008/hyperf-translation

配置

发布配置

php bin/hyperf.php  vendor:publish chunhei2008/hyperf-translation

配置路径

your/config/path/autoload/translation.php

配置内容

<?php

declare(strict_types=1);

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

return [
    'locale'          => 'en',   
    'fallback_locale' => '',
    'lang'            => BASE_PATH . '/resources/lang', 
];

使用方法


$translator = $this->container->get(\Chunhei2008\Hyperf\Translation\Contracts\Translator::class);

$translator->trans('validation.accepted'),