summaryrefslogtreecommitdiffstats
path: root/lib/private/L10N
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-10 10:19:49 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-10 10:42:08 +0200
commitdf143cb72a9681d977a7fa85553a95ce1ee2314f (patch)
treed40f7d7bc787393a049e92ecb56ec98339502010 /lib/private/L10N
parente9c644412c65aab4799c5dc24dcfa294cc7f5a23 (diff)
downloadnextcloud-server-df143cb72a9681d977a7fa85553a95ce1ee2314f.tar.gz
nextcloud-server-df143cb72a9681d977a7fa85553a95ce1ee2314f.zip
Use user locale as default in the template
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib/private/L10N')
-rw-r--r--lib/private/L10N/Factory.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index cc2de174509..1a7fff43229 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -245,6 +245,26 @@ class Factory implements IFactory {
}
/**
+ * find the matching lang from the locale
+ *
+ * @param string $app
+ * @param string $locale
+ * @return null|string
+ */
+ public function findLanguageFromLocale($app = 'core', $locale = null) {
+ if ($this->languageExists($app, $locale)) {
+ return $locale;
+ }
+
+ // Try to split e.g: fr_FR => fr
+ $locale = explode('_', $locale)[0];
+ if ($this->languageExists($app, $locale)) {
+ return $locale;
+ }
+
+ }
+
+ /**
* Find all available languages for an app
*
* @param string|null $app App id or null for core