diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-10 13:02:56 +0300 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-10 13:02:56 +0300 |
commit | 1b97eccca1e8f21fa832227036c6e110c4808688 (patch) | |
tree | e28ebf9df0d6a89dddc5ce2d445a9c096538926c /l10n.php | |
parent | 5bc4b7fe213cbae004f7ffcfea2b26683399ab5e (diff) |
Use translations only when 100%
Diffstat (limited to 'l10n.php')
-rw-r--r-- | l10n.php | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -70,12 +70,22 @@ class L10N { } $this->requestedStrings[$stringHash] = $string; - // Read the translated string + // Read the translated string if 100% translated $translationFile = __DIR__ . '/l10n/'.$this->getCurrentLanguage().'/' . $this->pageName . '.json'; if(file_exists($translationFile)) { - $translations = json_decode(file_get_contents($translationFile), true); - if(isset($translations[$stringHash])) { - return $translations[$stringHash]; + $originalFile = json_decode(file_get_contents(__DIR__ . '/l10n/base/' . $this->pageName . '.json'), true); + $translationFile = json_decode(file_get_contents($translationFile), true); + + if(!is_array($translationFile) || !is_array($originalFile)) { + return $string; + } + + if (array_keys($translationFile) !== array_keys($originalFile)) { + return $string; + } + + if(isset($translationFile[$stringHash])) { + return $translationFile[$stringHash]; } } |