1.0.2 ā€¢ Published 1 year ago

mirage-translate-languages v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Mirage Translate Languages

Build Status NPM Downloads

šŸ”¤ Maps the languages currently supported by the Mirage Translate API endpoint. The data auto-updates every 3 days, if needed.

Copyright 2023 Crisp IM SAS. See LICENSE for copying information.

šŸ˜˜ Maintainer: @eliottvincent

Usage

const { isLanguageSupported } = require("mirage-translate-languages");

console.log(isLanguageSupported("en"));
// true

API

Access to supported languages

The raw set of supported languages, as returned by the Mirage Translate API, is made accessible:

const { languages } = require("mirage-translate-languages");

console.log(languages);
// {af: {ā€¦}, am: {ā€¦}, ar: {ā€¦}, as: {ā€¦}, az: {ā€¦}, ā€¦}

// OR
const mirageTranslate = require("mirage-translate-languages");

console.log(mirageTranslate.dataLanguages);
// {af: {ā€¦}, am: {ā€¦}, ar: {ā€¦}, as: {ā€¦}, az: {ā€¦}, ā€¦}

Check if a language is supported

isLanguageSupported(code) returns whether a language is supported or not:

  • code must be a BCP 47 language tag, as per ISO 3166-1
const { isLanguageSupported } = require("mirage-translate-languages");

console.log(isLanguageSupported("en"));
// true