File: sample.html

package info (click to toggle)
node-i18next 23.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,780 kB
  • sloc: javascript: 13,315; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<html>
  <head>
    <script src="./i18next.min.js" ></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/i18next-browser-languagedetector/7.0.2/i18nextBrowserLanguageDetector.min.js" ></script>
  </head>

  <body>

    <div>open console</div>

    <script>
      // use plugins and options as needed, for options, detail see
      // - https://www.i18next.com/overview/plugins-and-utils
      // - https://www.i18next.com/overview/configuration-options
      i18next
        .use(window.i18nextBrowserLanguageDetector)
        .init({
          fallbackLng: 'en',
          //lng: 'en', // evtl. use language-detector https://github.com/i18next/i18next-browser-languageDetector
          resources: { // evtl. load via http https://github.com/i18next/i18next-http-backend
            en: {
              translation: {
                input: {
                  placeholder: "a placeholder"
                },
                nav: {
                  home: 'Home',
                  page1: 'Page One',
                  page2: 'Page Two'
                }
              }
            }
          },
          debug: true
        }, function(err, t) {
          var fixedT = i18next.getFixedT(null, null);
          console.warn(fixedT('nav.page3', 'support'), fixedT('nav.page3', 'support') === 'support');
          console.warn(i18next.t('input.placeholder'), i18next.t('input.placeholder') === 'a placeholder');
          console.warn(i18next.t('nav.home'), i18next.t('nav.home') === 'Home');
          console.warn(i18next);
        });
    </script>

  </body>

</html>