Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Added example for localization by TLD #116

Merged
merged 1 commit into from Jul 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/en/index.md
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