@andrewcaires/translate
v1.1.0
Published
Plugin for translation
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
translateTranslate 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");getLocaleGet language for translation
const locale = Translate.getLocale();setLocaleSet language for translation
Translate.setLocale("en");