1.0.7 • Published 9 months ago

@andrewcaires/translate v1.0.7

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.0.7

9 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago