Skip to content

Commit

Permalink
DOC: Added example for localization by TLD
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Jul 4, 2016
1 parent d9b134e commit a759863
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ Example router might look like this
$router[] = new Route('[<locale=cs cs|en>/]<presenter>/<action>', "Homepage:default");
```

or with new version of Nette, you can get localization by TLD (top level domain) look like this

```php
$router[] = new Route('//%sld%.<locale>/<presenter>/<action>[/<id>]', [
'presenter' => 'Homepage',
'action' => 'default',
'id' => null,
'locale' => [
Route::FILTER_TABLE => [
'cz' => 'cs',
'sk' => 'sk',
'pl' => 'pl',
'com' => 'en'
]
]
]);
```

There is also an interface `IUserLocaleResolver` and few default implementations. These implementations try to figure out, in what language should the website be displayed.
The first one looks in request parameters and searches for `locale`, that's why there is the persistent parameter and example route. If it fails, it tries to look at `Accept-Language` header, and if that fails, it fallbacks to default locale.

Expand Down

0 comments on commit a759863

Please sign in to comment.