WordPress.org

Ready to get started?Download WordPress

Forums

my multilingual setup (2 posts)

  1. Khalid
    Member
    Posted 1 year ago #

    well, i'm just proud of my new multilingual setup, i been testing for two years so far, my goal was to make just simple website with same admin panel and ability to write in two languages, the problem is i do write in Arabic which is rtl, and that looks bad when mixed with English.
    my front page is in Arabic:
    fashionied, the fashion design site
    every thing should be in Arabic, but the English categories, EN single posts, and i need English front page as well.
    i made 5 Arabic categories and 3 English cats, the first step was to make category template for the EN ones so i just made them, put them in the theme folder, for the header, footer, sidebar, and CSS file, i made folder, and put all this file in it, called them from my EN cats template.
    so far so good.
    now i wanna exclude the English posts from the Arabic front-page which is the default index.php, simply i used this code:
    <?php
    $cat1 = get_cat_ID('fashion design');
    $cat2 = get_cat_ID('pattern making');
    $cat3 = get_cat_ID('garment sewing');
    $q = 'cat=-'.$cat1 .', -' . $cat2 .', -' . $cat3;
    query_posts($q .'&paged='.$paged);?>

    now my front-page is 100% Arabic, i have the Arabic cats and posts running well too.
    now i wanna have EN template for the English single posts, so i add this code the the very start of single.php file:
    <?php if ( in_category( array( 'garment sewing', 'fashion design', 'pattern making' ) )) {
    include(TEMPLATEPATH . '/en/single.php');
    } else {
    get_header();
    ?>

    if it's English post use the English single post template, other wise go on with default one. i had to end the IF statement by adding this line to the end of the sinle.php file. <?php } ?>
    cool?
    now i want to make English front page, just made a page template with a loop started like this:
    <?php
    $cat1 = get_cat_ID('fashion design');
    $cat2 = get_cat_ID('pattern making');
    $cat3 = get_cat_ID('garment sewing');
    $q = 'cat='.$cat1 .', ' . $cat2 .', ' . $cat3;
    query_posts($q .'&paged='.$paged);?>

    this lets the page to query posts from this 3 cats only, then i add the usual template code necessary to show posts.
    here it is:
    fashionied in EN
    of-course the header, footer, sidebar, and css for EN content is different than AR, the EN pages uses EN template different than Arabic ones.
    so now i'm happy with easy to manage single website, with two languages, every one of them is shown the right way, just cant stop myself from working further, i dont know where or why, i just like doing it :).
    i'm not coder, not web developer, i'm just fashion designer, who loves php, css and WordPress.

  2. blograzzi
    Member
    Posted 1 year ago #

    I really want to learn this.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.