generaltranslation 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codes/codes.js +6 -2
- package/package.json +1 -1
package/dist/codes/codes.js
CHANGED
|
@@ -38,11 +38,15 @@ const Predefined = Predefined_json_1.default;
|
|
|
38
38
|
* @returns {boolean} - Returns true if valid, false otherwise.
|
|
39
39
|
*/
|
|
40
40
|
function _isValidLanguageCode(code) {
|
|
41
|
-
if (!code)
|
|
41
|
+
if (!code || typeof code !== 'string')
|
|
42
42
|
return false;
|
|
43
43
|
try {
|
|
44
|
+
if (!_mapCodeToLanguage(code.split('-')[0]))
|
|
45
|
+
return false;
|
|
44
46
|
const locale = new Intl.Locale(code);
|
|
45
|
-
|
|
47
|
+
const { language, script, region } = locale;
|
|
48
|
+
const constructedCode = `${language}${script ? '-' + script : ''}${region ? '-' + region : ''}`;
|
|
49
|
+
return constructedCode === code;
|
|
46
50
|
}
|
|
47
51
|
catch (error) {
|
|
48
52
|
return false;
|