Skip to content
Open
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions lib/private/Template/JSResourceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public function doFind(string $resource): void {
if (str_contains($resource, '/l10n/')) {
// For language files we try to load them all, so themes can overwrite
// single l10n strings without having to translate all of them.
$found = $this->appendScriptIfExist($this->serverroot, 'core/' . $resource)
|| $this->appendScriptIfExist($this->serverroot, $theme_dir . 'core/' . $resource)
|| $this->appendScriptIfExist($this->serverroot, $resource)
|| $this->appendScriptIfExist($this->serverroot, $theme_dir . $resource)
|| $this->appendScriptIfExist($appRoot, $resource, $appWebRoot)
|| $this->appendScriptIfExist($this->serverroot, $theme_dir . 'apps/' . $resource);
$found = $this->appendScriptIfExist($this->serverroot, 'core/' . $resource);
$found = $this->appendScriptIfExist($this->serverroot, $theme_dir . 'core/' . $resource) || $found;
$found = $this->appendScriptIfExist($this->serverroot, $resource) || $found;
$found = $this->appendScriptIfExist($this->serverroot, $theme_dir . $resource) || $found;
$found = $this->appendScriptIfExist($appRoot, $resource, $appWebRoot) || $found;
$found = $this->appendScriptIfExist($this->serverroot, $theme_dir . 'apps/' . $resource) || $found;

if ($found) {
return;
Expand Down
27 changes: 27 additions & 0 deletions tests/lib/Template/JSResourceLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,31 @@ public function testFindModuleJSWithFallback(): void {

$this->rrmdir($new_apps_path);
}

public function testFindTranslationWithThemeOverride(): void {
$this->config->method('getSystemValueString')
->willReturnCallback(fn (string $key, string $default = ''): string => $key === 'theme' ? 'testtheme' : $default);
$this->appManager->method('getAppPath')
->willThrowException(new AppPathNotFoundException());

$themeDir = \OC::$SERVERROOT . '/themes/testtheme';
$themeL10n = $themeDir . '/core/l10n';
mkdir($themeL10n, 0777, true);
touch(\OC::$SERVERROOT . '/core/l10n/zz.js');
touch($themeL10n . '/zz.js');

try {
$locator = $this->jsResourceLocator();
$locator->find(['core/l10n/zz']);
$files = array_column($locator->getResources(), 2);
$this->assertEquals(['core/l10n/zz.js', 'core/l10n/zz.js'], $files);
$this->assertEquals(
[\OC::$SERVERROOT, \OC::$SERVERROOT . '/themes/testtheme'],
array_column($locator->getResources(), 0)
);
} finally {
unlink(\OC::$SERVERROOT . '/core/l10n/zz.js');
$this->rrmdir($themeDir);
}
}
}