0

I have completed a single page wordpress theme. I have to add the feature of multiple languages to it. So what I have decided is to make the user create a page such as about-gr Which gr stands for Germany. The website has a navigation menu, which loads the content of the page via ajax. in my jqueyr ajax call, if they selected germany as the language i append -gr to the link and load the page about-gr. it works fine. But the issue is how can I change the language of the menu.

*Should the user create multiple menus for each language and load the relevant menu? I find this difficult to handle for the user. Is there any other way of changing the language of the menu? *

2

Should the user create multiple menus for each language and load the relevant menu?

Yes

Obviously menus are part of the content of the site, and no one else except for the site owner can decide what will be the content.

I find this difficult to handle for the user. Is there any other way of changing the language of the menu?

Sure, localization is hard. You can use the google translate API to translate automatically. IMO this approach is not recommended to any site that don't want to be ridiculed (google translate is good enough to give a general meaning of phrases, but from time to time it will give you a funny translation that is out of context).

side note: you are reinventing the wheel. This kind of localizations is usually solved by using dedicated plugins like WPML or by setting different sites (maybe over a network installation) per each language.

  • +1 for using WPML -- there are many complexities to l10n and WPML has already had to deal with them. – webaware Dec 15 '13 at 7:30
0

Best way is if your menu is writen in some template *.php file. Then you can use

<li><?php _e("Main", "your_theme_id"); ?>

instead of

<li>Main</li>

and make locale file. I did this like with using of WCM Lang Switch (User Language Switch plugin).

But if you have not a big list things that you need to translate, you can use just function and return needed value. It's a very simple way.

And the next, you can use JS. Great and power way. For example check if is *-gr page, then change all your menus htmlinner and titles with german. Also with this way you can change link's destinations, link colors and more other this. It work and if you added menu with build in wordpress functions. Don't forget to add this js function to a single *.js file and in header.php put loading of this js so hight as you can.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.