MCPcopy
hub / github.com/matheuss/google-translate-api / getCode

Function getCode

languages.js:121–140  ·  view source on GitHub ↗

* Returns the ISO 639-1 code of the desiredLang – if it is supported by Google Translate * @param {string} desiredLang – the name or the code of the desired language * @returns {string|boolean} The ISO 639-1 code of the language or false if the language is not supported

(desiredLang)

Source from the content-addressed store, hash-verified

119 * @returns {string|boolean} The ISO 639-1 code of the language or false if the language is not supported
120 */
121function getCode(desiredLang) {
122 if (!desiredLang) {
123 return false;
124 }
125 desiredLang = desiredLang.toLowerCase();
126
127 if (langs[desiredLang]) {
128 return desiredLang;
129 }
130
131 var keys = Object.keys(langs).filter(function (key) {
132 if (typeof langs[key] !== 'string') {
133 return false;
134 }
135
136 return langs[key].toLowerCase() === desiredLang;
137 });
138
139 return keys[0] || false;
140}
141
142/**
143 * Returns true if the desiredLang is supported by Google Translate and false otherwise

Callers 1

isSupportedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…