@andrewcaires/translate
v1.1.0
Published
Plugin for translation
Downloads
18
Readme
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");