• Resolved Chouby

    (@chouby)


    I am the author of Polylang But I noticed the same issue with WP Native Dashboard (and it probably exists with other multilingual plugins too).

    How to reproduce?
    * activate Jetpack 2.2 and a multilingual plugin
    * switch the backend language to something different from the default one (normally set by WPLANG)
    -> the WordPress admin interface (and generally other plugins) are correctly translated but not Jetpack.

    Why?
    At first glance, Jetpack loads its text domain in ‘Jetpack::init’ function hooked to ‘init’ action so multilingual plugins should have the time to switch the locale before the plugin text domain is loaded…

    But “Jetpack_Sync::sync_options” calls ‘Jetpack::init’ too, as soon as the plugin is loaded and before any hook is fired, thus multilingual plugins cannot do their job.

    Can “Jetpack_Sync::sync_options” wait for the hook ‘plugins_loaded’ to be fired?

    http://wordpress.org/extend/plugins/jetpack/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Thanks for the report!

    We’ll have a look at the problem, and I will post again here as soon as we can address the issue.

    Thread Starter Chouby

    (@chouby)

    thanks 🙂

    Habemus exsarcio, there is a workaround
    I encountered this same problem with bbPress in september – a too early firing to set localization…
    Because it is long to obtain a fixe by the authors (delays).
    The solution is based on unload_textdomain and two filters : the case jetpack is here added in bbPress solution. (xili-language plugin is compatible to a multilingual bbPress forum.
    This code is here provided as example:

    function xili_xl_bbp_lang_init ( ) {
    	if ( is_admin() )
    
    		add_filter( 'plugin_locale', 'xili_bbp_admin_side_locale', 10, 2);
    }
    
    function xili_bbp_admin_side_locale ( $locale = 'en_US', $domain = 'bbpress' ) {
    	if ( in_array ( $domain, array( 'bbpress' , 'jetpack' ) ) ) {
    
    		$locale = get_user_option( 'user_locale' );  // set elsewhere in xililanguage
    
    			if ( empty( $locale ) ) {
    				$locale = ( defined( 'WPLANG' ) ) ? WPLANG : 'en_US';
    
    				if ( is_multisite() ) {
    					if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) )
    						$ms_locale = get_site_option( 'WPLANG' );
    
    				if ( $ms_locale !== false )
    						$locale = $ms_locale;
    				}
    			}
    			// example for jetpack
    			unload_textdomain( 'jetpack' );
    			load_textdomain( 'jetpack', WP_PLUGIN_DIR.'/jetpack/languages/jetpack-'.$locale.'.mo' );
    	}
    
    	return $locale;
    }
    add_action( 'plugins_loaded', 'xili_xl_bbp_lang_init', 9 ); // 9 = to be registered before bbPress instantiate

    With these few lines, webmaster in the admin side is able to choose ‘live’ his language.

    M.

    Thread Starter Chouby

    (@chouby)

    Yes Michel. I also proposed the same solution for WordPress SEO by Yoast some months ago. See http://wordpress.org/support/topic/plugin-wordpress-seo-by-yoast-please-put-the-load_plugin_textdomain-on-init-action?replies=4#post-3185420

    But since this workaround does load two times the mo file, and since it is rather a time consuming process, it would be better if plugins did load the text domain in a function hooked to ‘plugins_loaded’ or ‘init’.

    In the case of WPSEO and Polylang, there is another (less time consuming) workaround because Polylang is loaded before WPSE0, but it can’t work with Jetpack (which is loaded before Polylang or Xili language).

    it is only a matter of time and duration… before waiting the improvements (versioning scheduling), good: the solution exists.

    Because in admin side, performances are less important than in visitors side except if more multilingual authors than readers 😉

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    @michel: I created a trac ticket with your proposed fix:#1764-plugins

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    We have now committed a fix, that will be included in the next Jetpack release, and solve all problems with multilingual plugins.

    Thread Starter Chouby

    (@chouby)

    That’s nice! Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Jetpack not correctly translated by multilingual plugins’ is closed to new replies.