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.
@@ -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
- return locale.baseName === code; // The baseName includes only the canonical language, script, and region
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {