From 853fa27b530dc0a156b7285eda53dbc6f7285038 Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 25 Jan 2012 22:41:55 +0000 Subject: [PATCH] Initial support for RTL detection in core. props SergeyBiryukov for compiling the list. fixes #19600. git-svn-id: http://svn.automattic.com/wordpress/trunk@19755 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/locale.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wp-includes/locale.php b/wp-includes/locale.php index fa67bcb17..b34129238 100644 --- a/wp-includes/locale.php +++ b/wp-includes/locale.php @@ -84,6 +84,11 @@ class WP_Locale { */ var $text_direction = 'ltr'; + /** + * Locales which are known to be right-to-left. + */ + private $rtl_locales = array( 'ar', 'ckb', 'fa_IR', 'he_IL', 'ug_CN', 'dv', 'fa_AF', 'ha', 'ps', 'uz_UZ', 'yi' ); + /** * Sets up the translated strings and object properties. * @@ -177,10 +182,13 @@ class WP_Locale { $trans = __('number_format_decimal_point'); $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans; + // Locale-specific tweaks + if ( in_array( get_locale(), $this->rtl_locales ) ) + $this->text_direction = 'rtl'; + // Import the $text_direction global. if ( isset( $GLOBALS['text_direction'] ) ) $this->text_direction = $GLOBALS['text_direction']; - } /** @@ -321,9 +329,10 @@ class WP_Locale { * @since 3.0.0 * @return bool Whether locale is RTL. */ - function is_rtl() { - return 'rtl' == $this->text_direction; - } + function is_rtl() { + return 'rtl' == $this->text_direction; + } + } /**