From 70fea997afd3c8cb1c8bcf01e7d7ba58a94764bf Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 25 Oct 2019 13:29:51 +0200 Subject: [PATCH 1/2] Don't pass in the locale as the language This messes with the translation of the date names etc. Signed-off-by: Roeland Jago Douma --- lib/private/TemplateLayout.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index f23ec97119f..c833b56cebd 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -140,7 +140,6 @@ class TemplateLayout extends \OC_Template { // Send the language and the locale to our layouts $lang = \OC::$server->getL10NFactory()->findLanguage(); $locale = \OC::$server->getL10NFactory()->findLocale($lang); - $localeLang = \OC::$server->getL10NFactory()->findLanguageFromLocale('lib', $locale); $lang = str_replace('_', '-', $lang); $this->assign('language', $lang); @@ -162,7 +161,7 @@ class TemplateLayout extends \OC_Template { if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { $jsConfigHelper = new JSConfigHelper( - \OC::$server->getL10N('lib', $localeLang ?: $lang), + \OC::$server->getL10N('lib'), \OC::$server->query(Defaults::class), \OC::$server->getAppManager(), \OC::$server->getSession(), From 4dc91420cfa172f512912da7d7f819d51b63b257 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 25 Oct 2019 13:31:19 +0200 Subject: [PATCH 2/2] Cleanup theming mess * Do not do translations in the constructor. This gets called to early so there is no user yet. Which means we can't obtain the locale. Which means we store the wrong translation instance. * Same for the theming app magic. Just use the parent call when needed. Signed-off-by: Roeland Jago Douma --- apps/theming/lib/ThemingDefaults.php | 5 +---- lib/private/legacy/defaults.php | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 2305f570888..884be66f7d4 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -70,8 +70,6 @@ class ThemingDefaults extends \OC_Defaults { /** @var string */ private $url; /** @var string */ - private $slogan; - /** @var string */ private $color; /** @var string */ @@ -115,7 +113,6 @@ class ThemingDefaults extends \OC_Defaults { $this->title = parent::getTitle(); $this->entity = parent::getEntity(); $this->url = parent::getBaseUrl(); - $this->slogan = parent::getSlogan(); $this->color = parent::getColorPrimary(); $this->iTunesAppId = parent::getiTunesAppId(); $this->iOSClientUrl = parent::getiOSClientUrl(); @@ -143,7 +140,7 @@ class ThemingDefaults extends \OC_Defaults { } public function getSlogan() { - return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); + return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', parent::getSlogan())); } public function getImprintUrl() { diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php index d313366abe7..8633113ba5a 100644 --- a/lib/private/legacy/defaults.php +++ b/lib/private/legacy/defaults.php @@ -52,7 +52,6 @@ class OC_Defaults { private $defaultTextColorPrimary; public function __construct() { - $l10n = \OC::$server->getL10N('lib'); $config = \OC::$server->getConfig(); $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ @@ -65,7 +64,6 @@ class OC_Defaults { $this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client'); $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; $this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links - $this->defaultSlogan = $l10n->t('a safe home for all your data'); $this->defaultColorPrimary = '#0082c9'; $this->defaultTextColorPrimary = '#ffffff'; @@ -219,6 +217,10 @@ class OC_Defaults { if ($this->themeExist('getSlogan')) { return $this->theme->getSlogan(); } else { + if ($this->defaultSlogan === null) { + $l10n = \OC::$server->getL10N('lib'); + $this->defaultSlogan = $l10n->t('a safe home for all your data'); + } return $this->defaultSlogan; } }