I develop a website (in wordpress) that it is intended for users who speak different languages. The main content of the site is the same (not divisible by languages). But the interface of the site (such as menus, and a few other small things) should be in two different languages.
I do not want to use gettext
in PHP
level. Instead, I want to translate certain things at the level of JavaScript
.
Of course I can do an array of words in both languages, mark the html elements that require translation (like: <span translate='true'>Hello world!</span>
) , and when the user presses a button of his language, the script will look for a match of words, and replace the contents of the elements.
But I want to ask, is there a better way to achieve this?