[wp-trac] [WordPress Trac] #40715: TinyMCE should use the site language instead of the user one

WordPress Trac noreply at wordpress.org
Wed May 10 12:19:53 UTC 2017


#40715: TinyMCE should use the site language instead of the user one
----------------------------+-----------------------------
 Reporter:  7studio         |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:  4.7
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Since the [https://core.trac.wordpress.org/changeset/36802 change 36802],
 TinyMCE in the admin panel uses the language defined by the default
 translated string (`html_lang_attribute`) based on locale. In almost all
 cases, the locale is defined by the site language.

 Except that since the 4.7, the user is able to select their preferred
 locale (language) when editing their profile.

 In this specific case, if the selected language is different from the site
 language, TinyMCE will use a wrong locale (the user one) for the `lang`
 attribute on its `<html>` element.

 This wrong behaviour is due to `get_bloginfo( 'language' )` which is used
 to define the `wp_lang_attr` entry.

 That's a shame especially when you want to use the `:lang` CSS pseudo-
 class and you get a different result in the admin panel and on your site.

 For the moment, I'm able to resolve this issue by overriding the value via
 the filter `tiny_me_before_init`:
 {{{#!php
 <?php

 function fix_wp_lang_attr( $mceInit ) {
         $lang = get_locale();
         $lang = str_replace( '_', '-', $lang );

         $mceInit['wp_lang_attr'] = $lang;

         return $mceInit;
 }
 add_filter( 'tiny_me_before_init', 'fix_wp_lang_attr' );
 }}}

 Hope you will consider this ticket and it contributes to WP.
 ==  ==

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40715>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list