Re: Gettext - finding translations for imported common module

Gerry Reno <[email protected]> Sat, 06 Nov 2010 12:38:32 -0400
Newsgroups gmane.comp.php.internationalization
Message-ID <[email protected]>
On 11/05/2010 01:01 PM, Gerry Reno wrote:
> I am using PHP 5.2.4 and gettext.
> I have a common module that I import (require) into other modules.
> But when I do this pages (at a different level in site tree) do not 
> show the translations for this module.
>
> /siteroot
> /siteroot/lib/common.php
> /siteroot/lib/locale/[LANG]/LC_MESSAGES/message.po    #COMMON MODULE 
> TRANSLATIONS ARE IN HERE
>
> /siteroot/index.php             #require("lib/common.php")     #NO 
> COMMON MODULE TRANSLATION OCCURS
> /siteroot/locale/[LANG]/LC_MESSAGES/message.po
> /siteroot/page2/index.php  #require("../lib/common.php")  #NO COMMON 
> MODULE TRANSLATION OCCURS
> /siteroot/page2/locale/[LANG]/LC_MESSAGES/message.po
>
> Right now all the regular translations work fine but the imported 
> module is not translated even though I have the translations for it 
> under the /siteroot/lib directory.
>
> If I put the common module translation into each po file under each 
> /siteroot/pageN directory then the common module translations work but 
> this requires tons of duplication.
>
> Is there a way to bind an alternate root or domain so that gettext can 
> find both the local translations and the library translations for the 
> imported common modules?
>

After some experimenting I was able to redeclare the text domain binding 
so that it looked in the library location for the translations and then 
later reset it back to what it was previously.



-- 
PHP Unicode & I18N Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php