diff --git a/GettextTranslator/Gettext.php b/GettextTranslator/Gettext.php index ee98f02..255a828 100644 --- a/GettextTranslator/Gettext.php +++ b/GettextTranslator/Gettext.php @@ -315,8 +315,12 @@ public function translate($message, $form = 1) if (!empty($message) && isset($this->dictionary[$message])) { - $tmp = preg_replace('/([a-z]+)/', '$$1', "n=$form;" . $this->metadata[$files[0]]['Plural-Forms']); - eval($tmp); + $pluralForms = $this->metadataList['Plural-Forms']; + if (isset($this->metadata[$files[0]]['Plural-Forms'])) { + $pluralForms = $this->metadata[$files[0]]['Plural-Forms']; + } + $tmp = preg_replace('/([a-z]+)/', '$$1', "n=$form;" . $pluralForms); + eval($tmp); $message = $this->dictionary[$message]['translation']; if (!empty($message)) @@ -379,13 +383,13 @@ public function getVariantsCount() { $this->loadDictonary(); $files = array_keys($this->files); - $plural_forms = $this->metadata_list['Plural-Forms']; + $pluralForms = $this->metadataList['Plural-Forms']; if (isset($this->metadata[$files[0]]['Plural-Forms'])) { - $plural_forms = $this->metadata[$files[0]]['Plural-Forms']; + $pluralForms = $this->metadata[$files[0]]['Plural-Forms']; } - return (int)substr($plural_forms, 9, 1); + return (int)substr($pluralForms, 9, 1); } /**