Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pmoust/6403884 to your computer and use it in GitHub Desktop.
Save pmoust/6403884 to your computer and use it in GitHub Desktop.
<?php
/**
* Returns the active language.
* @return string the locale.
*/
public function resolveActiveLanguage()
{
$user = user();
$matches = array();
if ($user->hasState('__locale')) {
return $user->getState('__locale');
} else if (preg_match(
'/^\/([a-z]{2}(?:_[a-z]{2})?)\//i',
substr($this->request->url, strlen($this->baseUrl)),
$matches
) !== false && isset($matches[1], $this->languages[$matches[1]])
) {
return $matches[1];
} else {
return $this->defaultLanguage;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment