@@ -52,11 +52,6 @@ class Factory implements IFactory {
5252 */
5353 protected $ availableLanguages = [];
5454
55- /**
56- * @var array Structure: string => callable
57- */
58- protected $ pluralFunctions = [];
59-
6055 /** @var IConfig */
6156 protected $ config ;
6257
@@ -76,7 +71,7 @@ class Factory implements IFactory {
7671 * @param IConfig $config
7772 * @param IRequest $request
7873 * @param IThemeService $themeService
79- * @param IUserSession $userSession
74+ * @param IUserSession|null $userSession
8075 * @param string $serverRoot
8176 */
8277 public function __construct (
@@ -194,10 +189,9 @@ public function findAvailableLanguages($app = null) {
194189 $ available = \array_merge ($ available , $ this ->findAvailableLanguageFiles ($ dir ));
195190
196191 // merge with translations from themes
197- $ relativePath = \substr ($ dir , \strlen ($ this ->serverRoot ));
198192 $ themeDir = $ this ->getActiveThemeDirectory ();
199193 if ($ themeDir !== '' ) {
200- $ themeDir . = $ relativePath ;
194+ $ themeDir = $ this -> findL10nDirInTheme ( $ themeDir , $ app ) ;
201195 $ available = \array_merge ($ available , $ this ->findAvailableLanguageFiles ($ themeDir ));
202196 }
203197
@@ -290,10 +284,9 @@ public function getL10nFilesForApp($app, $lang) {
290284 }
291285
292286 // merge with translations from themes
293- $ relativePath = \substr ($ transFile , \strlen ($ this ->serverRoot ));
294287 $ themeDir = $ this ->getActiveThemeDirectory ();
295288 if ($ themeDir !== '' ) {
296- $ themeTransFile = $ themeDir . $ relativePath ;
289+ $ themeTransFile = $ this -> findL10nDirInTheme ( $ themeDir, $ app ) . " / $ lang .json " ;
297290 if (\file_exists ($ themeTransFile )) {
298291 $ languageFiles [] = $ themeTransFile ;
299292 }
@@ -305,10 +298,10 @@ public function getL10nFilesForApp($app, $lang) {
305298 /**
306299 * find the l10n directory
307300 *
308- * @param string $app App id or empty string for core
301+ * @param string|null $app App id or empty string for core
309302 * @return string directory
310303 */
311- protected function findL10nDir ($ app = null ) {
304+ protected function findL10nDir ($ app): string {
312305 if (\in_array ($ app , ['core ' , 'lib ' , 'settings ' ])) {
313306 if (\file_exists ($ this ->serverRoot . '/ ' . $ app . '/l10n/ ' )) {
314307 return $ this ->serverRoot . '/ ' . $ app . '/l10n/ ' ;
@@ -320,6 +313,20 @@ protected function findL10nDir($app = null) {
320313 return $ this ->serverRoot . '/core/l10n/ ' ;
321314 }
322315
316+ protected function findL10nDirInTheme (string $ themeDir , $ app ): string {
317+ if ($ app ) {
318+ if (\in_array ($ app , ['core ' , 'lib ' , 'settings ' ])) {
319+ $ p = $ themeDir . '/ ' . $ app . '/l10n/ ' ;
320+ } else {
321+ $ p = $ themeDir . '/apps/ ' . $ app . '/l10n/ ' ;
322+ }
323+ if (\file_exists ($ p )) {
324+ return $ p ;
325+ }
326+ }
327+ return $ themeDir . '/core/l10n/ ' ;
328+ }
329+
323330 /**
324331 * @param string $dir
325332 * @return array
0 commit comments