Media: Further improvements to the handling of language codes that get passed to MediaElement.

This change means that only the leading portion of a locale code gets passed to MediaElement, removing problems that arise from locales such as `de_DE_formal` and `pt_PT_ao90`.

Props erich_k4wp, blobfolio, flixos90, ocean90, joemcgill, SergeyBiryukov.

Fixes #42574


git-svn-id: https://develop.svn.wordpress.org/trunk@42251 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2017-11-28 14:51:33 +00:00
parent 49852ed54f
commit af52df0aa1

View File

@ -357,7 +357,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1);
did_action( 'init' ) && $scripts->add_inline_script( 'mediaelement-core', sprintf( 'var mejsL10n = %s;', wp_json_encode( array(
'language' => strtolower( str_replace( '_', '-', is_admin() ? get_user_locale() : get_locale() ) ),
'language' => strtolower( strtok( is_admin() ? get_user_locale() : get_locale(), '_-' ) ),
'strings' => array(
'mejs.install-flash' => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ),
'mejs.fullscreen-off' => __( 'Turn off Fullscreen' ),