On this page
- Create additional switcher
- Create languages links
- Switch to another language
- Create currencies links with active state
- Switch to another currency
- React on the opened dropdown switcher
- Take action only if certain language is chosen
- Format product price
- Show price in your own format
- Save user last language before language switching
- Track switching the currency with Google Analytics
- Translate third-party app's static content
Create additional switcher
Create languages links
Switch to another language
Using inline javascript code
or using event listener
var links = document.querySelectorAll(".language-link");
for(var i = 0, count = links.length; i < count; i++) {
links[i].addEventListener("click", function(e) {
var code = e.currentTarget.dataset.code;
LangShopSDK.switchLanguage(code);
});
}
Create currencies links with active state
Switch to another currency
var selector = document.getElementById("simple-selector");
selector.addEventListener("change", function(e) {
var code = e.currentTarget.value;
LangShopSDK.switchCurrency(code);
});
React on the opened dropdown switcher
Take action only if certain language is chosen
Format product price
Show price in your own format
Save user last language before language switched
Track switching the currency with Google Analytics
Translate third-party app's static content
The translations process takes some time. In this case, we recommend creating a translatable container for all needed locales as fast as possible.
Then you can receive strings translations during the render process.