Download the PHP package getsupercode/localizater without Composer
On this page you can find all versions of the php package getsupercode/localizater. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download getsupercode/localizater
More information about getsupercode/localizater
Files in getsupercode/localizater
Package localizater
Short Description Laravel package for wrapping routes in multiple locale prefixes
License MIT
Homepage https://github.com/getsupercode/localizater
Informations about the package localizater
Localizater
Laravel package for wrapping routes in multiple locale prefixes.
Installation
Via Composer
To detect and change the locale of the application based on the request automatically, you can add this middleware to your app/Http/Kernel
:
Configuration
By default, the application locales are only going to be en
and the default locale is not prefixed. If you want to prefix the default locale, please run the following command to publish the configuration file:
After installing the package, Adding the middleware and publishing the configuration file. You need to edit the configuration file config/localizater.php
in order to add more locales.
Note
The default locale is app.locale
located at config/app.php
file.
Config: localizater.locales
Add supported locales. It's recommended to write the locale value with its native language.
Config: localizater.rtl_locales
Add RTL direction locales.
Config: localizater.prefix_default
If this option is set to true, Default locale URL will be prefixed.
Config: localizater.prefix_default_name
If this option is set to true, Default locale route name will be prefixed.
true:
Method | URI | URI | Name |
---|---|---|---|
GET | HEAD | /page | en.page |
GET | HEAD | /fr/page | fr.page |
false:
Method | URI | URI | Name |
---|---|---|---|
GET | HEAD | /page | page |
GET | HEAD | /fr/page | fr.page |
Usage
The package will not override the route features you already know. It's just a wrapper function that will create multiple locale routes for you.
The above example will give us:
Method | URI | Name |
---|---|---|
GET|HEAD | / | welcome |
GET|HEAD | /fr | fr.welcome |
GET|HEAD | /user | |
GET|HEAD | /fr/user | fr. |
POST | /user |
Route naming
If you add a name to a route it will be prepended by the locale key locale.name
. for example: (fr.welcome
)
All locales without a name will have the same prefix name like fr.
. And this is normal as you don't need its names.
Localizater attributes
You can add attributes to the localizer group function as you do with the route group function.
Or:
Get route URL in a specified locale
You can get the current route URL in different locale key:
Or a named route:
You can pass the same parameters as the route()
function after the locale parameter.
Get locale language name
You can get the value of the locale key in localizater.locales
configuration for the current locale or a specified locale:
Get HTML dir
attribute based on current locale
You can get HTML dir
attribute based on current locale. The package will search for RTL locales in localizater.rtl_locales
config. If the current locale is listed there, The output will be rtl
or ltr
if it's not listed.
You can also get dir
attribute for a specified locale:
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Mohamed Elkebir
- All Contributors
License
MIT. Please see the license file for more information.