Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public static function addInitScript(string $application, string $file): void {
$path = "js/$file";
}

// We need to handle the translation BEFORE the init script
// is loaded, as the init script might use translations
if ($application !== 'core' && !str_contains($file, 'l10n')) {
self::addTranslations($application, null, true);
}

self::$scriptsInit[] = $path;
}

Expand Down Expand Up @@ -233,9 +239,10 @@ public static function getScripts(): array {
* Add a translation JS file
* @param string $application application id
* @param string $languageCode language code, defaults to the current locale
* @param bool $init whether the translations should be loaded early or not
* @since 8.0.0
*/
public static function addTranslations($application, $languageCode = null) {
public static function addTranslations($application, $languageCode = null, $init = false) {
if (is_null($languageCode)) {
$languageCode = \OC::$server->getL10NFactory()->findLanguage($application);
}
Expand All @@ -244,7 +251,12 @@ public static function addTranslations($application, $languageCode = null) {
} else {
$path = "l10n/$languageCode";
}
self::$scripts[$application][] = $path;

if ($init) {
self::$scriptsInit[] = $path;
} else {
self::$scripts[$application][] = $path;
}
}

/**
Expand Down