Adding a language switch to your WordPress site does not always require a heavy plugin. With a little JavaScript and jQuery you can swap text on the fly and give visitors a lightweight translation option. This guide walks through the approach with copy ready code.
Learn how to add simple, lightweight translation to your WordPress site using plain JavaScript and jQuery no heavy plugins required. In this tutorial, I’ll walk through the custom code I wrote, show you how it works, and explain how you can easily adapt it to translate your own theme content.
Delay to ensure the content is rendered if it's being generated by shortcode
Attach click event to the button
How it works
The script stores translations for each phrase and updates the matching elements when a visitor picks a language. jQuery makes it easy to select and replace the text, while your original markup stays intact. Because it runs in the browser, switching is instant.
Tips and customization
- Keep your translation list organized by phrase.
- Remember the chosen language so it persists across pages.
- Use it for small sites, and a full plugin for large multilingual ones.
FAQ
Is this a full multilingual solution?
It is a lightweight approach best for small sites. For large sites, a dedicated translation plugin is better.
Is it good for SEO?
Client side switching is limited for SEO. For indexed translations, use a proper multilingual plugin.
