Forked from crisu83/Application::resolveActiveLanguage.php
Created
September 1, 2013 11:31
-
-
Save pmoust/6403884 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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