Media: Use user locale as ME.js language in admin and add `mejsL10n` inline script before `mediaelement-core` so WP-exported translation strings are used.

See #39686.
Fixes #42241.


git-svn-id: https://develop.svn.wordpress.org/trunk@41889 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-10-18 00:07:30 +00:00
parent 3e3ec01c63
commit 9bca555920
1 changed files with 4 additions and 3 deletions

View File

@ -355,8 +355,9 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.6-78496d1' );
$scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.6-78496d1', 1 );
$scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1);
did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array(
'language' => get_bloginfo( 'language' ),
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() ) ),
'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' ),
@ -443,7 +444,7 @@ function wp_default_scripts( &$scripts ) {
'mejs.welsh' => __( 'Welsh' ),
'mejs.yiddish' => __( 'Yiddish' ),
),
) );
) ) ), 'before' );
$scripts->add( 'mediaelement-vimeo', "/wp-includes/js/mediaelement/renderers/vimeo.min.js", array('mediaelement'), '4.2.6-78496d1', 1 );