generaltranslation 1.2.5 → 1.2.7
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/codes/codes.js +1 -1
- package/index.js +4 -5
- package/package.json +1 -1
- package/translate/html.js +9 -11
package/codes/codes.js
CHANGED
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { _getLanguageCode, _getLanguageName } from "./codes/codes.js"
|
|
7
7
|
import _translatePrompt from "./translate/prompts.js"
|
|
8
|
-
import
|
|
8
|
+
import _translateHTML from "./translate/html.js";
|
|
9
9
|
|
|
10
10
|
// ----- CORE CLASS ----- //
|
|
11
11
|
|
|
@@ -29,13 +29,12 @@ export default class GT {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Site I18N
|
|
32
|
-
async
|
|
33
|
-
return await
|
|
32
|
+
async translateHTML({ projectID, defaultLanguage, userLanguage, content }) {
|
|
33
|
+
return await _translateHTML({
|
|
34
34
|
projectID: projectID,
|
|
35
|
-
html: html,
|
|
36
|
-
strings: strings,
|
|
37
35
|
defaultLanguage: defaultLanguage,
|
|
38
36
|
userLanguage: userLanguage,
|
|
37
|
+
content: content,
|
|
39
38
|
config: this
|
|
40
39
|
});
|
|
41
40
|
}
|
package/package.json
CHANGED
package/translate/html.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _translateHTML = async ({
|
|
2
2
|
projectID,
|
|
3
|
-
html,
|
|
4
|
-
strings,
|
|
5
3
|
defaultLanguage,
|
|
6
4
|
userLanguage,
|
|
5
|
+
content,
|
|
7
6
|
config
|
|
8
7
|
}) => {
|
|
9
8
|
|
|
@@ -17,7 +16,7 @@ const _createI18N = async ({
|
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
try {
|
|
20
|
-
const response = await fetch(
|
|
19
|
+
const response = await fetch(`https://html.gtx.dev`, {
|
|
21
20
|
method: 'POST',
|
|
22
21
|
headers: {
|
|
23
22
|
'Content-Type': 'application/json',
|
|
@@ -25,12 +24,11 @@ const _createI18N = async ({
|
|
|
25
24
|
},
|
|
26
25
|
body: JSON.stringify({
|
|
27
26
|
projectID: projectID,
|
|
28
|
-
html: html,
|
|
29
|
-
strings: strings,
|
|
30
27
|
defaultLanguage: defaultLanguage,
|
|
31
|
-
userLanguage: userLanguage
|
|
28
|
+
userLanguage: userLanguage,
|
|
29
|
+
content: content
|
|
32
30
|
})
|
|
33
|
-
})
|
|
31
|
+
});
|
|
34
32
|
if (!response.ok) {
|
|
35
33
|
const result = await response.text();
|
|
36
34
|
throw new Error(`${result || response.status}`);
|
|
@@ -39,9 +37,9 @@ const _createI18N = async ({
|
|
|
39
37
|
return result;
|
|
40
38
|
}
|
|
41
39
|
} catch (error) {
|
|
42
|
-
console.error(error)
|
|
43
|
-
return
|
|
40
|
+
console.error(error);
|
|
41
|
+
return {};
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
}
|
|
47
|
-
export default
|
|
45
|
+
export default _translateHTML;
|