protected function cmdDiff($args, $extra) { // TODO: Accepts a language code to compare it with another. (Default: English) $languageManager = Bootstrap::get('languagesManager'); $languages = $languageManager->getLanguageList(); if (count($languages) <= 1) { return []; } $languagesPhrases = []; foreach ($languages as $code => $name) { $languagesPhrases[] = ['code' => $code, 'name' => $name, 'phrases_keys' => get_locale_keys($code), 'diff' => []]; } // ============================================================================= // A language to compare to the rest of languages keys // ============================================================================= $mainLanguage = $languagesPhrases[0]; unset($languagesPhrases[0]); foreach ($languagesPhrases as $language) { $diff = ArrayUtils::missing($mainLanguage['phrases_keys'], $language['phrases_keys']); echo "--------------------" . PHP_EOL; echo $language['name'] . " has " . count($diff) . " missing/removed keys compared against " . $mainLanguage['name'] . PHP_EOL; foreach ($diff as $key) { echo "\t - " . $key . PHP_EOL; } echo "--------------------" . PHP_EOL . PHP_EOL; } }
public function testMissing() { $array1 = ['one', 'two', 'three', 'five']; $array2 = ['one', 'four', 'five']; $result = ArrayUtils::missing($array1, $array2); $this->assertTrue(in_array('four', $result)); }