1.1.0 • Published 9 months ago

@andrewcaires/translate v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

npm downloads size license

Translate

Plugin for translation

Installation

npm i @andrewcaires/translate

Usage

import { Translate } from "@andrewcaires/translate";

Translate.options({
  locale: "en",
  locales: {
      "en": {
        "Hello world": "Hello world",
      },
      "pt": {
        "Hello world": "Olá Mundo",
      },
  },
});

console.log(Translate.to("Hello world"));

Api

  • translate Translate a message
const text = Translate.to("Hello world");

const text = Translate.to("Hello {name}", { name: "John" });

const text = Translate.to("Hello {name}", { name: "John" }, "en");
  • getLocale Get language for translation
const locale = Translate.getLocale();
  • setLocale Set language for translation
Translate.setLocale("en");

Links

License

1.1.0

9 months ago

1.0.8

1 year ago

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago