web/Translator.php
changeset 1427 8b3d57a519eb
child 1544 8f8faf11c81f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/Translator.php	Mon Jun 18 23:15:34 2018 +0200
@@ -0,0 +1,29 @@
+<?php
+// namespace IRI\Polemictweet\Web;
+
+use Zend\I18n\Translator\Translator as ZendTranslator;
+use Zend\I18n\Translator\TextDomain;
+use Zend\I18n\Translator\Loader\PhpMemoryArray;
+
+class Translator extends ZendTranslator {
+
+
+    public function _($message) {
+        return $this->translate($message, 'default');
+    }
+
+    public function addTranslation($messages, $locale) {
+
+        if (! isset($this->messages['default'])) {
+            $this->messages['default'] = [];
+        }
+        $textDomain = new TextDomain($messages);
+        if (isset($this->messages['default'][$locale])) {
+            $this->messages['default'][$locale]->merge($textDomain);
+        } else {
+            $this->messages['default'][$locale] = $textDomain;
+        }
+    }
+
+}
+