Skip to content

Commit

Permalink
ensure all languages have Intl translations, otherwise do not use them
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jun 22, 2015
1 parent 0834daf commit 310be98
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plugins/LanguagesManager/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public function getAvailableLanguagesInfo()
}
return $res;
};

// Skip languages not having Intl translations
if (empty($translations['Intl'])) {
continue;
}

$translationStringsDone = $intersect($englishTranslation, $translations);
$percentageComplete = count($translationStringsDone, COUNT_RECURSIVE) / count($englishTranslation, COUNT_RECURSIVE);
$percentageComplete = round(100 * $percentageComplete, 0);
Expand Down Expand Up @@ -282,13 +288,19 @@ private function loadAvailableLanguages()
if ($cache->contains($cacheId)) {
$languagesInfo = $cache->fetch($cacheId);
} else {
$filenames = $this->getAvailableLanguages();
$languages = $this->getAvailableLanguages();
$languagesInfo = array();
foreach ($filenames as $filename) {
$data = file_get_contents(PIWIK_INCLUDE_PATH . "/plugins/Intl/lang/$filename.json");
foreach ($languages as $languageCode) {
$data = @file_get_contents(PIWIK_INCLUDE_PATH . "/plugins/Intl/lang/$languageCode.json");

// Skip languages not having Intl translations
if (empty($data)) {
continue;
}

$translations = json_decode($data, true);
$languagesInfo[] = array(
'code' => $filename,
'code' => $languageCode,
'name' => $translations['Intl']['OriginalLanguageName'],
'english_name' => $translations['Intl']['EnglishLanguageName']
);
Expand Down

0 comments on commit 310be98

Please sign in to comment.