From 1f99fe276cec1e723a9149a27c6c635930df3919 Mon Sep 17 00:00:00 2001 From: Francesco Lodolo Date: Fri, 5 May 2023 15:17:56 +0200 Subject: [PATCH] Always use en-US as reference for 'all projects' search (#1035) --- app/classes/Transvision/Utils.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/classes/Transvision/Utils.php b/app/classes/Transvision/Utils.php index d7850fb6..253cb35d 100644 --- a/app/classes/Transvision/Utils.php +++ b/app/classes/Transvision/Utils.php @@ -163,7 +163,19 @@ public static function getRepoStrings($locale, $repository, $flat = true) : [$repository]; foreach ($repositories as $repository) { - $file = TMX . "{$locale}/cache_{$locale}_{$repository}.php"; + # Ignore meta project (all_projects) + if (Project::isMetaRepository($repository)) { + continue; + } + /* + If the locale requested is en-US, we assume that the research + needs to look at the reference locale (which might be "en" + for some projects). + */ + $repo_locale = ($locale == 'en-US') + ? Project::getReferenceLocale($repository) + : $locale; + $file = TMX . "{$repo_locale}/cache_{$repo_locale}_{$repository}.php"; if (! is_file($file)) { continue; } @@ -183,7 +195,8 @@ public static function getRepoStrings($locale, $repository, $flat = true) } /** - * Return a flat array of entity items with structure (repo, entity, entity's text) + * Return a flat array of entity items with structure (repo, entity, + entity's text) * * @param string $tmx Array with strings organized per repo *