Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsgiehl <stefan@piwik.org>2015-06-22 13:16:00 +0300
committersgiehl <stefan@piwik.org>2015-06-22 13:16:00 +0300
commit310be9832c07959c70020e5ac5e36a41b928f289 (patch)
tree523a1655f5c68a4d1a129fc0a54af16c106384d8 /plugins/LanguagesManager/API.php
parent0834dafa90f3b48ecf080b9773c118ceea73220e (diff)
ensure all languages have Intl translations, otherwise do not use them
Diffstat (limited to 'plugins/LanguagesManager/API.php')
-rw-r--r--plugins/LanguagesManager/API.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php
index bddfaff450..46afc357c2 100644
--- a/plugins/LanguagesManager/API.php
+++ b/plugins/LanguagesManager/API.php
@@ -128,6 +128,12 @@ class API extends \Piwik\Plugin\API
}
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);
@@ -282,13 +288,19 @@ class API extends \Piwik\Plugin\API
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']
);