Skip to content

Commit 5f88ff3

Browse files
committed
Add info about midddleware in README
1 parent dda3980 commit 5f88ff3

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
This plugins provides:
1111

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

99+
### I18nMiddleware
100+
101+
You can setup the `I18nMiddleware` in your `src/Application::middleware()` as
102+
shown:
103+
104+
```php
105+
$middlware->add(new \ADmad\I18n\Middlware\I18nMiddleware([
106+
'defaultLanguage' => 'en',
107+
'languages' => [
108+
'en' => ['locale' => 'en_US'],
109+
'fr' => ['locale' => 'fr_FR']
110+
],
111+
]));
112+
```
113+
114+
The keys of `languages` array are the language prefixes you use in your URL.
115+
96116
### TimezoneWidget
97117

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

0 commit comments

Comments
 (0)