Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am running a multilingual wordpress site - English and Japanese. I am using transposh plugin to make the English text translated to Japanese. And when the user choose Japanese, there will be a words "ja" appended to my url. (This problem should be independant of the Transposh plugin.)

For example, www.momorice.com is the english site, while www.momorice.com/ja/ denotes the Japanese page.

I would like to load different css files depending on the language that the user choose. The solution that i can think of is to detect the url for the characters "ja", if found, i will then have to point all my css file to japanese css file. Is this a recommended way? If so can someone give me some guideline to do this?

I realized I can make use of @font-face unicode-range to specify certain japanese font type for japanese characters. However this is not supported in Firefox browser. So I will not resort to this method.

share|improve this question

1 Answer 1

function load_my_styles() {
    wp_register_style( 'my-en-style1', plugins_url( 'en-style1.css', __FILE__ ) );
    wp_register_style( 'my-en-style2', plugins_url( 'en-style2.css', __FILE__ ) );

    wp_register_style( 'my-ja-style1', plugins_url( 'ja-style1.css', __FILE__ ) );
    wp_register_style( 'my-ja-style2', plugins_url( 'ja-style2.css', __FILE__ ) );

    $lang = preg_match( '/^\/ja\//i', $_SERVER['REQUEST_URI'] ) ? 'ja' : 'en';
    wp_enqueue_style( "my-{$lang}-style1" );
    wp_enqueue_style( "my-{$lang}-style2" );
}
add_action( 'wp_enqueue_scripts', 'load_my_styles' );
share|improve this answer
    
I would like to replace the style.css in my theme folder with specific css file. Will the above works? will the default style.css still be served? And apparently in my current theme, there is a direct reference to this style.css in some of the php file, eg. <link href="style/style.css" rel="stylesheet" type="text/css" /> How to overcome this direct reference of 1 fixed style.css? –  kentzo Apr 9 '12 at 15:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.