sample.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <html>
  2. <head>
  3. <script src="./i18next.min.js" ></script>
  4. <script src="https://cdnjs.cloudflare.com/ajax/libs/i18next-browser-languagedetector/1.0.1/i18nextBrowserLanguageDetector.min.js" ></script>
  5. </head>
  6. <body>
  7. <div>open console</div>
  8. <script>
  9. // use plugins and options as needed, for options, detail see
  10. // http://i18next.com/docs/
  11. i18next
  12. .use(window.i18nextBrowserLanguageDetector)
  13. .init({
  14. //lng: 'en', // evtl. use language-detector https://github.com/i18next/i18next-browser-languageDetector
  15. resources: { // evtl. load via xhr https://github.com/i18next/i18next-xhr-backend
  16. en: {
  17. translation: {
  18. input: {
  19. placeholder: "a placeholder"
  20. },
  21. nav: {
  22. home: 'Home',
  23. page1: 'Page One',
  24. page2: 'Page Two'
  25. }
  26. }
  27. }
  28. },
  29. debug: true
  30. }, function(err, t) {
  31. console.warn(i18next.t('input.placeholder'));
  32. console.warn(i18next.t('nav.home'));
  33. console.warn(i18next);
  34. });
  35. </script>
  36. </body>
  37. </html>