class LocaleDetector

Locales are shorthand 2 letter strings for a language/region.

Methods

string
current()

Get the current locale. At first we try to use the cookie if one is set. If a cookie is not set then we attempt to deduce the locale in this order: url segment, http headers, and finally we fall back to the universal locale which is set in laravel's app.locale (defaults to en).

string
cookie()

Get the locale from a cookie

string
universal()

Get the universal locale set by developer and laravel

string
header()

Get locale from header accept string

string
segment()

We don't use this, but we could use it later if we wanted to. It would get the locale from the first segment of the url, e.g.

string
update(string $locale)

Updates the locale stored in this cookie

Details

at line 28
string current()

Get the current locale. At first we try to use the cookie if one is set. If a cookie is not set then we attempt to deduce the locale in this order: url segment, http headers, and finally we fall back to the universal locale which is set in laravel's app.locale (defaults to en).

Return Value

string

Get the locale from a cookie

Return Value

string

at line 58
string universal()

Get the universal locale set by developer and laravel

Return Value

string

at line 68
string header()

Get locale from header accept string

Return Value

string

at line 82
string segment()

We don't use this, but we could use it later if we wanted to. It would get the locale from the first segment of the url, e.g.

http://somesite.com/en/cool/page

Return Value

string

at line 93
string update(string $locale)

Updates the locale stored in this cookie

Parameters

string $locale

Return Value

string