Get started with i18next-locize-backend CDN

MIT licensed

Node.js backend for i18next, Locize translation management.

Tags:
  • i18next
  • i18next-backend

Stable version

Copied!

How to start using i18next-locize-backend CDN


<!DOCTYPE html>
<html>
<head>
  <script src="https://unpkg.com/i18next@latest/i18next.min.js"></script>
  <script src="https://cdn.cdnhub.io/i18next-locize-backend/6.4.1/i18nextLocizeBackend.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/locize@latest/locize.min.js"></script>
  <script src="path/to/your/locales.json"></script>
  <title>Get started with i18next-locize-backend CDN - cdnhub.io</title>
</head>
<body>
  <button id="change-language">Change Language</button>
  <script>
    const i18n = new I18n({
      backend: {
        load: (namespace, callback) => {
          i18nextLocizeBackend.load(namespace, callback);
        },
        addResource: (namespace, key, value) => {
          i18next.addResource(namespace, key, value);
        },
        addLng: (language, ns, callback) => {
          i18next.init(ns, null, () => {
            callback();
          });
        },
      },
      init: () => {},
      lng: 'en',
      resources: {},
    });

    document.getElementById('change-language').addEventListener('click', () => {
      i18n.changeLanguage('fr').then(() => {
        console.log(i18n.t('welcome'));
      });
    });
  </script>
</body>
</html>

All versions