Skip to:

Opened 9 years ago

Closed 8 years ago

#1953 closed defect (fixed)

Very early stage to set language (text_domain) by bbPress plugin !!!

Reported by: michelwppi Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.1
Component: Locale - i18n/l10n Keywords:
Cc: team@…


After working on add-on for xili-language plugin to manage language of multilingual forums (see I note that bbPress has his own way to set his plugin text domain… and at very early stage

On admin site if you use this type of code (example in class) :

function admin_side_locale( $locale = 'en_US' ) {
		$locale = get_user_option( 'user_locale' ); 

		if ( empty( $locale ) )
			$locale = $this->get_default_locale();
		return $locale;
add_filter( 'locale', array( &$this, 'admin_side_locale') );

Language changes in dashboard WP and all plugins according user option (but not bbPress remaining in pre-set language of config...)

After research how and when - "when" it is important - I found this solution especially for bbPress and his very well architectured code:

// bbPress admin Language (user locale)
function xili_xl_bbp_lang_init ( ) { 
	if ( is_admin() )
		add_filter( 'bbpress_locale', 'xili_bbp_admin_side_locale', 10 );

function xili_bbp_admin_side_locale ( $locale = 'en_US') {
	$locale = get_user_option( 'user_locale' ); 

		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;
		return $locale;
add_action( 'plugins_loaded', 'xili_xl_bbp_lang_init', 9 ); // 9 = to be registered before bbPress instantiate

the last action 'plugins_loaded' must be set to priority less than 10 - it is very important..

I don't know if this stage can be improved but voilà mine contributions ;-)


Change History (5)

#1 @michelwppi
9 years ago

  • Cc team@… added

#2 @johnjamesjacoby
9 years ago

  • Component changed from General to i18n/l10n
  • Milestone changed from Awaiting Review to 2.2

Hi Michel,

Thanks for the detailed report, though I'm having trouble figuring out exactly what to change in bbPress that would be helpful.

In bbPress 2.2, I'm removing the bbpress_locale filter, so that it's not necessary to filter it exclusively anymore. It's caused a few headaches, so I'm deprecating it.

#3 @michelwppi
9 years ago

Hi John,
Indeed this filter 'bbpress_locale' was redundant with filter 'plugin_locale' on previous line and his two params...
About 'headache', I agree with you so I will try to find a peaceful period to check the right stage to define when plugin text-domain must be defined to be sync with other plugins (avoiding the workaround described above)...

Note: the well designed data model of bbPress based on CPT and custom taxonomies and filters confirms me that the approach (5 years ago) of xili-language trilogy is good. With xili-tidy-tags (and very few lines added), it is now possible to group topic tags according language of forum according language of this forum.


#4 @johnjamesjacoby
9 years ago

  • Keywords reporter-feedback added
  • Milestone changed from 2.2 to Future Release

Punting to future release pending reporter feedback.

#5 @johnjamesjacoby
8 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Future Release to 2.3
  • Resolution set to fixed
  • Status changed from new to closed

This was fixed in 2.3.

Note: See TracTickets for help on using tickets.