• I’d like to build a multiple language site that would have 3 separate languages like this:

    / – finnish
    /se/ -swedish
    /eng/ -english

    They will have both sub pages and categories. I think I can build the navigation quite easily by building root categories and pages for each language.

    I’d like to have each ‘directory’ to be fully localized for the useer. My problem now is that I’d like to use a different language file for each. There’s also some hardcoded stuff in the template, but I suppose I can hack that in by creating a $_dictionary, etc. array by myself. I’d just like to have automatic dates, months, etc.

    I’d rather not run multiple blogs to keep everything under a single login. Any suggestions on how to do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Jani Tarvainen

    (@janit)

    Problem solved. Just used some if statements in wp-config to hack the correct language file according to URI.

    Jani,
    could you be a bit more specific about what you did? I think for many non-coder users it would be a great help if you could post a (step by step) description of how did you succeed to make the blog “tri-lingual”. Thanks!

    Thread Starter Jani Tarvainen

    (@janit)

    Sure 🙂 Most of the template translations are hardcoded ( <h1>Hello</h1> vs. <h1><? echo $greeting ?></h1>”, for example ), for these I’ll have to create my own dictionary solution.

    Here’s an example with the following structure (it gives me localized dates and navigation):

    / – finnish
    /en/ – english

    Some translations come from the language files (/wp-includes/languages/xx_xx.mo). I’ve got the necessary ones in place and I add this:


    $URI = explode('/',$_SERVER[REQUEST_URI]);

    if (in_array('en',$URI)){
    define ('WPLANG', '');
    } else {
    define ('WPLANG', 'fi_FI');
    }

    It breaks the request to an array and defines the appropriate language file. Now I get localized dates (not sure if anything else even comes from the file).

    I can also use the same trick to build the navigation (english page, english links only, etc.). Remember my ‘root language’ here is Finnish. I’ve got something like this in my template header.php


    $URI = explode('/',$_SERVER[REQUEST_URI]);

    if (in_array('en',$URI)){
    $catOptions = 'child_of=2';
    $pageOptions = 'title_li=&child_of=2';
    } else {
    $catOptions = 'exclude=2';
    $pageOptions = 'exclude=2';
    }

    English category and root page are both ID 2, your mileage may vary. I then later create call the wp_list_cats and wp_list_pages with the appropriate variables to create a navigation. You’ll need to have the english link (/en/) somewhere, since its not displayed in the page navigation.

    The structure is now like this:
    / (english front page)
    /finnish-page/
    /category/somecategory/post1
    /en/ (english front page)
    /en/english-page/
    /category/englishcategory/post1
    …..

    I’m in a hurry and might have missed something. Hope this clears it up.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Choosing lang file by ‘directory’’ is closed to new replies.