npm.io
0.1.4 • Published 4 years agoCLI

text-localizer

Licence
MIT
Version
0.1.4
Deps
0
Size
30 kB
Vulns
0
Weekly
0
Stars
24

Text Localizer

Tutorial

Tutorial can be found here.

Usage

import { TextLocalizer } from 'text-localizer';
import { fetchItTranslations } from './l10n/it';

(async () => {
  const localizer = new TextLocalizer({
    us: import('./l10n/us.json'),
    gb: import('./l10n/gb'),
    it: fetchItTranslations,
  });

  await localizer.setOptions({
    language: 'gb',
  });

  const translations = localizer.translations;

  console.log(translations.question); // "Which is your favourite cat?"

  console.log(
    localizer.formatTranslation(translations.help, { topic: 'Text Localizer' })
  );
})();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Keywords