WordPress.org

Make WordPress Core

Ticket #42574: 42574.2.diff

File 42574.2.diff, 1.9 KB (added by flixos90, 6 months ago)
  • src/wp-includes/l10n.php

     
    12101210                selected( '', $parsed_args['selected'], false )
    12111211        );
    12121212
    1213         // List installed languages. 
     1213        // List installed languages.
    12141214        foreach ( $languages as $language ) {
    12151215                $structure[] = sprintf(
    12161216                        '<option value="%s" lang="%s"%s data-installed="1">%s</option>',
     
    13321332
    13331333        return $wp_locale_switcher->is_switched();
    13341334}
     1335
     1336/**
     1337 * Parses a WordPress locale identifier into an ISO 639 locale identifier.
     1338 *
     1339 * @since 5.0.0
     1340 *
     1341 * @param string $locale A WordPress locale.
     1342 * @return string Parsed ISO locale.
     1343 */
     1344function wp_parse_iso_locale( $locale ) {
     1345        $locale = str_replace( '_', '-', $locale );
     1346
     1347        if ( substr_count( $locale, '-' ) > 1 ) {
     1348                $locale = implode( '-', array_slice( explode( '-', $locale ), 0, 2 ) );
     1349        }
     1350
     1351        return $locale;
     1352}
  • src/wp-includes/script-loader.php

     
    357357        $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1);
    358358
    359359        did_action( 'init' ) && $scripts->add_inline_script( 'mediaelement-core', sprintf( 'var mejsL10n = %s;', wp_json_encode( array(
    360                 'language' => strtolower( str_replace( '_', '-', is_admin() ? get_user_locale() : get_locale() ) ),
     360                'language' => strtolower( wp_parse_iso_locale( is_admin() ? get_user_locale() : get_locale() ) ),
    361361                'strings'  => array(
    362362                        '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/' ),
    363363                        'mejs.fullscreen-off'      => __( 'Turn off Fullscreen' ),