generaltranslation 2.0.19 → 2.0.21

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/README.md CHANGED
@@ -28,11 +28,11 @@ import GT from 'generaltranslation'
28
28
  const gt = new GT()
29
29
  ```
30
30
 
31
- ## Convert between languages and ISO-639 codes
31
+ ## Convert between languages and BCP 47 language tags
32
32
 
33
33
  ### getLanguageName(codes)
34
34
 
35
- Returns a language name from an ISO-639 language code, or an array of codes. Compatible with ISO-3166 regions and ISO-15924 scripts common in browser languages.
35
+ Returns a language name from a BCP 47 language tag, or an array of tags.
36
36
 
37
37
  ```
38
38
  const language1 = getLanguageName('en');
@@ -47,7 +47,7 @@ console.log(languages) // ['French', 'Mandarin Chinese']
47
47
 
48
48
  ### getLanguageObject(codes)
49
49
 
50
- Returns a language object, or array of language objects, each containing a language, script, and region from an ISO-639 language code, or an array of codes. Compatible with ISO-3166 regions and ISO-15924 scripts common in browser languages.
50
+ Returns a language object, or array of language objects, each containing the English name of a language, script, and region.
51
51
 
52
52
  ```
53
53
  const languageObject = getLanguageCode('en');
@@ -59,7 +59,7 @@ console.log(codes) // [{ "language": "Chinese", "script": "Han (simplified)", "r
59
59
 
60
60
  ### getLanguageCode(languages)
61
61
 
62
- Returns an ISO-639 code from a language name or an array of language names.
62
+ Returns a BCP 47 language tag from a language name or an array of language names.
63
63
 
64
64
  ```
65
65
  const code = getLanguageCode('English');
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Standardizes a given language code.
2
+ * Ensures correct capitalization and formatting of a language code.
3
+ * @param {string} code - The language-country-script code to standardize.
4
+ * @returns {string} A BCP 47 language tag.
3
5
  */
4
6
  declare function _standardizeLanguageCode(code: string): string;
5
7
  /**
@@ -34,7 +34,9 @@ const Predefined_json_1 = __importDefault(require("./predefined/Predefined.json"
34
34
  const Predefined = Predefined_json_1.default;
35
35
  // ----- VALIDITY CHECKS ----- //
36
36
  /**
37
- * Standardizes a given language code.
37
+ * Ensures correct capitalization and formatting of a language code.
38
+ * @param {string} code - The language-country-script code to standardize.
39
+ * @returns {string} A BCP 47 language tag.
38
40
  */
39
41
  function _standardizeLanguageCode(code) {
40
42
  if (!code || typeof code !== 'string')
@@ -96,10 +98,10 @@ const _mapCodeToLanguage = (code) => {
96
98
  return '';
97
99
  };
98
100
  /**
99
- * Returns an ISO 639 code from a language name.
101
+ * Returns a BCP 47 language tag from a language name.
100
102
  * Preferentially returns two-letter codes.
101
103
  * @param {string} language - The language name.
102
- * @returns {string} The ISO 639 code.
104
+ * @returns {string} BCP 47 language tag.
103
105
  */
104
106
  const _mapLanguageToCode = (language) => {
105
107
  language = language === null || language === void 0 ? void 0 : language.toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {