0.1.10 • Published 2 years ago

@sil/locale v0.1.10

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years 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

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.0.3

2 years ago

0.1.1

2 years ago

0.0.2

2 years ago

0.1.8

2 years ago

0.0.9

2 years ago

0.1.7

2 years ago

0.0.8

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.1.6

2 years ago

0.0.7

2 years ago

0.1.5

2 years ago

0.0.1

2 years ago