From b4f3109bfa556c65753dd052370d9a2877352697 Mon Sep 17 00:00:00 2001 From: MaSi Date: Tue, 10 Jan 2017 23:12:20 +0100 Subject: [PATCH 1/2] Fix for gettext with defined text_domain Ex. 1 - Missing translations with defined text_domain in PoEdit Source keywords: `translate:1,2c` `translatePlural:1,2,4c` Ex. 2 - Working PoEdit Source keywords (but without text_domain): `translate:1` `translatePlural:1,2` Cause: Gettext with defined text_domain gives `\x04' EOT in storage array key Ex. 1 `ui\x04name` Ex. 2`name` Resolves zendframework/zend-i18n#53 --- src/Translator/Translator.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Translator/Translator.php b/src/Translator/Translator.php index bb82a33c..fe0c150d 100644 --- a/src/Translator/Translator.php +++ b/src/Translator/Translator.php @@ -446,6 +446,24 @@ protected function getTranslatedMessage( return $this->messages[$textDomain][$locale][$message]; } + + /** + * issue https://github.com/zendframework/zend-i18n/issues/53 + * + * storage: array:8 [▼ + * "default\x04Welcome" => "Cześć" + * "default\x04Top %s Product" => array:3 [▼ + * 0 => "Top %s Produkt" + * 1 => "Top %s Produkty" + * 2 => "Top %s Produktów" + * ] + * "Top %s Products" => "" + * ] + */ + if (isset($this->messages[$textDomain][$locale][$textDomain . "\x04" . $message])) { + return $this->messages[$textDomain][$locale][$textDomain . "\x04" . $message]; + } + if ($this->isEventManagerEnabled()) { $until = function ($r) { return is_string($r); From b3380cddafd7af3b9cb3fefcb78583fd5c6acc7a Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 17 May 2017 11:52:26 -0500 Subject: [PATCH 2/2] Added CHANGELOG for #62 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5587fd3a..893a1825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,9 @@ All notable changes to this project will be documented in this file, in reverse - [#56](https://github.com/zendframework/zend-i18n/pull/56) adds more aliases to the `LoaderPluginManager` to ensure different cAsIng strategies will still resolve translation loaders under zend-servicemanager v3. +- [#62](https://github.com/zendframework/zend-i18n/pull/62) fixes an issue with + how the gettext adapter resolves `PoEdit` source keywords when a text_domain is + defined. ## 2.7.3 - 2016-06-07