From 061d35e5fd39839990986ecfbdec755bc711301c Mon Sep 17 00:00:00 2001 From: Siarhei Karavai Date: Sun, 8 Nov 2020 00:13:25 +0300 Subject: [PATCH] Register theme backend localization files (#4960) Closes #4308. --- modules/cms/ServiceProvider.php | 18 ++++++++++++++++++ modules/cms/controllers/ThemeOptions.php | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/cms/ServiceProvider.php b/modules/cms/ServiceProvider.php index 40e170787..fd84ea3b9 100644 --- a/modules/cms/ServiceProvider.php +++ b/modules/cms/ServiceProvider.php @@ -1,11 +1,14 @@ registerBackendPermissions(); $this->registerBackendWidgets(); $this->registerBackendSettings(); + $this->registerBackendLocalization(); } } @@ -284,6 +288,20 @@ class ServiceProvider extends ModuleServiceProvider }); } + /** + * Registers localization from an active theme for backend items. + */ + protected function registerBackendLocalization() + { + $theme = CmsTheme::getActiveTheme(); + + $langPath = $theme->getPath() . '/lang'; + + if (File::isDirectory($langPath)) { + Lang::addNamespace("theme.{$theme->getId()}", $langPath); + } + } + /** * Registers events for menu items. */ diff --git a/modules/cms/controllers/ThemeOptions.php b/modules/cms/controllers/ThemeOptions.php index b20fd5eae..78068c83a 100644 --- a/modules/cms/controllers/ThemeOptions.php +++ b/modules/cms/controllers/ThemeOptions.php @@ -103,8 +103,11 @@ class ThemeOptions extends Controller /** * Default to the active theme if user doesn't have access to manage all themes + * + * @param string $dirName + * @return string */ - protected function getDirName($dirName = null) + protected function getDirName(string $dirName = null) { /* * Only the active theme can be managed without this permission