Register theme backend localization files (#4960)

Closes #4308.
This commit is contained in:
Siarhei Karavai 2020-11-08 00:13:25 +03:00 committed by GitHub
parent 59d183b3b0
commit 061d35e5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -1,11 +1,14 @@
<?php namespace Cms; <?php namespace Cms;
use App; use App;
use Lang;
use File;
use Event; use Event;
use Backend; use Backend;
use BackendMenu; use BackendMenu;
use BackendAuth; use BackendAuth;
use Backend\Models\UserRole; use Backend\Models\UserRole;
use Cms\Classes\Theme as CmsTheme;
use Backend\Classes\WidgetManager; use Backend\Classes\WidgetManager;
use October\Rain\Support\ModuleServiceProvider; use October\Rain\Support\ModuleServiceProvider;
use System\Classes\SettingsManager; use System\Classes\SettingsManager;
@ -40,6 +43,7 @@ class ServiceProvider extends ModuleServiceProvider
$this->registerBackendPermissions(); $this->registerBackendPermissions();
$this->registerBackendWidgets(); $this->registerBackendWidgets();
$this->registerBackendSettings(); $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. * Registers events for menu items.
*/ */

View File

@ -103,8 +103,11 @@ class ThemeOptions extends Controller
/** /**
* Default to the active theme if user doesn't have access to manage all themes * 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 * Only the active theme can be managed without this permission