Skip to content

Instantly share code, notes, and snippets.

@arvi
Created September 6, 2016 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvi/56cace261ed2900c84466befdb7d1a0b to your computer and use it in GitHub Desktop.
Save arvi/56cace261ed2900c84466befdb7d1a0b to your computer and use it in GitHub Desktop.
jQuery's i18next counterpart on vanilla js
//translates text to user's preferred language
for (i = 0; i < document.querySelectorAll('[data-i18n]').length; i++) {
document.querySelectorAll('[data-i18n]')[i].innerHTML = i18next.t(document.querySelectorAll('[data-i18n]')[i].getAttribute("data-i18n"));
}
//source: https://github.com/i18next/i18next/issues/398#issuecomment-241671697
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment