0

Here is my problem, i am trying to translate plugin. I use plugin locale hooke

add_filter('plugin_locale', 'pls_locale', 10, 2);

next function wich return language de_DE

   function pls_locale() 
    {
       $pls_language = get_option('jezik');
       return $pls_language;  
    }

finally translate strings something like this

__('text', 'myplugin');

But i have major problem, when i try to change my language in my plugin, also lang on otheres plugins are changed.

Also i cant use load_plugin_textdomain() function because it depends on WPLANG constant, wich change also admin lang, wich i dont want. Any suggestions?

0

The filter comes with the text domain as second argument. So you could do this:

function wpdev_170138_plugin_locale( $locale, $domain )  {

    if ( $domain === 'myplugin' ) {
        return get_option( 'jezik' );
    }

    return $locale;
}

add_filter( 'plugin_locale', 'wpdev_170138_plugin_locale', 10, 2 );

Now only your plugin's locale is changed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.