0.1.3 • Published 11 months ago

google-cloud-translation-languages v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Google Cloud Translation Languages

Build Status Version Downloads

Maps the languages currently supported by operations of the Google Cloud Translation API. The data auto-updates every 3 days, if needed.

Usage

const { isLanguageSupported } = require("google-cloud-translation-languages");

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

API

Access to supported languages

The raw sets of supported languages, as returned by Google Cloud Translation API, are made accessible:

const { languages } = require("google-cloud-translation-languages");

console.log(languages);
// [{language: 'hu', name: 'Hungarian'}, {…}, {…}, …]

// OR
const gct = require("google-cloud-translation-languages");

console.log(gct.dataLanguages);
// [{language: 'hu', name: 'Hungarian'}, {…}, {…}, …]

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("google-cloud-translation-languages");

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

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

License

google-cloud-translation-languages is released under the MIT License. See the bundled LICENSE file for details.