CodeExplorer extractLocaleFromFilePath example
function findTranslationFiles($originalFilePath,
$localeToAnalyze): array
{ $translations =
[];
$translationsDir =
dirname($originalFilePath);
$originalFileName =
basename($originalFilePath);
$translationFileNamePattern =
str_replace('.en.', '.*.',
$originalFileName);
$translationFiles =
glob($translationsDir.'/'.
$translationFileNamePattern, \GLOB_NOSORT
);
sort($translationFiles);
foreach ($translationFiles as $filePath) { $locale =
extractLocaleFromFilePath($filePath);
if (null !==
$localeToAnalyze &&
$locale !==
$localeToAnalyze) { continue;
} $translations[$locale] =
$filePath;
} return $translations;
}