Skip to content

Commit

Permalink
Remove package configuration (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Nov 5, 2022
1 parent 4e04392 commit 9cc9585
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## 1.0.1 under development

- Chg #40: Remove package configuration (@vjik)
- Enh #41: Raise minimum PHP version to `^8.0` (@vjik)

## 1.0.0 May 13, 2021
Expand Down
47 changes: 14 additions & 33 deletions README.md
Expand Up @@ -28,49 +28,30 @@ with [`yiisoft/translator`](https://github.com/yiisoft/translator) package.
The package could be installed with composer:

```shell
composer require yiisoft/translator-message-gettext --prefer-dist
composer require yiisoft/translator-message-gettext
```

## Configuration
### Attention

In case you use [`yiisoft/config`](http://github.com/yiisoft/config), you will get configuration automatically. If not, the following DI container configuration is necessary:
When using gettext, `locale` depends on your OS requirement:
* for Windows `'locale' => 'en-US.UTF-8'`
* for Linux `'locale' => 'en_US.UTF-8'`

```php
<?php
## General usage

declare(strict_types=1);
The package is meant to be used with [`yiisoft/translator`](https://github.com/yiisoft/translator):

use Yiisoft\Translator\MessageReaderInterface;
```php
use Yiisoft\Translator\CategorySource;
use Yiisoft\Translator\Message\Gettext\MessageSource;
use Yiisoft\Aliases\Aliases;

return [
MessageReaderInterface::class => [
'class' => MessageSource::class,
'__construct()' => [
DynamicReference::to(fn (Aliases $aliases) => $aliases->get('@message')),
],
],
];
```

**Note:** You can use absolute path to translation files in case you don't want to use [`yiisoft/aliases`](https://github.com/yiisoft/aliases)
```php
MessageReaderInterface::class => [
'class' => MessageSource::class,
'__construct()' => [
'/var/www/app/resourse/messages',
],
],
$categorySource = new CategorySource(
'my-category',
new MessageSource('/path/to/messages'),
);
```

### Attention

When using gettext, `locale` depends on your OS requirement:
* for Windows `'locale' => 'en-US.UTF-8'`
* for Linux `'locale' => 'en_US.UTF-8'`

## General usage
The examples below are about using it separately.

### Create of instance of MessageSource

Expand Down
12 changes: 2 additions & 10 deletions composer.json
Expand Up @@ -21,8 +21,8 @@
},
"require": {
"php": "^8.0",
"yiisoft/translator": "^1.0",
"ext-gettext": "*"
"ext-gettext": "*",
"yiisoft/translator": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand All @@ -41,14 +41,6 @@
"Yiisoft\\Translator\\Message\\Gettext\\Tests\\": "tests"
}
},
"extra": {
"config-plugin-options": {
"source-directory": "config"
},
"config-plugin": {
"common": "common.php"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
17 changes: 0 additions & 17 deletions config/common.php

This file was deleted.

0 comments on commit 9cc9585

Please sign in to comment.