Skip to content

Latest commit

History

History
77 lines (50 loc) 路 2.49 KB

README.md

File metadata and controls

77 lines (50 loc) 路 2.49 KB

Microsoft Translator Languages

Build Status NPM Downloads

Maps the languages currently supported by operations of the Microsoft Cognitive Translator service. The data auto-updates every 3 days, if needed.

馃槝 Maintainer: @eliottvincent

Who uses it?

Crisp

馃憢 You use this library and you want to be listed there? Contact us.

Usage

const { isLanguageSupported } = require("microsoft-translator-languages");

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

API

Access to supported languages

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.

Check if a language is supported

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

  • code must be a BCP 47 language tag, as per ISO 3166-1
  • scope must be either translation, transliteration or dictionary (defaults to translation)
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

License

microsoft-translator-languages is released under the MIT License. See the bundled LICENSE file for details.