Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#21691 closed defect (bug) (invalid)

WPLANG not settable in multisite if there are no language files

Reported by: foxinni's profile foxinni Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords: close
Focuses: Cc:

Description

I got a plugin running on a multisite and there is definitely something up with the translation.

I tracked the problem down to the WPLANG option in http://localhost/<subsite>/wp-admin/options.php being empty. I tried to update it, but it keeps reverting to blank. So down the line the issue with get_locale() looking for the WPLANG value in the site_options and then defaulting back to en_US because it's not picking it up from the wp-config.php defined WPLANG.

I'm assuming that the defined WPLANG in the wp-config.php does not apply in multisite instances. The plugin is only enabled on the separate blog instance, and I changed the translation in wp-config.php after the install if that has anything to do with it.

Simple filter to force the locale in the plugin for the moment:

function modify_locale(){
    return 'de_DE';
}
add_filter('locale','modify_locale');

I hope someone can reproduce this issue.

Attachments (1)

wplang-duh.diff (454 bytes) - added by wonderboymusic 11 years ago.

Download all attachments as: .zip

Change History (13)

#1 @thee17
11 years ago

WPLANG in the wp-config.php is supposed to globally set the WPLANG for all sites on the install.

#2 @wonderboymusic
11 years ago

You have to set language for each site individually in Network Admin - WPLANG in wp-config only works for site #1

#3 @foxinni
11 years ago

I'm logged in as the super admin and then go to that site's settings, but it's not saving the WPLANG like I'm expecting it too. The interface is also not very intuitive in that regard. http://foxinni.com/screens/site-settings-20120827-112529.png. Is this behavior normal? Am I looking/editing in the wrong place?

#4 @wonderboymusic
11 years ago

In sanitize_option() - here's the problem:

case 'WPLANG':
	$allowed = get_available_languages();
	if ( ! in_array( $value, $allowed ) && ! empty( $value ) )
		$value = get_option( $option );
	break;

The value should be IN the array, not excluded - attached patch

Last edited 11 years ago by wonderboymusic (previous) (diff)

#5 @wonderboymusic
11 years ago

  • Keywords has-patch added

#6 follow-up: @SergeyBiryukov
11 years ago

  • Keywords reporter-feedback added

Replying to foxinni:

So down the line the issue with get_locale() looking for the WPLANG value in the site_options and then defaulting back to en_US because it's not picking it up from the wp-config.php defined WPLANG.

If an empty WPLANG value exists, that's intentional, per ticket:18688:5.

The interface is also not very intuitive in that regard.

The proper screens for setting the language in Multisite are:

  1. For existing sites: My Sites → (Site Name) → Settings → General → Site Language.
  2. For new sites and for the main site: Network Admin → Settings → Default Language.

I tried to update it, but it keeps reverting to blank.

Couldn't reproduce that. Setting WPLANG in all possible ways (via Sites → Edit Site → Settings on the main site, or Settings → General or wp-admin/options.php on a subsite) works fine on my install.

  1. Do you have *.mo files in wp-content/languages for the language you're trying to set?
  2. Have you tried disabling all plugins?

I think I've found a related bug though. WPLANG site option is not populated on network setup for localized packages: #21726.

Replying to wonderboymusic:

The value should be IN the array, not excluded - attached patch

The check was introduced in [18346] and appears to be correct. If the new value is not within the allowed languages, it's not updated.

#7 in reply to: ↑ 6 ; follow-up: @foxinni
11 years ago

  • Summary changed from WPLANG not set in multisite to WPLANG not settable in multisite

@ SergeyBiryukov:

Remember that I'm not changing the language of my entire Wordpress, I just want to have translations for my plugin to work for small American and European spelling differences ( en_US & us_US for example). So there are no languages in my wp-content/languages folder, and thus no drop-down settings anywhere to change the locale for the network or subsite. I've seen them before and know that they exist. :)

Perhaps translating just a plugin without the entire WordPress along with IS illogical... but I wrote applied filter to fix the issue and I'm very happy with the route I've chosen to save myself from writing options to change text.

I tried to update the WPLANG option again, both on my machine and my colleuses' in the wp-admin/options.php, plus adding update_site_option('WPLANG', 'testing'); to my plugins root file and still nothing updates. It just remains blank...

#8 @SergeyBiryukov
11 years ago

  • Keywords has-patch reporter-feedback removed

Currently, setting WPLANG via the UI or via update_site_option() only works if there are corresponding files in wp-content/languages.

I guess using the locale or gettext filter workaround makes sense in your case.

#9 in reply to: ↑ 7 @thee17
11 years ago

You may want to consider that if they are using European spelling that they would be likely using en_GB for the European spelling as en_GB is a maintained WordPress localization. Also European spelling is often used in Canada that has a Canadian English version I've been maintaining that uses en_CA.

#10 @SergeyBiryukov
11 years ago

  • Summary changed from WPLANG not settable in multisite to WPLANG not settable in multisite if there are no language files

#11 @SergeyBiryukov
11 years ago

  • Keywords close added

The inability to change WPLANG without having language files in wp-content/languages sounds like expected behaviour to me.

#12 @wonderboymusic
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Sergey says close

Note: See TracTickets for help on using tickets.