-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tracks loaded language files individually
Signed-off-by: Jon Stovell <[email protected]>
- Loading branch information
1 parent
67301ee
commit 45c2eb0
Showing
1 changed file
with
8 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,11 +233,6 @@ public static function load(string $template_name, string $lang = '', bool $fata | |
$lang = User::$me->language ?? self::$default; | ||
} | ||
|
||
// Don't repeat this unnecessarily. | ||
if (!$force_reload && isset(self::$already_loaded[$template_name]) && self::$already_loaded[$template_name] == $lang) { | ||
return $lang; | ||
} | ||
|
||
if (empty(self::$dirs)) { | ||
self::addDirs(); | ||
} | ||
|
@@ -249,6 +244,11 @@ public static function load(string $template_name, string $lang = '', bool $fata | |
$template = 'General'; | ||
} | ||
|
||
// Don't repeat this unnecessarily. | ||
if (!$force_reload && isset(self::$already_loaded[$template]) && self::$already_loaded[$template] == $lang) { | ||
continue; | ||
} | ||
|
||
$attempts = []; | ||
|
||
foreach (self::$dirs as $dir) { | ||
|
@@ -271,14 +271,6 @@ public static function load(string $template_name, string $lang = '', bool $fata | |
|
||
foreach ($attempts as $k => $file) { | ||
if (file_exists($file[0] . '/' . $file[2] . '/' . $file[1] . '.php')) { | ||
/** | ||
* @var string $forum_copyright | ||
* @var array $txt | ||
* @var array $txtBirthdayEmails | ||
* @var array $tztxt | ||
* @var array $editortxt | ||
* @var array $helptxt | ||
*/ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Sesquipedalian
Author
Member
|
||
// Include it! | ||
// {DIR} / {locale} / {file} .php | ||
require $file[0] . '/' . $file[2] . '/' . $file[1] . '.php'; | ||
|
@@ -366,10 +358,10 @@ public static function load(string $template_name, string $lang = '', bool $fata | |
} | ||
$birthdayEmails = []; | ||
} | ||
} | ||
|
||
// Remember what we have loaded, and in which language. | ||
self::$already_loaded[$template_name] = $lang; | ||
// Remember what we have loaded, and in which language. | ||
self::$already_loaded[$template] = $lang; | ||
} | ||
|
||
// Return the language actually loaded. | ||
return $lang; | ||
|
I will put this back later. This fixed my IDE from complaining because we used those variables inside the code without defining them. Because they come from the file loading and then handled with
${$var}
they are loaded, but it can't see them and assumes they are undefined.