summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/l10n/factory.php31
-rw-r--r--tests/data/themes/abc/apps/files/l10n/zz.json0
-rw-r--r--tests/lib/l10n/factorytest.php25
3 files changed, 49 insertions, 7 deletions
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php
index 1440e9510c5..198c5605413 100644
--- a/lib/private/l10n/factory.php
+++ b/lib/private/l10n/factory.php
@@ -186,6 +186,23 @@ class Factory implements IFactory {
}
}
+ // merge with translations from theme
+ $theme = $this->config->getSystemValue('theme');
+ if (!empty($theme)) {
+ $themeDir = \OC::$SERVERROOT . '/themes/' . $theme . substr($dir, strlen(\OC::$SERVERROOT));
+
+ if (is_dir($themeDir)) {
+ $files = scandir($themeDir);
+ if ($files !== false) {
+ foreach ($files as $file) {
+ if (substr($file, -5) === '.json' && substr($file, 0, 4) !== 'l10n') {
+ $available[] = substr($file, 0, -5);
+ }
+ }
+ }
+ }
+ }
+
$this->availableLanguages[$key] = $available;
return $available;
}
@@ -271,14 +288,14 @@ class Factory implements IFactory {
&& file_exists($transFile)) {
// load the translations file
$languageFiles[] = $transFile;
+ }
- // merge with translations from theme
- $theme = $this->config->getSystemValue('theme');
- if (!empty($theme)) {
- $transFile = \OC::$SERVERROOT . '/themes/' . $theme . substr($transFile, strlen(\OC::$SERVERROOT));
- if (file_exists($transFile)) {
- $languageFiles[] = $transFile;
- }
+ // merge with translations from theme
+ $theme = $this->config->getSystemValue('theme');
+ if (!empty($theme)) {
+ $transFile = \OC::$SERVERROOT . '/themes/' . $theme . substr($transFile, strlen(\OC::$SERVERROOT));
+ if (file_exists($transFile)) {
+ $languageFiles[] = $transFile;
}
}
diff --git a/tests/data/themes/abc/apps/files/l10n/zz.json b/tests/data/themes/abc/apps/files/l10n/zz.json
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/tests/data/themes/abc/apps/files/l10n/zz.json
diff --git a/tests/lib/l10n/factorytest.php b/tests/lib/l10n/factorytest.php
index 9f5954d0ee1..228ec482fc9 100644
--- a/tests/lib/l10n/factorytest.php
+++ b/tests/lib/l10n/factorytest.php
@@ -287,6 +287,31 @@ class FactoryTest extends TestCase {
];
}
+ public function testFindAvailableLanguagesWithThemes() {
+ $serverRoot = \OC::$SERVERROOT;
+ \OC::$SERVERROOT = \OC::$SERVERROOT . '/tests/data';
+ $app = 'files';
+
+ $factory = $this->getFactory(['findL10nDir']);
+ $factory->expects($this->once())
+ ->method('findL10nDir')
+ ->with($app)
+ ->willReturn(\OC::$SERVERROOT . '/apps/files/l10n/');
+ $this->config
+ ->expects($this->once())
+ ->method('getSystemValue')
+ ->with('theme')
+ ->willReturn('abc');
+
+ try {
+ $this->assertEquals(['en', 'zz'], $factory->findAvailableLanguages($app), '', 0.0, 10, true);
+ } catch (\Exception $e) {
+ \OC::$SERVERROOT = $serverRoot;
+ throw $e;
+ }
+ \OC::$SERVERROOT = $serverRoot;
+ }
+
/**
* @dataProvider dataLanguageExists
*