I actually ended up re-doing the whole thing. Was planning on doing a post about it, and it needs some cleanup before working on more than two languages, but this is the idea:
Paste attached code in the Footer Code section of your site’s settings
Change the DEFAULT_LANG to your own language (in ISO 639-1)
Edit the languages in getELementsByClassName in changeLangTo(lang). (These are the class names we’ll be using later)
Save
In the Designer, structure content into div blocks depending on which language content they contain. No [[en]]English[[sv]]Svenska-stuff. So if you’ve got a text block and a button that have different text for different languages, wrap them together in a div block and give that div block the class english, then you make a duplicate with the translated content and give it the class swedish.
Make sure to never style the swedish and english classes, cause they will be used for a wide variety of content
Changing language
Make a button or link block
Under Custom Attributes in the Settings (cog wheel), press the plus sign and set Name to whenClick and Value to setLang(‘en’).
Make sure to replace the en above with the ISO 639-1 code for whichever language you want to change to
Code
Mansi Jani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.