Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hyperf/translation

A independent translation component
https://github.com/hyperf/translation

coroutine hyperf i18n swoole translation

Last synced: 10 days ago
JSON representation

A independent translation component

Awesome Lists containing this project

README

        

# Hyperf Translation

[hyperf/translation](https://github.com/hyperf/translation) 组件衍生于 `Laravel Translation` 组件的,我们对它进行了一些改造,大部分功能保持了相同。在这里感谢一下 Laravel 开发组,实现了如此强大好用的 Translation 组件。

## Installation

```bash
composer require hyperf/translation
```

## Configuration

### Publish config

```bash
php bin/hyperf.php vendor:publish hyperf/translation
```

Config files:
```
+ ./config/autoload/translation.php
```

### Configuration

```php
'en',
'fallback_locale' => '',
'path' => BASE_PATH . '/storage/languages',
];
```

## Usage

```php
$container = ApplicationContext::getContainer();
$translator = $container->get(\Hyperf\Contract\TranslatorInterface::class);
$translator->trans('validation.accepted');
```