Skip to content

Commit

Permalink
Add info about midddleware in README
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Dec 18, 2016
1 parent dda3980 commit 5f88ff3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
This plugins provides:

- Route class for generating and matching urls with language prefix.
- Middleware (dispatcher filter or CakePHP < 3.3) which sets `I18n::locale()`
based on language prefix in URL and also provides redirection to appropriate
URL with language prefix when accessing site root.
- Class for retrieving translation messages stored in database instead of po/mo files.
- Validation class for auto translating validation message.
- A widget to generate select box with list of timezone identifiers.
Expand Down Expand Up @@ -93,6 +96,23 @@ files and populate the translations table. Updating the db records with
translations for each language is upto you. Having the messages in a table
instead of files make it much to make a web interface for managing translations.

### I18nMiddleware

You can setup the `I18nMiddleware` in your `src/Application::middleware()` as
shown:

```php
$middlware->add(new \ADmad\I18n\Middlware\I18nMiddleware([
'defaultLanguage' => 'en',
'languages' => [
'en' => ['locale' => 'en_US'],
'fr' => ['locale' => 'fr_FR']
],
]));
```

The keys of `languages` array are the language prefixes you use in your URL.

### TimezoneWidget

In your `AppView::initialize()` configure the `FormHelper` to use `TimezoneWidget`.
Expand Down

0 comments on commit 5f88ff3

Please sign in to comment.