Does anyone know how to use getCurrentLang() to know the language code for a multi-language website?
I currently use Weglot for the translation and there is not much instruction on how to use getCurrentLang() on their site: Javascript functions - Weglot
Once you know it’s working smoothly, you can hide it ( display: none on the style panel, not visibility: hidden on the settings panel, they’re very different ).
<script defer>
window.addEventListener('DOMContentLoaded', (event) => {
let language = Weglot.getCurrentLang();
let inputField = document.getElementById('lang-code');
if (inputField) {
inputField.value = language;
}
});
</script>
You’ll have to check with Weglot on getting the language code if you’re using their service for that. If you need help researching that bit, you can direct message me and I’ll send you my rates.
For the logic fallback, you just set the fallback value in logic. Logic docs cover that, click the little yellow icon.
Not sure what your design goal here is, if you have a default language when Weglot does not have one selected, I’d just set that in the field and/or as the fallback.