WordPress.org

Make WordPress Core

Changeset 19836


Ignore:
Timestamp:
02/06/2012 07:36:24 PM (6 years ago)
Author:
nacin
Message:

Do RTL detection based on a translated string, rather than a hardcoded list. Makes things a bit cleaner. fixes #19924, fixes #19600.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r19787 r19836  
    727727                    if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) )
    728728                        load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' );
    729                     if ( WP_Locale::is_locale_rtl( $locale ) )
    730                         $text_direction = 'rtl';
    731729                    break 2;
    732730                }
  • trunk/wp-includes/locale.php

    r19797 r19836  
    8484     */
    8585    var $text_direction = 'ltr';
    86 
    87     /**
    88      * Locales which are known to be right-to-left.
    89      *
    90      * @since 3.4.0
    91      * @var array
    92      * @access private
    93      * @static
    94      */
    95     private static $rtl_locales = array( 'ar', 'ckb', 'fa_IR', 'he_IL', 'ug_CN', 'dv', 'fa_AF', 'ha', 'ps', 'uz_UZ', 'yi' );
    9686
    9787    /**
     
    191181        if ( isset( $GLOBALS['text_direction'] ) )
    192182            $this->text_direction = $GLOBALS['text_direction'];
    193         elseif ( is_textdomain_loaded( 'default' ) && self::is_locale_rtl( get_locale() ) )
     183        elseif ( 'rtl' == _x( 'ltr', 'text direction' ) )
    194184            $this->text_direction = 'rtl';
    195185    }
     
    336326    function is_rtl() {
    337327        return 'rtl' == $this->text_direction;
    338     }
    339 
    340     /**
    341      * Determines whether a locale is known to be right-to-left.
    342      *
    343      * @since 3.4.0
    344      * @static
    345      *
    346      * @param string Locale in WP format.
    347      * @return bool Whether locale is RTL.
    348      */
    349     public static function is_locale_rtl( $locale ) {
    350         return in_array( $locale, self::$rtl_locales );
    351328    }
    352329}
Note: See TracChangeset for help on using the changeset viewer.