summaryrefslogtreecommitdiffstats
path: root/lib/private/L10N
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-22 17:38:58 +0200
committerJoas Schilling <coding@schilljs.com>2020-07-01 10:20:07 +0200
commitb997edad105d38703351b89998444ab0828f7d05 (patch)
treeb619c2a89e0d496e8a59e7045eb7250532e8c9ed /lib/private/L10N
parentebedbf157968e40230a102c8f6f17c22990b0aae (diff)
downloadnextcloud-server-b997edad105d38703351b89998444ab0828f7d05.tar.gz
nextcloud-server-b997edad105d38703351b89998444ab0828f7d05.zip
Add a dedicated method to get the language for another user
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/L10N')
-rw-r--r--lib/private/L10N/Factory.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index 9d9e6ac9b26..3ab62de4b97 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -359,6 +359,29 @@ class Factory implements IFactory {
}
/**
+ * Return the language to use when sending something to a user
+ *
+ * @param IUser|null $user
+ * @return string
+ * @since 20.0.0
+ */
+ public function getUserLanguage(IUser $user = null): string {
+ $language = $this->config->getSystemValue('force_language', false);
+ if ($language !== false) {
+ return $language;
+ }
+
+ if ($user instanceof IUser) {
+ $language = $this->config->getUserValue($user->getUID(), 'core', 'lang', null);
+ if ($language !== null) {
+ return $language;
+ }
+ }
+
+ return $this->config->getSystemValue('default_language', 'en');
+ }
+
+ /**
* @param string $locale
* @return bool
*/