diff options
Diffstat (limited to 'lib/private/L10N')
-rw-r--r-- | lib/private/L10N/Factory.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index 8c8735836bb..79495f5ff88 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -32,6 +32,7 @@ namespace OC\L10N; use OCP\IConfig; use OCP\IRequest; +use OCP\IUser; use OCP\IUserSession; use OCP\L10N\IFactory; @@ -321,6 +322,37 @@ class Factory implements IFactory { return array_search($lang, $languages) !== false; } + public function iterateLanguage(bool $reset = false): string { + static $i = 0; + if($reset) { + $i = 0; + } + switch($i) { + /** @noinspection PhpMissingBreakStatementInspection */ + case 0: + $i++; + $forcedLang = $this->config->getSystemValue('force_language', false); + if(is_string($forcedLang)) { + return $forcedLang; + } + /** @noinspection PhpMissingBreakStatementInspection */ + case 1: + $i++; + $user = $this->userSession->getUser(); + if($user instanceof IUser) { + $userLang = $this->config->getUserValue($user->getUID(), 'core', 'lang', null); + if(is_string($userLang)) { + return $userLang; + } + } + case 2: + $i++; + return $this->config->getSystemValue('default_language', 'en'); + default: + return 'en'; + } + } + /** * @param string $locale * @return bool |