By domain I mean the gettext domain. I have this code
$domain = "default";
$locale = 'en_US';
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain($domain, 'my_path');
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
So It will use the my_path/en_US/LC_MESSAGES/default.po
But I want to use more than 1 file so I can override overwrite the value in default.po
with another po file like admin.po, blog.po, etc
First define all your domains something like this:
bindtextdomain('domain1', DIR_LOCALE);
bindtextdomain('domain2', DIR_LOCALE);
bindtextdomain('domain3', DIR_LOCALE);
textdomain('domain1'); // set default domain for _() function
Now if you want to grab strings from a different domain, you'd use either dgettext()
or dcgettext()
(if not from LC_MESSAGES
) to retrieve just a single string from a different, specified domain. Example:
echo dgettext('domain2', "msgid");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With