Skip to content

Commit a2e6975

Browse files
committed
Update README.md
1 parent 54bfd04 commit a2e6975

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
#### A convenient way to set up, manage and use localized routes in a Laravel app.
1111

1212
- [Automatically register](#register-routes) a route for each locale you wish to support.
13+
- Use [route slugs or custom domains](#supported-locales) (or subdomains)
1314
- Optionally remove the locale slug from the URL for your main language.
1415
- [Generate localized route URL's](#generate-route-urls) in the simplest way using the `route()` helper.
1516
- [Redirect to localized routes](#redirect-to-routes) using the `redirect()->route()` helper.
1617
- Allow routes to be [cached](#cache-routes).
17-
- Let you work with routes without thinking too much about locales.
1818
- Optionally [translate each segment](#translate-routes) in your URI's.
19+
- **Let you work with routes without thinking too much about locales.**
1920

2021
## Requirements
2122

@@ -30,6 +31,8 @@ composer require codezero/laravel-localized-routes
3031

3132
> Laravel will automatically register the ServiceProvider.
3233
34+
## Configure
35+
3336
#### Publish Configuration File
3437

3538
```php
@@ -38,14 +41,32 @@ php artisan vendor:publish --provider="CodeZero\LocalizedRoutes\LocalizedRoutesS
3841

3942
You will now find a `localized-routes.php` file in the `config` folder.
4043

41-
#### Configure
44+
#### Supported Locales
45+
46+
##### Using Slugs
4247

4348
Add any locales you wish to support to your published `config/localized-routes.php` file:
4449

4550
```php
4651
'supported-locales' => ['en', 'nl', 'fr'],
4752
```
4853

54+
This will automically prepend a slug to your localized routes. [More on this below](#register-routes).
55+
56+
##### Using Domains
57+
58+
Alternatively, you can use a different domain or subdomain for each locale by adding them to the `supported-locales` like this:
59+
60+
```php
61+
'supported-locales' => [
62+
'en' => 'example.com',
63+
'nl' => 'nl.example.com',
64+
'fr' => 'fr.example.com',
65+
],
66+
```
67+
68+
#### Omit Slug for Main Locale
69+
4970
Specify your main locale if you want to omit its slug from the URL:
5071

5172
```php
@@ -58,6 +79,8 @@ Setting this option to `'en'` will result, for example, in URL's like this:
5879
- Dutch: `/nl/some-url` as usual
5980
- French: `/fr/some-url` as usual
6081

82+
> This option has no effect if you use domains instead of slugs.
83+
6184
## Register Routes
6285

6386
Example:
@@ -81,7 +104,7 @@ Route::localized(function () {
81104
});
82105
```
83106

84-
In the above example there are 5 routes being registered. The routes defined in the `Route::localized` closure are automatically registered for each configured locale. This will prepend the locale to the route's URI and name.
107+
In the above example there are 5 routes being registered. The routes defined in the `Route::localized` closure are automatically registered for each configured locale. This will prepend the locale to the route's URI and name. If you configured custom domains, it will use those instead of the slugs.
85108

86109
| URI | Name |
87110
| ----------------- | ---------------------- |

0 commit comments

Comments
 (0)