Make WordPress Core

Ticket #60091: 60091.diff

File 60091.diff, 1.3 KB (added by sabernhardt, 11 months ago)

adds language code inside option element before the native name

  • src/wp-includes/l10n.php

     
    16991699        if ( $translations_available ) {
    17001700                $structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">';
    17011701                foreach ( $translations as $translation ) {
     1702                        // Add zero-width non-joiner to language code so screen readers spell out each letter.
     1703                        $language_code_characters   = str_split( $translation['language'] );
     1704                        $language_code_add_entities = implode( '&zwnj;', $language_code_characters );
     1705                        $language_code_with_zwnj    = str_replace(
     1706                                array( '&zwnj;_&zwnj;', 'a&zwnj;o&zwnj;9&zwnj;0', 'i&zwnj;n&zwnj;f&zwnj;o&zwnj;r&zwnj;m&zwnj;a&zwnj;l', 'f&zwnj;o&zwnj;r&zwnj;m&zwnj;a&zwnj;l' ),
     1707                                array( '_', 'a&zwnj;o90', 'informal', 'formal' ),
     1708                                $language_code_add_entities
     1709                        );
     1710
    17021711                        $structure[] = sprintf(
    17031712                                '<option value="%s" lang="%s"%s>%s</option>',
    17041713                                esc_attr( $translation['language'] ),
    17051714                                esc_attr( current( $translation['iso'] ) ),
    17061715                                selected( $translation['language'], $parsed_args['selected'], false ),
    1707                                 esc_html( $translation['native_name'] )
     1716                                esc_html( $language_code_with_zwnj . ' - ' . $translation['native_name'] )
    17081717                        );
    17091718                }
    17101719                $structure[] = '</optgroup>';