public function Request::getLanguages in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Request.php \Symfony\Component\HttpFoundation\Request::getLanguages()
Gets a list of languages acceptable by the client browser.
Return value
array Languages ordered in the user browser preferences
1 call to Request::getLanguages()
- Request::getPreferredLanguage in vendor/
symfony/ http-foundation/ Request.php - Returns the preferred language.
File
- vendor/
symfony/ http-foundation/ Request.php, line 1575
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
public function getLanguages() {
if (null !== $this->languages) {
return $this->languages;
}
$languages = AcceptHeader::fromString($this->headers
->get('Accept-Language'))
->all();
$this->languages = array();
foreach ($languages as $lang => $acceptHeaderItem) {
if (false !== strpos($lang, '-')) {
$codes = explode('-', $lang);
if ('i' === $codes[0]) {
// Language not listed in ISO 639 that are not variants
// of any listed language, which can be registered with the
// i-prefix, such as i-cherokee
if (count($codes) > 1) {
$lang = $codes[1];
}
}
else {
for ($i = 0, $max = count($codes); $i < $max; ++$i) {
if ($i === 0) {
$lang = strtolower($codes[0]);
}
else {
$lang .= '_' . strtoupper($codes[$i]);
}
}
}
}
$this->languages[] = $lang;
}
return $this->languages;
}