google-cloud-translation-languages
v0.1.6
Published
Maps supported languages by Google Cloud Translation
Downloads
27
Maintainers
Readme
Google Cloud Translation Languages
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.