mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-16 12:02:54 +02:00
refactor(i18n): drop the global $language, provide it from the controller layer
$language was a bootstrap-set global (literally Translator::class) that reached views through four separate bridges: the BaseAdminController extract whitelist, admin/functions.php, and the renderUnifiedLayoutHeader/ Footer $GLOBALS pulls. Removing the global and sourcing $language where each page is actually assembled makes the dependency explicit. - BaseAdminController::render() sets $data['language'] = Translator::class, covering every admin/reseller page it renders. - renderUnifiedLayoutHeader()/Footer() and admin/functions.php set a local $language for the legacy header/footer and the standalone login/setup/post pages; the reseller login/post controllers set their own local. - Non-view code (TableController, SearchAjaxController, Admin/Reseller ScopeBootstrap) calls Translator::get()/setLanguage() directly instead of through `global $language`. - bootstrap.php no longer creates the $language global; initTranslator() and $allowedLangs call Translator:: directly. Views keep their `$language::get(...)` syntax unchanged; $language is now a local in every scope that renders one.
This commit is contained in:
+3
-5
@@ -526,8 +526,7 @@ class XC_Bootstrap {
|
||||
* Initialize Translator (i18n).
|
||||
*/
|
||||
private static function initTranslator(): void {
|
||||
$language = Translator::class;
|
||||
$language::init(MAIN_HOME . 'resources/langs/');
|
||||
Translator::init(MAIN_HOME . 'resources/langs/');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -665,7 +664,7 @@ class XC_Bootstrap {
|
||||
private static function initAdminGlobals(): void {
|
||||
global $rDetect, $rMobile, $rTimeout, $rSQLTimeout, $rProtocol,
|
||||
$allServers, $rServers, $rSettings, $rProxyServers,
|
||||
$rPermissions, $language, $allowedLangs;
|
||||
$rPermissions, $allowedLangs;
|
||||
|
||||
if (!defined('SERVER_ID')) {
|
||||
define('SERVER_ID', intval(ConfigReader::get('server_id')));
|
||||
@@ -690,8 +689,7 @@ class XC_Bootstrap {
|
||||
}
|
||||
$rProxyServers = ServerRepository::getProxySimple($rPermissions);
|
||||
|
||||
$language = Translator::class;
|
||||
$allowedLangs = $language::available();
|
||||
$allowedLangs = Translator::available();
|
||||
|
||||
// Sort servers by order
|
||||
if (is_array($rServers)) {
|
||||
|
||||
Reference in New Issue
Block a user