[wp-hackers] Using constants for text domain

J.D. Grimes jdg at codesymphony.co
Wed Nov 27 13:57:40 UTC 2013


The reason that your setup is a bad idea is because it won’t be possible to generate the POT file automatically with the available programs. Your text domain should always be a string, otherwise the POT generators won’t pick it up properly. The same also goes for the strings being gettexted, which is why, although your system will work, it won’t be easy to generate your POT files automatically. The POT generator won’t recognize your functions as gettext functions, so it won’t pick up those strings either.

-J.D.

On Nov 27, 2013, at 8:38 AM, Justas Butkus <jbutkus at time.ly> wrote:

> Hi all.
> 
> In a recent response to "Best way to allow slug rewrite of CPT via i18n" by Otto I saw him warning against use of defined constant for the text domain.
> 
> What is the reasoning behind this, are there any exceptions to this rule?
> 
> We are proxying calls to gettext functions (__, _x, ...) family via our class, so the result is much like this:
> ```
> class PluginPrefix_Foo {
> 
>    public function __( $string ) {
>        return __( $string, PLUGINPREFIX_TEXT_DOMAIN );
>    }
> 
> }
> ```
> 
> 
> -- 
> Regards,
> Justas Butkus
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list