javascript – Russian to English website translation button


How can you implement a button for switching the site language in the form of an icon with the letters "EN", upon clicking on which the entire site would "turn" into an English-language one?

I know about the possibility of using the Google Translate service, but I think that this option is too clumsy.


If done correctly, you need to use third-party libraries for translation. Those. the entire text of the site is stored in the "dictionary", and when you press the button, the required dictionary is selected, the text on the site changes.

There are a lot of such libraries. You need to sit and dig deeper.

Option two – google translator API

Option three (if the site is very, very small), just make duplicate pages with replacement text.

If the question was about how exactly to implement the button itself, everything is simple. You create two things with different id. After that you hang up the event handler with JS. elementButton = document.getElementById (id);

You hang a handler on it – elementButtom.addEventListener ("click", function () {function body});

If you do it with links, you don't need to process it at all. You just throw links to translated pages.

Scroll to Top