printTranslationStatus example

$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
{
    $translations = [];

    $translationsDir = dirname($originalFilePath);
    $originalFileName = basename($originalFilePath);
    $translationFileNamePattern = str_replace('.en.', '.*.', $originalFileName);

    
Home | Imprint | This part of the site doesn't use cookies.