mirror of
https://github.com/nextcloud/server.git
synced 2026-05-27 03:43:40 -04:00
Merge pull request #59643 from nextcloud/backport/59518/stable33
[stable33] fix(Util): `getScripts` also need to reorder core translations
This commit is contained in:
commit
522e03a605
1 changed files with 19 additions and 8 deletions
|
|
@ -188,16 +188,27 @@ class Util {
|
|||
// Flatten array and remove duplicates
|
||||
$sortedScripts = array_merge([self::$scriptsInit], $sortedScripts);
|
||||
$sortedScripts = array_merge(...array_values($sortedScripts));
|
||||
$sortedScripts = array_unique($sortedScripts);
|
||||
|
||||
// Override core-common and core-main order
|
||||
if (in_array('core/js/main', $sortedScripts)) {
|
||||
array_unshift($sortedScripts, 'core/js/main');
|
||||
}
|
||||
if (in_array('core/js/common', $sortedScripts)) {
|
||||
array_unshift($sortedScripts, 'core/js/common');
|
||||
}
|
||||
usort($sortedScripts, fn (string $a, string $b) => self::scriptOrderValue($b) <=> self::scriptOrderValue($a));
|
||||
return $sortedScripts;
|
||||
}
|
||||
|
||||
return array_unique($sortedScripts);
|
||||
/**
|
||||
* Gets a numeric value based on the script name.
|
||||
* This is used to ensure that the global state is initialized before all other scripts.
|
||||
*
|
||||
* @param string $name - The script name
|
||||
* @since 33.0.3
|
||||
*/
|
||||
private static function scriptOrderValue(string $name): int {
|
||||
return match($name) {
|
||||
'core/js/common' => 3,
|
||||
'core/js/main' => 2,
|
||||
default => str_starts_with($name, 'core/l10n/')
|
||||
? 1 // core translations have to be loaded directly after core-main
|
||||
: 0, // other scripts should preserve their current order
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue