diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-10-21 13:19:59 +0300 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-10-21 13:19:59 +0300 |
commit | 9ec2f19e26b9d0736bd1c341bb7069b51e284296 (patch) | |
tree | 539957a8c0f6eed8312328d1d7653c7116de74f3 /l10n.php | |
parent | 116719decccd6e2f17568ac2a365d0468d3a7273 (diff) |
Use hash as key
Diffstat (limited to 'l10n.php')
-rw-r--r-- | l10n.php | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -57,23 +57,25 @@ class L10N { file_put_contents($baseTranslationFile, json_encode([])); } + $stringHash = md5($string); + // If the string doesn't yet exist to translate: Create it if($this->baseTranslations === null) { $this->baseTranslations= json_decode(file_get_contents($baseTranslationFile), true); $this->countBefore = count($this->baseTranslations); - if (!isset($this->baseTranslations[$string])) { - $this->baseTranslations[$string] = $string; + if (!isset($this->baseTranslations[$stringHash])) { + $this->baseTranslations[$stringHash] = $string; $this->changed = true; } } - $this->requestedStrings[$string] = $string; + $this->requestedStrings[$stringHash] = $string; // Read the translated string $translationFile = __DIR__ . '/l10n/'.$this->getCurrentLanguage().'/' . $this->pageName . '.json'; if(file_exists($translationFile)) { $translations = json_decode(file_get_contents($translationFile), true); - if(isset($translations[$string])) { - return $translations[$string]; + if(isset($translations[$stringHash])) { + return $translations[$stringHash]; } } |