0.1.10 • Published 8 months ago

@sil/locale v0.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Locale

A clean and simple thing to use translations.

Install

npm install @sil/locale

Usage

Create a file locale.ts in your project. In this file;

In this file you include all your languages, you import your content and define the locales. This will automatically create a state which can be imported/used throughout your project.

import { createLocale } from "@sil/locale";

import EN from "./data/en";
import NL from "./data/nl";
import MT from "./data/mt";

const Languages = {
  AUTO: "auto",
  EN: "EN_uk",
  NL: "NL_nl",
  MT: "MT_mt",
};

const localeData = {
  [Languages.EN]: EN,
  [Languages.NL]: NL,
  [Languages.MT]: MT,
};

const { t, locales, currentLocale, state } = createLocale({
  locales: Languages,
  locale: Languages.AUTO,
  fallbackLocale: Languages.EN,
  messages: localeData,
});

export { t, locales, currentLocale, state };

Example Content file;

const copy = {
    hello: "Hello"
};
export default copy;
``
0.1.10

8 months ago

0.0.10

11 months ago

0.0.11

11 months ago

0.0.12

11 months ago

0.1.0

11 months ago

0.1.2

11 months ago

0.0.3

11 months ago

0.1.1

11 months ago

0.0.2

11 months ago

0.1.8

11 months ago

0.0.9

11 months ago

0.1.7

11 months ago

0.0.8

11 months ago

0.1.9

11 months ago

0.1.4

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.1.6

11 months ago

0.0.7

11 months ago

0.1.5

11 months ago

0.0.1

11 months ago