I have a bilingual (english/arabic) wordpress site. I was able to successfully translate the navigation menu items. However, the menu links on the arabic site, link to the default language which is English.
How can I tell wordpress that I need the menu links to change on the arabic site (I need the links on the arabic site to include /ar, for example: www.talalonline.com/ar instead of www.talalonline.com)
thanks
@maha, I searched a lot about this and found the solution here, but the answer is a little fuzzyâ¦
As you don’t want to mess with your WP core files, all changes are in the theme. Your theme is located in wp-content/themes/your-theme-name/
Find your theme’s function.php and add the code above in the end of the file, before the php end tag (?>):
Then, you have to find where’s your menu view inside your theme. The theme I’m using implement’s it in the header.php. Maybe your’s uses another file name, like header-fancy-theme.php.
My header view code was like this:
All you have to do is add the Walker implementation in the param array:
Then, in your menu, you’ll use |lang| after the language URL ,like this:
I know it’s not the exactly use you were hopping of automatic language links, but this may solve your problem.
fork of qtranslate does this out of the box:
https://wordpress.org/plugins/qtranslate-x/
in the menu item in the field “navigation label” just provide strings for both languages:
tested with qTranslate-X 2.7.8, WordPress 4.1 and Twenty Fifteen 1.0 theme
There are four functions in WP to translate your menu text using default or plugin option.
Each of the four functions requires at least one argument, which is the text that is to be translated. The functions are:
__() â (two underscores) The basic function that you will use the majority of the time. It returns the text in the correct language.
e() â The same as _() except it echoes the text instead of returning it.
_n() â Used when the text has the potential to be plural, so for example if you were to display how many comments have been made, you might want to output either âX commentsâ or âX commentâ depending on how many comments you have.
_x() â Useful for when the translation of the word depends on the context. âPostâ could mean âa post (noun)â or âto post (verb)â depending on context. It is important for the translator to know which you mean when translating to be accurate. _x() is mainly used where single words are used.
ex
I am also working with qTranslate and bilingual Arabic/English site.
You can have your
.htaccess
as the following:And select the “Use Pre-Path Mode (Default, puts /en/ in front of URL)” options from Advanced settings section of your qTranslate plugin settings page.
I’ve solved it by adding 2 menu items on for spanish and for english and french. Then I leave empty the “Navigation label” in one language in each of them. When there’s no navigation label wordpress doesn’t “paint” the menu item and thus when my website is presented in Spanish the “English link item” doesn’t appear and when I have the website in English it happends the same with the spanish menu item.