• I made a twenty11 page multilingual:

    1. make 2 different menus, one for each language, one is ‘en’ the other ‘tr’

    2. add ‘_tr’ to the SLUG of each page in language ‘tr’,

    3. add a Language-choosing url html code somewhere in the page:
    <a href="/wordpress/?lang=en">EN</a> | <a href="/wordpress/?lang=tr">TR</a>
    becomes: EN | TR

    (wherever you want the html, i put it near bloginfo( ‘name’ ); in header.php where the name if the blog appears)
    this calls the root url of my blog with ‘?lang=tr’ appended to the url(change /wordpress/ with your root url)

    4. then at the end of HEADER.PHP find wp_nav_menu(…) function and replace it with the following 4 lines

    $m=”en”;
    if ((isset($_GET[‘lang’]) && $_GET[‘lang’]==”tr”) || substr($_SERVER[‘SCRIPT_URL’], -4,3)==”_tr”)
    $m=”tr”;
    wp_nav_menu( array( ‘menu’ => $m ) );

    (line 1: default language is ‘en’,
    line 2: if ?lang=… is preset, and it’s value is ‘tr’, OR current SLUG (url) ends with _tr, switch to ‘tr’
    line 3: run wp_nav_menu() with argument menu=language )

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ozzythaman

    (@ozzythaman)

    EVEN SIMPLER VERSION:

    make 2 menus named en/tr

    add _tr to slug of all pages belonging to tr

    make code like this:
    <a href="/wordpress/">EN</a> | <a href="/wordpress/aaaaaa_tr">TR</a>
    aaaaaa_tr = first page of tr

    add following lines to header instead of wp_nav_menu:

    $m=”en”;
    if (substr($_SERVER[‘SCRIPT_URL’], -4,3)==”_tr”) $m=”tr”;
    wp_nav_menu( array( ‘menu’ => $m ) );

    (if url ends with _tr, keep showing menu tr, else: en)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘My Hack for a multilingual page (simple)’ is closed to new replies.