简体   繁体   中英

Handle textDomains with zend-framework3 and gettext



We're using ZF3 for a large app with internationalization.
i18n is done with zend-i18n, zend-mvc-i18n, and xgettext cli for extraction / compilation of pot / po / mo files.
For some words like Contact which could be a verb or a noun, we've specified a $textDomain : $this->translate('Contact', 'Verb') or $this->translate('Contact', 'Noun') .

Problem is, when we extract those strings, it's all in the same pot file.
Since Zend load translation files by textDomain, it would be better if we could split pot files by textDomain, but it seems like xgettext can't do that.

Could someone help us to manage properly textDomains with Zend and gettext?

For those who may have the same problem, we ended up creating our own Gettext file loader, which properly parses msgctxt and returns a TextDomain structured by msgctxt.
We also created our own Translator extends Zend\\I18n\\Translator\\Translator to override loadMessagesFrom... functions and properly update the $this->messages variable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM