@andrewcaires/translate
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

Dependents (1)

Package Sidebar

Install

npm i @andrewcaires/translate

Weekly Downloads

10

Version

1.1.0

License

MIT

Unpacked Size

7.4 kB

Total Files

7

Last publish

Collaborators

  • andrewcaires