You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# LanguageSwitcher
2
2
Laravel Language Switcher Package
3
3
4
-
##Description
4
+
##Description
5
5
This package provides an easy to work with language switcher that you can use in your projects with a wide variety of config options.
6
6
It automatically bootstraps to your Laravel project, sets the locale, and switches the languages when needed.
7
7
@@ -10,7 +10,7 @@ whereas the default provided config will allow you to use the package right afte
10
10
11
11
I know it may seem very simple and perhaps over-complicated, but you don't have to waste time and thought process on the simple things.
12
12
13
-
##Installation
13
+
##Installation
14
14
To install the package, just run composer require ied3vil/language-switcher and follow the instructions.
15
15
If you want to add it to your composer.json manually, just open composer.json and search for the "autoload" field and add
16
16
```
@@ -50,7 +50,7 @@ Make sure you include the middleware at the end of the array, because it is reli
50
50
51
51
You are now ready to use the language switcher!
52
52
53
-
##Usage
53
+
##Usage
54
54
55
55
The default language set in your app.locale config value will be set. You can find it in the `config/app.php` config file.
56
56
@@ -67,7 +67,7 @@ For more information on how to do this, please consult [Laravel's Documentation]
67
67
68
68
Alternatively, you can set this yourself using your own routes, just set the session value `'language'` to the new locale and redirect.
69
69
70
-
##Configuration
70
+
##Configuration
71
71
The package ships with quite a few configuration options:
72
72
```
73
73
return [
@@ -84,33 +84,33 @@ You are free to use any method to configure the package. Remember to use the pub
84
84
To set options, you can use any of the following methods:
85
85
1. Changing the config file `config/languageswitcher.php`, editing the values of the provided keys (recommended)
86
86
2. Using laravel's runtime configuration helper - `Config::set()` | `config()->set()`, with the specification that you use the 'languageswitcher' preffix for the keys (eg. `languageswitcher.switchPath` for changing the switch path).
87
-
#####Changing the switcher's route (default: lang/{language_flag})
87
+
#####Changing the switcher's route (default: lang/{language_flag})
88
88
* Config key: `languageswitcher.switchPath`
89
89
* Default Value: `lang`
90
90
91
91
This config setting dynamically sets the route created in the package for switching the language.
92
-
#####Changing store method - session | cookie (default: session)
92
+
#####Changing store method - session | cookie (default: session)
93
93
* Config key: `languageswitcher.store`
94
94
* Default value: `session`
95
95
* Accepted values: `session | cookie`
96
96
97
97
This config setting changes the storage method of the language flag.
98
98
Default is session, but cookies with forever as expiry date can be used.
99
99
Initially this was set up as a cookie with a configurable expiry date, but for obvious reasons it was set up to never expire.
100
-
#####Changing the key where the language flag is stored (default: lang)
100
+
#####Changing the key where the language flag is stored (default: lang)
101
101
* Config key: `languageswitcher.key`
102
102
* Default value: `language`
103
103
104
104
This config setting decides what key to be used when storing the language flag, to the session or cookie.
105
-
#####Changing the redirect type (default: route redirect to '/')
105
+
#####Changing the redirect type (default: route redirect to '/')
106
106
* Config keys: `languageswitcher.redirect` and `languageswitcher.redirect_route`
107
107
* Default value for `languageswitcher.redirect`: `route`
108
108
* Accepted values: `route | back`
109
109
* Default value for `languageswitcher.redirect_route`: `/`
110
110
111
111
When the `languageswitcher.redirect` config value is set to route, the user is redirected to the specified `languageswitcher.redirect_route` after the new language flag is set.
112
112
Setting the `languageswitcher.redirect` to `back` will redirect the user back to the previous page after the new language flag is set.
113
-
##Examples
113
+
##Examples
114
114
My preffered way to usage is this: I include the library, create my UI for switching the language, and start translating!
115
115
116
116
Example HTML:
@@ -122,7 +122,7 @@ Example HTML:
122
122
</ul>
123
123
```
124
124
If you want to evidentiate the current selection language, you can use App::getLocale() or LanguageSwitcher::getCurrentLanguage().
125
-
##Bugs/Issues/Improvements
125
+
##Bugs/Issues/Improvements
126
126
Feel free to use github for issues and suggesting improvements.
127
-
##Additional Information
128
-
You can find more information on regarding this package on my website, [www.ied3vil.com](http://www.ied3vil.com).
127
+
##Additional Information
128
+
You can find more information on regarding this package on my website, [www.ied3vil.com](http://www.ied3vil.com).
0 commit comments