My Hack for a multilingual page (simple)
-
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 )
- The topic ‘My Hack for a multilingual page (simple)’ is closed to new replies.