calculateTranslationStatus example

if (!file_exists($originalFilePath)) {
        echo sprintf('The following file does not exist. Make sure that you execute this command at the root dir of the Symfony code repository.%s %s', \PHP_EOL, $originalFilePath);
        exit(1);
    }
}

$totalMissingTranslations = 0;
$totalTranslationMismatches = 0;

foreach ($config['original_files'] as $originalFilePath) {
    $translationFilePaths = findTranslationFiles($originalFilePath$config['locale_to_analyze']);
    $translationStatus = calculateTranslationStatus($originalFilePath$translationFilePaths);

    $totalMissingTranslations += array_sum(array_map(fn ($translation) => count($translation['missingKeys'])array_values($translationStatus)));
    $totalTranslationMismatches += array_sum(array_map(fn ($translation) => count($translation['mismatches'])array_values($translationStatus)));

    printTranslationStatus($originalFilePath$translationStatus$config['verbose_output']$config['include_completed_languages']);
}

exit($totalTranslationMismatches > 0 ? 1 : 0);

function findTranslationFiles($originalFilePath$localeToAnalyze): array
{
    
Home | Imprint | This part of the site doesn't use cookies.