Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Fix for gettext with defined text_domain
Browse files Browse the repository at this point in the history
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 #53
  • Loading branch information
ma-si committed Jan 10, 2017
1 parent ca78d28 commit b4f3109
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b4f3109

Please sign in to comment.