added missing/removed translation IDs found using improved unit test (#201)

This commit is contained in:
El RIDO
2017-03-25 13:19:11 +01:00
parent e80c726f92
commit 44327bed58
10 changed files with 27 additions and 9 deletions

View File

@@ -146,19 +146,31 @@ class I18nTest extends PHPUnit_Framework_TestCase
public function testMessageIdsExistInAllLanguages()
{
$messageIds = array();
$languages = array();
$dir = dir(PATH . 'i18n');
$languages = array();
$dir = dir(PATH . 'i18n');
while (false !== ($file = $dir->read())) {
if (strlen($file) === 7) {
$language = substr($file, 0, 2);
$translations = json_decode(file_get_contents(PATH . 'i18n' . DIRECTORY_SEPARATOR . $file), true);
$messageIds = array_unique($messageIds + array_keys($translations));
$languages[$language] = $translations;
$language = substr($file, 0, 2);
$languageMessageIds = array_keys(
json_decode(
file_get_contents(PATH . 'i18n' . DIRECTORY_SEPARATOR . $file),
true
)
);
$messageIds = array_unique(array_merge($messageIds, $languageMessageIds));
$languages[$language] = $languageMessageIds;
}
}
foreach ($messageIds as $messageId) {
foreach (array_keys($languages) as $language) {
$this->assertArrayHasKey($messageId, $languages[$language], "message ID '$messageId' exists in translation file $language.json");
// most languages don't translate the data size units, ignore those
if ($messageId !== 'B' && strlen($messageId) !== 3 && strpos($messageId, 'B', 2) !== 2) {
$this->assertContains(
$messageId,
$languages[$language],
"message ID '$messageId' exists in translation file $language.json"
);
}
}
}
}