Skip to content

Commit

Permalink
add more usage info to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed Jun 6, 2021
1 parent 9d3b276 commit 35f9f83
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ You can install it via Composer: `composer require jrmajor/laravel-fluent`. It r

## Usage

This package replaces default Laravel translator with `Major\Fluent\Laravel\FluentTranslator`.

```php
app('translator') instanceof Major\Fluent\Laravel\FluentTranslator; // true
```

Fluent translations are stored in `.ftl` files. Place them among your `.php` translation files in your Laravel app:

```
Expand All @@ -44,9 +50,21 @@ Fluent translations are stored in `.ftl` files. Place them among your `.php` tra
validation.php
```

If there is no Fluent message for given key, translator will fall back to `.php` file, which allows you to introduce Fluent translation format progressively. Laravel validator uses custom logic for replacing `:attribute` variable and requires deeply nested keys, which are not supported in Fluent, so you should leave `validation.php` file in default Laravel format.
If there is no Fluent message for given key, translator will fall back to `.php` file, which allows you to introduce Fluent translation format progressively.

Laravel validator uses custom logic for replacing `:attribute` variable and requires deeply nested keys, which are not supported in Fluent, so you should leave `validation.php` file in default Laravel format.

`trans_choice()` helper always falls back to default translator, as Fluent format eliminates the need for another function.

## Installation

You may install the package via Composer:

```shell
composer require jrmajor/laravel-fluent
```

### Configuration
The package will automatically register itself.

Optionally, you can publish the configuration file with this command:

Expand Down

0 comments on commit 35f9f83

Please sign in to comment.