WordPress.org

Plugin Directory

jetpack

Opened 5 years ago

Closed 4 years ago

#1764 closed defect (duplicate)

Language settings cannot be altered by language plugins

Reported by: jeherve Owned by: tmoorewp
Priority: normal Severity: normal
Plugin: jetpack Keywords: i18n languages has-patch
Cc: jeherve, michelwppi, richard@…

Description

Steps to reproduce:

  1. Activate Jetpack on your English Jetpack site
  2. Download a fresh copy of WordPress from http://ru.wordpress.org/
  3. Upload the contents of wp-content/languages/ to your own site via FTP
  4. In your dashboard, go to Plugins > Add New, and install WP Native Dashboard
  5. In Settings > Native Dashboard, enable the language switch in the admin bar
  6. Switch the dashboard language to Russian
    • The dashboard is translated, but not the contents added by Jetpack.

Here are some details by a plugin author:

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...

Reported here:

Attachments (2)

1764.diff (1.0 KB) - added by jeherve 5 years ago.
Load load_plugin_textdomain in plugins_loaded instead of init
1764.2.diff (980 bytes) - added by georgestephanis 5 years ago.

Download all attachments as: .zip

Change History (7)

@jeherve5 years ago

Load load_plugin_textdomain in plugins_loaded instead of init

@georgestephanis5 years ago

comment:1 @georgestephanis5 years ago

Just a minor tweak in the implementation -- added a contingency in case init is ever called after plugins_loaded

comment:2 @georgestephanis5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

In 720986:

Error: Failed to load processor CommitTicketReference
No macro or processor named 'CommitTicketReference' found

comment:3 @michelwppi5 years ago

  • Cc michelwppi added
  • Resolution fixed deleted
  • Status changed from closed to reopened

The modification is not perfect and the enqueuing in 'plugins_loaded' filters must set at level 100 and not 10 by default (too soon):

public static function init() {
		static $instance = false;

		if ( ! $instance ) {
			if ( did_action( 'plugins_loaded' ) )
				self::plugin_textdomain();
			else
				add_action( 'plugins_loaded', array( __CLASS__, 'plugin_textdomain' ), 100 ); // 100 = just before jetpack load_modules

			$instance = new Jetpack;

			$instance->plugin_upgrade();
		}

		return $instance;
	}

WHY ?

Because other plugins can enqueue their own filter between 10 and the 100 level of jetpack 'Plugins_loaded'. (more logical because jetpack choose the 100 level)

I test it with a plugin 'loaded' at level 15 (xiii-language) and all is now working by example with live change of admin language.

Thanks for your attention.

Michel

comment:4 @richardmtl4 years ago

  • Cc richard@… added

comment:5 @csonnek4 years ago

  • Resolution set to duplicate
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.