gettext domain mixing solution

I found zenphoto is mixing gettexts domains during run script, when theme has its own lc_messagess/domain. If there is no solution for this, this can be the solution (usable also for plugins etc):

New custom function for getting string from another than standard (zenphoto) domain. Something like
`
gettextd($string, $domain) {
1) set $domain as domain
2) get string
3) set back default/previous domain
}
`
_() function is nice helper. :-)

Comments

  • acrylian Administrator, Developer
    Yes, theme and plugin translations do not exactly work now. We had postponed that until we got an idea. Seems you had that now. This seems like an interessting and simple idea for this issue. Thanks, we will experiment with that.

    btw, we did not use the short term _() because it is too easy to overread and search for in source code.
  • I am using this and works well:
    `
    function gettext_th($string, $domain) {
    setupCurrentLocale(NULL,$domain,"theme");
    $output = gettext($string);
    setMainDomain();
    return $output;
    }
    `
    I add it into functions-i18n.php file.
  • acrylian Administrator, Developer
    We will try that. I assume you have configured Poedit or similar differently to note the gettext_th as well.
  • Yes, of course. 'gettext_th' is added into keywords field in catalog settings.

    In .po it looks like:
    `"X-Poedit-KeywordsList: gettext_th\n"`
  • acrylian Administrator, Developer
    Thanks, meanwhile it is already implemented with a few minor modifications in the svn/nightly builds, separately for themes and plugins. In case you are interessted, Info about that already on the translation tutorial.
Sign In or Register to comment.