Maps the languages currently supported by operations of the Microsoft Cognitive Translator service. The data auto-updates every 3 days, if needed.
😘 Maintainer: @eliottvincent
Crisp |
👋 You use this library and you want to be listed there? Contact us.
const { isLanguageSupported } = require("microsoft-translator-languages");
console.log(isLanguageSupported("en", "translation"));
// true
The raw sets of supported languages, as returned by Microsoft Translator API, are made accessible:
const { translation } = require("microsoft-translator-languages");
console.log(translation);
// {af: {…}, am: {…}, ar: {…}, as: {…}, az: {…}, …}
// OR
const microsoftTranslator = require("microsoft-translator-languages");
console.log(microsoftTranslator.dataTranslation);
// {af: {…}, am: {…}, ar: {…}, as: {…}, az: {…}, …}
Supported scopes are: translation
, transliteration
& dictionary
.
isLanguageSupported(code, scope)
returns whether a language is supported or not:
code
must be a BCP 47 language tag, as per ISO 3166-1scope
must be eithertranslation
,transliteration
ordictionary
(defaults totranslation
)
const { isLanguageSupported } = require("microsoft-translator-languages");
console.log(isLanguageSupported("en"));
// true
console.log(isLanguageSupported("en", "translation"));
// true
console.log(isLanguageSupported("en", "transliteration"));
// false
console.log(isLanguageSupported("en", "dictionary"));
// true
microsoft-translator-languages is released under the MIT License. See the bundled LICENSE file for details.