generaltranslation 2.0.16 → 2.0.17
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 +1 -1
- package/dist/codes/codes.js +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/translation/_intl.d.ts +3 -3
- package/dist/translation/_intl.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ console.log(result.translation); // 'Hola'
|
|
|
147
147
|
|
|
148
148
|
- A promise that resolves to an object containing the translated content and optional error information.
|
|
149
149
|
|
|
150
|
-
#### `intl(content: string, targetLanguage: string, projectID?: string, metadata?: {
|
|
150
|
+
#### `intl(content: string, targetLanguage: string, projectID?: string, metadata?: { dictionaryName?: string, notes?: string, [key: string]: any }): Promise<{ translation: string, error?: Error | unknown }>`
|
|
151
151
|
|
|
152
152
|
Translates a string and caches it for use in a public project.
|
|
153
153
|
|
package/dist/codes/codes.js
CHANGED
|
@@ -134,12 +134,13 @@ function _getLanguageObject(codes) {
|
|
|
134
134
|
* @returns {LanguageObject|null} The language object.
|
|
135
135
|
*/
|
|
136
136
|
const _handleGetLanguageObject = (code) => {
|
|
137
|
+
var _a, _b;
|
|
137
138
|
try {
|
|
138
139
|
const locale = new Intl.Locale(code);
|
|
139
140
|
let languageObject = {
|
|
140
141
|
language: _mapCodeToLanguage(locale.language) || '',
|
|
141
|
-
script: locale.script ? _mapCodeToScript(locale.script) : ''
|
|
142
|
-
region: locale.region ? _mapCodeToRegion(locale.region) : ''
|
|
142
|
+
script: locale.script ? (_a = _mapCodeToScript(locale.script)) !== null && _a !== void 0 ? _a : '' : '',
|
|
143
|
+
region: locale.region ? (_b = _mapCodeToRegion(locale.region)) !== null && _b !== void 0 ? _b : '' : ''
|
|
143
144
|
};
|
|
144
145
|
return languageObject.language ? languageObject : null;
|
|
145
146
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,12 +46,12 @@ declare class GT {
|
|
|
46
46
|
* @param {string} content - A string to translate.
|
|
47
47
|
* @param {string} targetLanguage - The target language for the translation.
|
|
48
48
|
* @param {string} projectID - The ID of the project.
|
|
49
|
-
* @param {
|
|
49
|
+
* @param {dictionaryName?: string, context?: string, [key: string]: any }} metadata - Additional metadata for the translation request.
|
|
50
50
|
* @returns {Promise<{ translation: string, error?: Error | unknown }>} The translated content with optional error information.
|
|
51
51
|
*/
|
|
52
52
|
intl(content: string, targetLanguage: string, projectID?: string, metadata?: {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
dictionaryName?: string;
|
|
54
|
+
context?: string;
|
|
55
55
|
[key: string]: any;
|
|
56
56
|
}): Promise<{
|
|
57
57
|
translation: string;
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ class GT {
|
|
|
68
68
|
* @param {string} content - A string to translate.
|
|
69
69
|
* @param {string} targetLanguage - The target language for the translation.
|
|
70
70
|
* @param {string} projectID - The ID of the project.
|
|
71
|
-
* @param {
|
|
71
|
+
* @param {dictionaryName?: string, context?: string, [key: string]: any }} metadata - Additional metadata for the translation request.
|
|
72
72
|
* @returns {Promise<{ translation: string, error?: Error | unknown }>} The translated content with optional error information.
|
|
73
73
|
*/
|
|
74
74
|
intl(content, targetLanguage, projectID, metadata) {
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* @param {string} content - The content to translate.
|
|
5
5
|
* @param {string} targetLanguage - The target language for the translation.
|
|
6
6
|
* @param {string} projectID - The ID of the project
|
|
7
|
-
* @param {{
|
|
7
|
+
* @param {{ dictionaryName?: string, notes?: string, [key: string]: any }} metadata - Additional metadata for the translation request.
|
|
8
8
|
* @returns {Promise<{ translation: string, error?: Error | unknown }>} - The translated content with optional error information.
|
|
9
9
|
*/
|
|
10
10
|
export default function _translate(gt: {
|
|
11
11
|
baseURL: string;
|
|
12
12
|
apiKey: string;
|
|
13
13
|
}, content: string, targetLanguage: string, projectID: string, metadata: {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
dictionaryName?: string;
|
|
15
|
+
context?: string;
|
|
16
16
|
[key: string]: any;
|
|
17
17
|
}): Promise<{
|
|
18
18
|
translation: string;
|
|
@@ -16,7 +16,7 @@ exports.default = _translate;
|
|
|
16
16
|
* @param {string} content - The content to translate.
|
|
17
17
|
* @param {string} targetLanguage - The target language for the translation.
|
|
18
18
|
* @param {string} projectID - The ID of the project
|
|
19
|
-
* @param {{
|
|
19
|
+
* @param {{ dictionaryName?: string, notes?: string, [key: string]: any }} metadata - Additional metadata for the translation request.
|
|
20
20
|
* @returns {Promise<{ translation: string, error?: Error | unknown }>} - The translated content with optional error information.
|
|
21
21
|
*/
|
|
22
22
|
function _translate(gt, content, targetLanguage, projectID, metadata) {
|