• Resolved theyuv

    (@theyuv)


    Hello,

    I am using WPGlobus for English and Hebrew and, in the “Languages” table, I renamed the Hebrew locale to “iw” (instead of the default “he_IL).

    However, if I do this, then my default rtl.css script (in the root directory of my theme) doesn’t get loaded. Whereas, if I leave the locale as “he_IL” then the rtl.css script is loaded by default when the language is changed.

    Is there any way to correct this so that the RTL.css script is also loaded when the locale is “iw”?

    A somewhat related question:
    How come each page’s htmllangattribute is populated with the “locale” (eg: he-IL) and not the language (eg:he)?

    Thank you.

    • This topic was modified 8 years, 1 month ago by theyuv. Reason: typo
    • This topic was modified 8 years, 1 month ago by theyuv. Reason: addition
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Alex Gor

    (@alexgff)

    As for locale
    Just add piece of code to file functions.php of active theme

    
    add_action( 'wp_print_styles', 'wpglobus__engueue_style' );
    function wpglobus__engueue_style() {
    	if ( WPGlobus::Config()->language == 'he' ) {
    		wp_enqueue_style( 'rtl', get_template_directory_uri() . '/rtl.css', array(), '20161005' );
    	}	
    }
    

    where ‘he’ is language code

    Hello @theyuv,

    The he_IL is used by WordPress. If you look at the file he_IL.po in the wp-content/languages folder, lines 20-24, that’s how the text direction is set. The rtl.css is loaded when the text direction is set to rtl.

    Alternatively, class-wp-locale.php checks for a global variable:

    
    		// Set text direction.
    		if ( isset( $GLOBALS['text_direction'] ) )
    			$this->text_direction = $GLOBALS['text_direction'];
    		/* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */
    		elseif ( 'rtl' == _x( 'ltr', 'text direction' ) )
    			$this->text_direction = 'rtl';
    

    So, if you really need to use the old iw globally, instead of the new he_IL, you will need to do some work.

    If only in your theme, at the front, then check the theme’s header and modify it: both the CSS part and the html lang part.

    Hope this helps, because WPGlobus has nothing to do with this. We just set the prefix->locale connection.

    Thanks

    Thread Starter theyuv

    (@theyuv)

    Thanks a lot guys for your answers.

    @tivnet Thank you. So WP is responsible for placing the entire locale (eg: he-IL) in the lang attribute of the html element?
    This is a mistake, no? Shouldn’t there be a language code there?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘RTL css trigger’ is closed to new replies.