1.0.12 • Published 10 months ago

@relocale/i18n v1.0.12

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
10 months ago

Relocale

Getting started

Library for localization and internationalization.

Advantages

  1. The size is 10 times smaller than in i18next
  2. Works with all possible frameworks (React, Next.js, Vue itc.) and in pure javascript
  3. Supports SSR, SSG

Init

import { init } from '@relocale/i18n';
const lang = 'en';

const resources = {
  en: {
    // ...some keys
  },
  de: {
    // ...some keys
  }
};

const onMissingKey = (missingKey) => {
  console.log(`Missing key: ${missingKey}`);
}

// sync operation
init({ lang, resources, onMissingKey });

Usage

import { t } from '@relocale/i18n';

// without params
t`some-key`
// or
t('some-key')
// or with nesting 
t`key1.key2.key3`

// with params
t('hi', { username: 'Garry' }) // Hi Garry

Translations with params

const resources = {
  en: {
    hi: 'Hi {{username}}'
  },
};

Change language

import { changeLang, getLang } from '@relocale/i18n';

const newLang = 'fr';

changeLang(newLang);

getLang(); // fr
1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago