Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not respect admin locale, uses WPLANG only #1027

Closed
nrrb opened this issue Aug 22, 2014 · 8 comments
Closed

Does not respect admin locale, uses WPLANG only #1027

nrrb opened this issue Aug 22, 2014 · 8 comments
Labels
General [Type] Bug When a feature is broken and / or not performing as intended

Comments

@nrrb
Copy link

nrrb commented Aug 22, 2014

In my site's wp-config.php I have the language set to es_ES since this is a Spanish-language news site and I want to use the default translation strings for front-end interface elements:

define('WPLANG', 'es_ES');

My theme is a child theme of twentythirteen. In my theme's functions.php I have the admin language set to en_US:

// Set the language of the admin to English
function vivelohoy_set_admin_lang($lang) {
    if( is_admin() ) {
        $lang = 'en_US';
    }
    return $lang;
}
add_filter( 'locale', 'vivelohoy_set_admin_lang' );

In the admin area, most plugins display in English but JetPack still displays in Spanish:

image

@jeherve
Copy link
Member

jeherve commented Aug 22, 2014

Possibly related to #113.

@tothebeat Would you mind trying to revert c4fe305 on your site, and let me know how it goes?

@nrrb
Copy link
Author

nrrb commented Aug 22, 2014

@jeherve I reverted it and still I have the Spanish language interface in the admin. Hopefully I did the revert right. I did the following:

  1. Changed directory into wp-content/plugins

  2. Removed existing jetpack folder there with rm -rf jetpack

  3. Cloned the Github repository with git clone https://github.com/Automattic/jetpack.git

  4. Changed directory into jetpack

  5. Reverted the specified commit with git revert c4fe305

  6. Checked that the revert worked, the most recent two lines in my git log:

    * 7bb9b23 - (HEAD, master) Revert "i18n: bump the plugin_textdomain call to 99" (4 minutes ago) <Nick Bennett>
    * af479fe - (origin/master, origin/HEAD) REST API: 400s should return regardless of origin… (58 minutes ago) <George Stephanis>
    

Jetpack is still displayed in Spanish:

image

@jeherve
Copy link
Member

jeherve commented Aug 22, 2014

Thanks for trying! You can go back to the standard Jetpack 3.1.1 then.

What happens when you remove your vivelohoy_set_admin_lang function, and use a plugin like this one instead?
https://wordpress.org/plugins/wp-native-dashboard/

@georgestephanis
Copy link
Member

I think it may be happening too late, as you're setting the admin language when your theme loads in functions.php.

Can you try migrating your language switcher admin snippet into a new mu-plugins file?

@nrrb
Copy link
Author

nrrb commented Aug 22, 2014

@jeherve I tried disabling all plugins except for Jetpack 3.1.1 and wp-native-dashboard 1.3.12 and removed the vivelohoy_set_admin_lang-related code from my functions.php and I still see Jetpack in Spanish:

image

All settings in wp-native-dashboard are default:
image

I also tried switching to plain vanilla twentythirteen and had the same result.

I am running WordPress 3.9.2, the main English version. There is a build specifically for es_ES that I have avoided because it translates too much to Spanish:

image

@georgestephanis After trying the above, I deactivated the wp-native-dashboard plugin and created a file wp-content/mu-plugins/english_admin.php with the following contents:

<?php

// Set the language of the admin to English
function vivelohoy_set_admin_lang($lang) {
    if( is_admin() ) {
        $lang = 'en_US';
    }
    return $lang;
}
add_filter( 'locale', 'vivelohoy_set_admin_lang' );

Still no dice.

I haven't previously used mu-plugins, don't have examples to work from, and the official docs leave me wanting, so I hope I'm doing it right. Please let me know if I should be doing this another way.

@jeherve
Copy link
Member

jeherve commented Aug 23, 2014

I tried disabling all plugins except for Jetpack 3.1.1 and wp-native-dashboard 1.3.12 and removed the vivelohoy_set_admin_lang-related code from my functions.php and I still see Jetpack in Spanish:

I can't seem to reproduce.

I tried the following:

  1. Set WPLANG to fr_FR
  2. Install WP Native Dashboard
  3. Switch my dashboard to English
    • All the dashboard got switched, including Jetpack

I then tried the following:

  1. Set WPLANG to fr_FR
  2. Paste the code from your original post into a new plugin
    • All the dashboard got translated to English, including Jetpack

I tested this with both WP 3.9.2 and WP Master, and with JP 3.1.1 and JP Master.

Something else seems to affect the locales on your site.

Could you try on a different site?

@nrrb
Copy link
Author

nrrb commented Aug 25, 2014

@jeherve Thanks very much for your earnest work on troubleshooting my issue and for providing such complete instructions. I will respond in turn with my detailed steps to replicate what you provided. I was able to make it work with the second method, via mu-plugins, but not by the first that involved WP Native Dashboard. I will concentrate my troubleshooting on how my Spanish site differs from the successful English admin build.

To spin up something quickly, I went with setting up a WordPress 3.9.2 site on WebFaction which chooses twentyfourteen as the default theme. I then download the wp-config.php file via SFTP, edit it to set WPLANG to fr_FR, save, and re-upload it. I then install JetPack 3.1.1 and see the following:

image

You can see the 3.9.2 "update" being offered because the language is set differently and WordPress is helpfully trying to get me to install the fr_FR localized version. You can also see the French language text shown with the as-yet-unactivated JetPack plugin.

From this point I try each of the following two methods as you described, reverting back to this base state for each attempt.

Using WP Native Dashboard

  1. Install WP Native Dashboard plugin and activate it

  2. Go to Settings -> Native Dashboard and enable all the Capabilities:

    image

  3. Now I see "Français (fr_FR)" on the left side of the admin bar. When I click on this, nothing happens. No menu, nothing.

    image

I think perhaps I am not understanding how to properly activate the WP Native Dashboard, or how to switch languages with it.

Using mu-plugins

  1. Create a file english_admin.php with the following contents:
<?php
// Set the language of the admin to English
function vivelohoy_set_admin_lang($lang) {
    if( is_admin() ) {
        $lang = 'en_US';
    }
    return $lang;
}
add_filter( 'locale', 'vivelohoy_set_admin_lang' );
  1. Upload this to the WebFaction site via SFTP, placing it in the mu-plugins folder (which I have to create) so that the full path from the root of the WordPress site is wp-content/mu-plugins/english_admin.php.
  2. Refresh the plugins page. Yay!
    image

Thanks also to @georgestephanis for the patient response.

@nrrb
Copy link
Author

nrrb commented Aug 25, 2014

I found that I was able to fix my site using the mu-plugins method after restarting the server. It's unclear if it's PHP that needed to be restarted or memcache that needed to be flushed, but since this only needs to be done once for me then I consider it unimportant to nail down.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

No branches or pull requests

3 participants