@leancodepl/intl 9.7.2 → 9.7.4
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/CHANGELOG.md +37 -0
- package/LICENSE +201 -0
- package/README.md +68 -7
- package/{src → dist}/TranslationsServiceClient.d.ts +9 -1
- package/dist/TranslationsServiceClient.d.ts.map +1 -0
- package/dist/bin.cjs +2 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +103 -0
- package/{src → dist}/commands/diff.d.ts +3 -2
- package/dist/commands/diff.d.ts.map +1 -0
- package/{src → dist}/commands/download.d.ts +3 -2
- package/dist/commands/download.d.ts.map +1 -0
- package/{src → dist}/commands/local.d.ts +3 -2
- package/dist/commands/local.d.ts.map +1 -0
- package/{src → dist}/commands/sync.d.ts +3 -2
- package/dist/commands/sync.d.ts.map +1 -0
- package/{src → dist}/commands/upload.d.ts +3 -2
- package/dist/commands/upload.d.ts.map +1 -0
- package/{src → dist}/formatjs.d.ts +1 -0
- package/dist/formatjs.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/loadConfig.d.ts +12 -0
- package/dist/loadConfig.d.ts.map +1 -0
- package/dist/logger.d.ts +9 -0
- package/dist/logger.d.ts.map +1 -0
- package/{src → dist}/mergeWithEnv.d.ts +1 -0
- package/dist/mergeWithEnv.d.ts.map +1 -0
- package/dist/mkTranslationsServiceClient-CYeFDsNC.cjs +5 -0
- package/dist/mkTranslationsServiceClient-D62VGNcU.js +1578 -0
- package/{src → dist}/mkTranslationsServiceClient.d.ts +2 -1
- package/dist/mkTranslationsServiceClient.d.ts.map +1 -0
- package/{src → dist}/poeditor/POEditorClient.d.ts +8 -2
- package/dist/poeditor/POEditorClient.d.ts.map +1 -0
- package/{src → dist}/poeditor/api.generated/api.d.ts +30 -41
- package/dist/poeditor/api.generated/api.d.ts.map +1 -0
- package/{src → dist}/poeditor/api.generated/base.d.ts +3 -13
- package/dist/poeditor/api.generated/base.d.ts.map +1 -0
- package/{src → dist}/poeditor/api.generated/common.d.ts +4 -14
- package/dist/poeditor/api.generated/common.d.ts.map +1 -0
- package/{src → dist}/poeditor/api.generated/configuration.d.ts +1 -0
- package/dist/poeditor/api.generated/configuration.d.ts.map +1 -0
- package/{src → dist}/poeditor/api.generated/index.d.ts +3 -2
- package/dist/poeditor/api.generated/index.d.ts.map +1 -0
- package/{src → dist}/poeditor/generatePoeditorClient.d.ts +1 -0
- package/dist/poeditor/generatePoeditorClient.d.ts.map +1 -0
- package/package.json +25 -7
- package/src/TranslationsServiceClient.js +0 -3
- package/src/TranslationsServiceClient.js.map +0 -1
- package/src/bin.d.ts +0 -2
- package/src/bin.js +0 -129
- package/src/bin.js.map +0 -1
- package/src/commands/diff.js +0 -35
- package/src/commands/diff.js.map +0 -1
- package/src/commands/download.js +0 -39
- package/src/commands/download.js.map +0 -1
- package/src/commands/local.js +0 -117
- package/src/commands/local.js.map +0 -1
- package/src/commands/sync.js +0 -34
- package/src/commands/sync.js.map +0 -1
- package/src/commands/upload.js +0 -32
- package/src/commands/upload.js.map +0 -1
- package/src/formatjs.js +0 -60
- package/src/formatjs.js.map +0 -1
- package/src/index.d.ts +0 -6
- package/src/index.js +0 -16
- package/src/index.js.map +0 -1
- package/src/mergeWithEnv.js +0 -14
- package/src/mergeWithEnv.js.map +0 -1
- package/src/mkTranslationsServiceClient.js +0 -14
- package/src/mkTranslationsServiceClient.js.map +0 -1
- package/src/poeditor/POEditorClient.js +0 -88
- package/src/poeditor/POEditorClient.js.map +0 -1
- package/src/poeditor/api.generated/api.js +0 -2654
- package/src/poeditor/api.generated/api.js.map +0 -1
- package/src/poeditor/api.generated/base.js +0 -69
- package/src/poeditor/api.generated/base.js.map +0 -1
- package/src/poeditor/api.generated/common.js +0 -146
- package/src/poeditor/api.generated/common.js.map +0 -1
- package/src/poeditor/api.generated/configuration.js +0 -100
- package/src/poeditor/api.generated/configuration.js.map +0 -1
- package/src/poeditor/api.generated/index.js +0 -18
- package/src/poeditor/api.generated/index.js.map +0 -1
- package/src/poeditor/generatePoeditorClient.js +0 -54
- package/src/poeditor/generatePoeditorClient.js.map +0 -1
|
@@ -0,0 +1,1578 @@
|
|
|
1
|
+
import J from "@inquirer/checkbox";
|
|
2
|
+
import X from "@inquirer/confirm";
|
|
3
|
+
import { z as V } from "zod/v4";
|
|
4
|
+
import K from "lodash";
|
|
5
|
+
import { readFileSync as E, rmSync as T, mkdtempSync as z, writeFileSync as q, mkdirSync as H } from "node:fs";
|
|
6
|
+
import { join as R } from "node:path";
|
|
7
|
+
import { createCliLogger as Y } from "@leancodepl/logger/cli";
|
|
8
|
+
import { execSync as Q } from "node:child_process";
|
|
9
|
+
import { tmpdir as M } from "node:os";
|
|
10
|
+
import O from "axios";
|
|
11
|
+
function $(a = "src/**/*.{ts,tsx}") {
|
|
12
|
+
const e = R(M(), `messages-${Date.now()}.json`);
|
|
13
|
+
try {
|
|
14
|
+
const t = [
|
|
15
|
+
"npx",
|
|
16
|
+
"@formatjs/cli",
|
|
17
|
+
"extract",
|
|
18
|
+
`"${a}"`,
|
|
19
|
+
"--out-file",
|
|
20
|
+
`"${e}"`,
|
|
21
|
+
"--preserve-whitespace",
|
|
22
|
+
"--extract-source-location"
|
|
23
|
+
].join(" ");
|
|
24
|
+
Q(t);
|
|
25
|
+
const s = E(e, "utf-8");
|
|
26
|
+
return T(e), JSON.parse(s);
|
|
27
|
+
} catch (t) {
|
|
28
|
+
throw new Error(`Failed to extract messages. Error: ${t}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function _({
|
|
32
|
+
inputDir: a,
|
|
33
|
+
outputDir: e,
|
|
34
|
+
options: t = {}
|
|
35
|
+
}) {
|
|
36
|
+
const { ast: s = !0, format: r = "simple" } = t;
|
|
37
|
+
try {
|
|
38
|
+
const o = [
|
|
39
|
+
"npx",
|
|
40
|
+
"@formatjs/cli",
|
|
41
|
+
"compile-folder",
|
|
42
|
+
...s ? ["--ast"] : [],
|
|
43
|
+
"--format",
|
|
44
|
+
r,
|
|
45
|
+
a,
|
|
46
|
+
e
|
|
47
|
+
].join(" ");
|
|
48
|
+
Q(o);
|
|
49
|
+
} catch (o) {
|
|
50
|
+
throw new Error(`Failed to compile translations. Error: ${o}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function F(a = "intl-") {
|
|
54
|
+
return z(R(M(), a));
|
|
55
|
+
}
|
|
56
|
+
function B({
|
|
57
|
+
translations: a,
|
|
58
|
+
language: e,
|
|
59
|
+
tempDir: t
|
|
60
|
+
}) {
|
|
61
|
+
const s = R(t, `${e}.json`);
|
|
62
|
+
return q(s, JSON.stringify(a, null, 2)), s;
|
|
63
|
+
}
|
|
64
|
+
const h = Y(), je = V.object({
|
|
65
|
+
srcPattern: V.string()
|
|
66
|
+
});
|
|
67
|
+
async function Ae({ srcPattern: a, translationsServiceClient: e }) {
|
|
68
|
+
try {
|
|
69
|
+
h.info("Analyzing differences between local and remote translations..."), h.info("Extracting local messages...");
|
|
70
|
+
const t = $(a), s = new Set(Object.keys(t));
|
|
71
|
+
h.info("Fetching remote terms...");
|
|
72
|
+
const r = await e.downloadTerms(), c = [...new Set(r.map((i) => i.term))].filter((i) => !s.has(i)), n = await e.getTranslationsInDefaultLanguage(r);
|
|
73
|
+
if (c.length > 0) {
|
|
74
|
+
h.info(`
|
|
75
|
+
Terms in remote but not used locally (${c.length}):`);
|
|
76
|
+
const i = await J({
|
|
77
|
+
message: "Select terms to remove",
|
|
78
|
+
choices: c.map((p) => {
|
|
79
|
+
const m = n.find((f) => f.term === p)?.translation;
|
|
80
|
+
return { name: `${p} $`, value: p };
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
if (i.length === 0 || !await X({
|
|
84
|
+
message: `Are you sure you want to remove these terms: ${i.join(", ")}?`
|
|
85
|
+
}))
|
|
86
|
+
return;
|
|
87
|
+
const d = r.filter((p) => i.includes(p.term));
|
|
88
|
+
h.info(`
|
|
89
|
+
Removing selected terms from remote...`), await e.removeTerms(d), h.success(`
|
|
90
|
+
Terms removed successfully`);
|
|
91
|
+
} else
|
|
92
|
+
h.info(`
|
|
93
|
+
No unused terms found in remote`);
|
|
94
|
+
} catch (t) {
|
|
95
|
+
h.error("Error in diff command:", t), process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const Se = V.object({
|
|
99
|
+
outputDir: V.string(),
|
|
100
|
+
languages: V.array(V.string())
|
|
101
|
+
});
|
|
102
|
+
async function W({ outputDir: a, languages: e, translationsServiceClient: t }) {
|
|
103
|
+
try {
|
|
104
|
+
h.info("Starting download from translation service..."), h.info(`Downloading translations for languages: ${e.join(", ")}`);
|
|
105
|
+
const s = F("download-");
|
|
106
|
+
try {
|
|
107
|
+
for (const r of e) {
|
|
108
|
+
h.info(`Downloading ${r} translations...`);
|
|
109
|
+
const o = await t.downloadTranslations(r);
|
|
110
|
+
B({ translations: o, language: r, tempDir: s });
|
|
111
|
+
const c = Object.keys(o).length;
|
|
112
|
+
h.info(`Downloaded ${c} translations for ${r}`);
|
|
113
|
+
}
|
|
114
|
+
h.info("Compiling translations..."), H(a, { recursive: !0 }), _({ inputDir: s, outputDir: a }), h.success(`Compiled translations saved to ${a}`);
|
|
115
|
+
} finally {
|
|
116
|
+
T(s, { recursive: !0, force: !0 });
|
|
117
|
+
}
|
|
118
|
+
} catch (s) {
|
|
119
|
+
h.error("Error in download command:", s), process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const be = V.object({
|
|
123
|
+
srcPattern: V.string(),
|
|
124
|
+
outputDir: V.string(),
|
|
125
|
+
defaultLanguage: V.string()
|
|
126
|
+
});
|
|
127
|
+
async function Ue({
|
|
128
|
+
defaultLanguage: a,
|
|
129
|
+
outputDir: e,
|
|
130
|
+
srcPattern: t,
|
|
131
|
+
translationsServiceClient: s
|
|
132
|
+
}) {
|
|
133
|
+
try {
|
|
134
|
+
const r = G({ srcPattern: t, defaultLanguage: a }), o = s ? await Z({ defaultLanguage: a, client: s }) : void 0, c = ee({ extractedTranslations: r, downloadedTranslations: o });
|
|
135
|
+
te({ translations: c, outputDir: e, defaultLanguage: a });
|
|
136
|
+
} catch (r) {
|
|
137
|
+
h.error("Error in local command:", r), process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function G({
|
|
141
|
+
srcPattern: a,
|
|
142
|
+
defaultLanguage: e
|
|
143
|
+
}) {
|
|
144
|
+
h.info("Extracting messages from source files...");
|
|
145
|
+
const t = $(a), s = Object.keys(t).length;
|
|
146
|
+
if (h.info(`Extracted ${s} messages`), s === 0)
|
|
147
|
+
throw h.error("No messages found. Make sure your source files contain formatjs messages."), new Error("No messages found");
|
|
148
|
+
const r = F("local-");
|
|
149
|
+
try {
|
|
150
|
+
const o = {};
|
|
151
|
+
for (const [n, i] of Object.entries(t))
|
|
152
|
+
o[n] = i.defaultMessage;
|
|
153
|
+
B({ translations: o, language: e, tempDir: r }), h.info("Compiling extracted translations...");
|
|
154
|
+
const c = F("compiled-");
|
|
155
|
+
try {
|
|
156
|
+
_({ inputDir: r, outputDir: c });
|
|
157
|
+
const n = R(c, `${e}.json`), i = E(n, "utf-8");
|
|
158
|
+
return JSON.parse(i);
|
|
159
|
+
} finally {
|
|
160
|
+
T(c, { recursive: !0, force: !0 });
|
|
161
|
+
}
|
|
162
|
+
} finally {
|
|
163
|
+
T(r, { recursive: !0, force: !0 });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function Z({
|
|
167
|
+
defaultLanguage: a,
|
|
168
|
+
client: e
|
|
169
|
+
}) {
|
|
170
|
+
try {
|
|
171
|
+
h.info(`Downloading ${a} translations...`);
|
|
172
|
+
const t = await e.downloadTranslations(a), s = Object.keys(t).length;
|
|
173
|
+
if (h.info(`Downloaded ${s} translations`), s === 0)
|
|
174
|
+
return;
|
|
175
|
+
const r = F("download-");
|
|
176
|
+
try {
|
|
177
|
+
B({
|
|
178
|
+
translations: t,
|
|
179
|
+
language: a,
|
|
180
|
+
tempDir: r
|
|
181
|
+
}), h.info("Compiling downloaded translations...");
|
|
182
|
+
const o = F("download-compiled-");
|
|
183
|
+
try {
|
|
184
|
+
_({ inputDir: r, outputDir: o });
|
|
185
|
+
const c = R(o, `${a}.json`), n = E(c, "utf-8");
|
|
186
|
+
return JSON.parse(n);
|
|
187
|
+
} finally {
|
|
188
|
+
T(o, { recursive: !0, force: !0 });
|
|
189
|
+
}
|
|
190
|
+
} finally {
|
|
191
|
+
T(r, { recursive: !0, force: !0 });
|
|
192
|
+
}
|
|
193
|
+
} catch (t) {
|
|
194
|
+
h.warn(`Failed to download translations from translation service: ${t}`), h.info("Using extracted translations only");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function ee({
|
|
199
|
+
extractedTranslations: a,
|
|
200
|
+
downloadedTranslations: e
|
|
201
|
+
}) {
|
|
202
|
+
if (!e)
|
|
203
|
+
return a;
|
|
204
|
+
const t = { ...a, ...e }, s = Object.keys(a).filter((o) => !(o in e)).length, r = Object.keys(e).length;
|
|
205
|
+
return h.info(
|
|
206
|
+
`Merged ${s} extracted terms with ${r} downloaded translations`
|
|
207
|
+
), t;
|
|
208
|
+
}
|
|
209
|
+
function te({
|
|
210
|
+
translations: a,
|
|
211
|
+
outputDir: e,
|
|
212
|
+
defaultLanguage: t
|
|
213
|
+
}) {
|
|
214
|
+
H(e, { recursive: !0 });
|
|
215
|
+
const s = K(a).toPairs().sortBy(0).fromPairs().value(), r = R(e, `${t}.json`);
|
|
216
|
+
q(r, JSON.stringify(s, null, 2)), h.success(`Merged translations saved to ${e}`);
|
|
217
|
+
}
|
|
218
|
+
const ge = V.object({
|
|
219
|
+
srcPattern: V.string(),
|
|
220
|
+
defaultLanguage: V.string()
|
|
221
|
+
});
|
|
222
|
+
async function se({ srcPattern: a, translationsServiceClient: e, defaultLanguage: t }) {
|
|
223
|
+
try {
|
|
224
|
+
h.info("Extracting messages from source files...");
|
|
225
|
+
const s = $(a), r = Object.keys(s).length;
|
|
226
|
+
if (h.info(`Extracted ${r} messages`), r === 0) {
|
|
227
|
+
h.warn("No messages found. Make sure your source files contain formatjs messages.");
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
h.info("Uploading terms to translation service..."), await e.uploadTerms(s), h.info(`Uploading default translations (${t}) to translation service...`), await e.uploadTranslations(s, t), h.success("Upload completed successfully!");
|
|
231
|
+
} catch (s) {
|
|
232
|
+
h.error("Error in upload command:", s), process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const Te = V.object({
|
|
236
|
+
srcPattern: V.string(),
|
|
237
|
+
outputDir: V.string(),
|
|
238
|
+
languages: V.array(V.string()),
|
|
239
|
+
defaultLanguage: V.string()
|
|
240
|
+
});
|
|
241
|
+
async function Re({
|
|
242
|
+
srcPattern: a,
|
|
243
|
+
outputDir: e,
|
|
244
|
+
languages: t,
|
|
245
|
+
translationsServiceClient: s,
|
|
246
|
+
defaultLanguage: r
|
|
247
|
+
}) {
|
|
248
|
+
try {
|
|
249
|
+
h.info("Starting sync operation..."), await se({
|
|
250
|
+
srcPattern: a,
|
|
251
|
+
translationsServiceClient: s,
|
|
252
|
+
defaultLanguage: r
|
|
253
|
+
}), await W({
|
|
254
|
+
outputDir: e,
|
|
255
|
+
languages: t,
|
|
256
|
+
translationsServiceClient: s
|
|
257
|
+
}), h.success("Sync completed successfully!");
|
|
258
|
+
} catch (o) {
|
|
259
|
+
h.error("Error in sync command:", o), process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const v = "https://api.poeditor.com/v2".replace(/\/+$/, "");
|
|
263
|
+
class k {
|
|
264
|
+
constructor(e, t = v, s = O) {
|
|
265
|
+
this.basePath = t, this.axios = s, e && (this.configuration = e, this.basePath = e.basePath ?? t);
|
|
266
|
+
}
|
|
267
|
+
configuration;
|
|
268
|
+
}
|
|
269
|
+
class re extends Error {
|
|
270
|
+
constructor(e, t) {
|
|
271
|
+
super(t), this.field = e, this.name = "RequiredError";
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const x = {}, y = "https://example.com", u = function(a, e, t) {
|
|
275
|
+
if (t == null)
|
|
276
|
+
throw new re(
|
|
277
|
+
e,
|
|
278
|
+
`Required parameter ${e} was null or undefined when calling ${a}.`
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
function L(a, e, t = "") {
|
|
282
|
+
e != null && (typeof e == "object" ? Array.isArray(e) ? e.forEach((s) => L(a, s, t)) : Object.keys(e).forEach(
|
|
283
|
+
(s) => L(a, e[s], `${t}${t !== "" ? "." : ""}${s}`)
|
|
284
|
+
) : a.has(t) ? a.append(t, e) : a.set(t, e));
|
|
285
|
+
}
|
|
286
|
+
const j = function(a, ...e) {
|
|
287
|
+
const t = new URLSearchParams(a.search);
|
|
288
|
+
L(t, e), a.search = t.toString();
|
|
289
|
+
}, A = function(a) {
|
|
290
|
+
return a.pathname + a.search + a.hash;
|
|
291
|
+
}, S = function(a, e, t, s) {
|
|
292
|
+
return (r = e, o = t) => {
|
|
293
|
+
const c = {
|
|
294
|
+
...a.options,
|
|
295
|
+
url: (r.defaults.baseURL ? "" : s?.basePath ?? o) + a.url
|
|
296
|
+
};
|
|
297
|
+
return r.request(c);
|
|
298
|
+
};
|
|
299
|
+
}, ae = function(a) {
|
|
300
|
+
return {
|
|
301
|
+
/**
|
|
302
|
+
* Add Project. More details in the [documentation](https://poeditor.com/docs/api#projects_add).
|
|
303
|
+
* @summary Creates a new project. Returns project details (if successful).
|
|
304
|
+
* @param {string} name
|
|
305
|
+
* @param {string} [apiToken]
|
|
306
|
+
* @param {string} [description]
|
|
307
|
+
* @param {*} [options] Override http request option.
|
|
308
|
+
* @throws {RequiredError}
|
|
309
|
+
*/
|
|
310
|
+
projectsAdd: async (e, t, s, r = {}) => {
|
|
311
|
+
u("projectsAdd", "name", e);
|
|
312
|
+
const o = "/projects/add", c = new URL(o, y);
|
|
313
|
+
let n;
|
|
314
|
+
a && (n = a.baseOptions);
|
|
315
|
+
const i = { method: "POST", ...n, ...r }, l = {}, d = {}, p = new URLSearchParams();
|
|
316
|
+
t !== void 0 && p.set("api_token", t), e !== void 0 && p.set("name", e), s !== void 0 && p.set("description", s), l["Content-Type"] = "application/x-www-form-urlencoded", j(c, d);
|
|
317
|
+
let m = n && n.headers ? n.headers : {};
|
|
318
|
+
return i.headers = { ...l, ...m, ...r.headers }, i.data = p.toString(), {
|
|
319
|
+
url: A(c),
|
|
320
|
+
options: i
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
/**
|
|
324
|
+
* Delete Project. More details in the [documentation](https://poeditor.com/docs/api#projects_delete).
|
|
325
|
+
* @summary Deletes the project from the account. You must be the owner of the project.
|
|
326
|
+
* @param {number} id
|
|
327
|
+
* @param {string} [apiToken]
|
|
328
|
+
* @param {*} [options] Override http request option.
|
|
329
|
+
* @throws {RequiredError}
|
|
330
|
+
*/
|
|
331
|
+
projectsDelete: async (e, t, s = {}) => {
|
|
332
|
+
u("projectsDelete", "id", e);
|
|
333
|
+
const r = "/projects/delete", o = new URL(r, y);
|
|
334
|
+
let c;
|
|
335
|
+
a && (c = a.baseOptions);
|
|
336
|
+
const n = { method: "POST", ...c, ...s }, i = {}, l = {}, d = new URLSearchParams();
|
|
337
|
+
t !== void 0 && d.set("api_token", t), e !== void 0 && d.set("id", e), i["Content-Type"] = "application/x-www-form-urlencoded", j(o, l);
|
|
338
|
+
let p = c && c.headers ? c.headers : {};
|
|
339
|
+
return n.headers = { ...i, ...p, ...s.headers }, n.data = d.toString(), {
|
|
340
|
+
url: A(o),
|
|
341
|
+
options: n
|
|
342
|
+
};
|
|
343
|
+
},
|
|
344
|
+
/**
|
|
345
|
+
* Export. More details in the [documentation](https://poeditor.com/docs/api#projects_export).
|
|
346
|
+
* @summary Returns the link of the file (expires after 10 minutes). The settings inherited from the project will be the ones at the time of the download.
|
|
347
|
+
* @param {number} id
|
|
348
|
+
* @param {string} language
|
|
349
|
+
* @param {ProjectsExportTypeEnum} type
|
|
350
|
+
* @param {string} [apiToken]
|
|
351
|
+
* @param {string} [filters]
|
|
352
|
+
* @param {string} [order]
|
|
353
|
+
* @param {string} [tags]
|
|
354
|
+
* @param {ProjectsExportOptionsEnum} [_options]
|
|
355
|
+
* @param {*} [options] Override http request option.
|
|
356
|
+
* @throws {RequiredError}
|
|
357
|
+
*/
|
|
358
|
+
projectsExport: async (e, t, s, r, o, c, n, i, l = {}) => {
|
|
359
|
+
u("projectsExport", "id", e), u("projectsExport", "language", t), u("projectsExport", "type", s);
|
|
360
|
+
const d = "/projects/export", p = new URL(d, y);
|
|
361
|
+
let m;
|
|
362
|
+
a && (m = a.baseOptions);
|
|
363
|
+
const f = { method: "POST", ...m, ...l }, w = {}, P = {}, b = new URLSearchParams();
|
|
364
|
+
r !== void 0 && b.set("api_token", r), e !== void 0 && b.set("id", e), t !== void 0 && b.set("language", t), s !== void 0 && b.set("type", s), o !== void 0 && b.set("filters", o), c !== void 0 && b.set("order", c), n !== void 0 && b.set("tags", n), i !== void 0 && b.set("options", i), w["Content-Type"] = "application/x-www-form-urlencoded", j(p, P);
|
|
365
|
+
let C = m && m.headers ? m.headers : {};
|
|
366
|
+
return f.headers = { ...w, ...C, ...l.headers }, f.data = b.toString(), {
|
|
367
|
+
url: A(p),
|
|
368
|
+
options: f
|
|
369
|
+
};
|
|
370
|
+
},
|
|
371
|
+
/**
|
|
372
|
+
* List Projects. More details in the [documentation](https://poeditor.com/docs/api#projects_list).
|
|
373
|
+
* @summary Returns the list of projects owned by user.
|
|
374
|
+
* @param {string} apiToken
|
|
375
|
+
* @param {*} [options] Override http request option.
|
|
376
|
+
* @throws {RequiredError}
|
|
377
|
+
*/
|
|
378
|
+
projectsList: async (e, t = {}) => {
|
|
379
|
+
u("projectsList", "apiToken", e);
|
|
380
|
+
const s = "/projects/list", r = new URL(s, y);
|
|
381
|
+
let o;
|
|
382
|
+
a && (o = a.baseOptions);
|
|
383
|
+
const c = { method: "POST", ...o, ...t }, n = {}, i = {}, l = new URLSearchParams();
|
|
384
|
+
e !== void 0 && l.set("api_token", e), n["Content-Type"] = "application/x-www-form-urlencoded", j(r, i);
|
|
385
|
+
let d = o && o.headers ? o.headers : {};
|
|
386
|
+
return c.headers = { ...n, ...d, ...t.headers }, c.data = l.toString(), {
|
|
387
|
+
url: A(r),
|
|
388
|
+
options: c
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
/**
|
|
392
|
+
* Sync Terms. More details in the [documentation](https://poeditor.com/docs/api#projects_sync).
|
|
393
|
+
* @summary Syncs your project with the array you send (terms that are not found in the JSON object will be deleted from project and the new ones added). Please use with caution. If wrong data is sent, existing terms and their translations might be irreversibly lost.
|
|
394
|
+
* @param {number} id
|
|
395
|
+
* @param {string} data JSON format
|
|
396
|
+
* @param {string} [apiToken]
|
|
397
|
+
* @param {*} [options] Override http request option.
|
|
398
|
+
* @throws {RequiredError}
|
|
399
|
+
*/
|
|
400
|
+
projectsSync: async (e, t, s, r = {}) => {
|
|
401
|
+
u("projectsSync", "id", e), u("projectsSync", "data", t);
|
|
402
|
+
const o = "/projects/sync", c = new URL(o, y);
|
|
403
|
+
let n;
|
|
404
|
+
a && (n = a.baseOptions);
|
|
405
|
+
const i = { method: "POST", ...n, ...r }, l = {}, d = {}, p = new URLSearchParams();
|
|
406
|
+
s !== void 0 && p.set("api_token", s), e !== void 0 && p.set("id", e), t !== void 0 && p.set("data", t), l["Content-Type"] = "application/x-www-form-urlencoded", j(c, d);
|
|
407
|
+
let m = n && n.headers ? n.headers : {};
|
|
408
|
+
return i.headers = { ...l, ...m, ...r.headers }, i.data = p.toString(), {
|
|
409
|
+
url: A(c),
|
|
410
|
+
options: i
|
|
411
|
+
};
|
|
412
|
+
},
|
|
413
|
+
/**
|
|
414
|
+
* Update Project Settings. More details in the [documentation](https://poeditor.com/docs/api#projects_update).
|
|
415
|
+
* @summary Updates project settings (name, description, reference language, fallback language). If optional parameters are not sent, their respective fields are not updated.
|
|
416
|
+
* @param {number} id
|
|
417
|
+
* @param {string} [apiToken]
|
|
418
|
+
* @param {string} [name]
|
|
419
|
+
* @param {string} [description]
|
|
420
|
+
* @param {string} [referenceLanguage]
|
|
421
|
+
* @param {string} [fallbackLanguage]
|
|
422
|
+
* @param {*} [options] Override http request option.
|
|
423
|
+
* @throws {RequiredError}
|
|
424
|
+
*/
|
|
425
|
+
projectsUpdate: async (e, t, s, r, o, c, n = {}) => {
|
|
426
|
+
u("projectsUpdate", "id", e);
|
|
427
|
+
const i = "/projects/update", l = new URL(i, y);
|
|
428
|
+
let d;
|
|
429
|
+
a && (d = a.baseOptions);
|
|
430
|
+
const p = { method: "POST", ...d, ...n }, m = {}, f = {}, w = new URLSearchParams();
|
|
431
|
+
t !== void 0 && w.set("api_token", t), e !== void 0 && w.set("id", e), s !== void 0 && w.set("name", s), r !== void 0 && w.set("description", r), o !== void 0 && w.set("reference_language", o), c !== void 0 && w.set("fallback_language", c), m["Content-Type"] = "application/x-www-form-urlencoded", j(l, f);
|
|
432
|
+
let P = d && d.headers ? d.headers : {};
|
|
433
|
+
return p.headers = { ...m, ...P, ...n.headers }, p.data = w.toString(), {
|
|
434
|
+
url: A(l),
|
|
435
|
+
options: p
|
|
436
|
+
};
|
|
437
|
+
},
|
|
438
|
+
/**
|
|
439
|
+
* Upload. More details in the [documentation](https://poeditor.com/docs/api#projects_upload).
|
|
440
|
+
* @summary Updates terms / translations - No more than one request every 20 seconds.
|
|
441
|
+
* @param {ProjectsUploadUpdatingEnum} updating
|
|
442
|
+
* @param {File} file Uploaded file (.po, .xls or any of the supported file formats)
|
|
443
|
+
* @param {string} [apiToken]
|
|
444
|
+
* @param {number} [id]
|
|
445
|
+
* @param {string} [language] The language code (Required only if `updating` is terms_translations or translations). When using `terms_translations` with `.xcstrings` file format, leave it empty to import all the languages in the file.
|
|
446
|
+
* @param {ProjectsUploadOverwriteEnum} [overwrite] Set it to 1 if you want to overwrite translations
|
|
447
|
+
* @param {ProjectsUploadSyncTermsEnum} [syncTerms] Set it to 1 if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added). Ignored if `updating` = translations.
|
|
448
|
+
* @param {string} [tags] Add tags to the project terms; available when updating terms or terms_translations; you can use the following keys: \\\"all\\\" - for the all the imported terms, \\\"new\\\" - for the terms which arent already in the project, \\\"obsolete\\\" - for the terms which are in the project but not in the imported file and \\\"overwritten_translations\\\" - for the terms for which translations change
|
|
449
|
+
* @param {ProjectsUploadReadFromSourceEnum} [readFromSource] For .xliff format only - set it to 1 if you want to import translations from the source tag
|
|
450
|
+
* @param {ProjectsUploadFuzzyTriggerEnum} [fuzzyTrigger] Set it to 1 to mark corresponding translations from the other languages as fuzzy for the updated values
|
|
451
|
+
* @param {*} [options] Override http request option.
|
|
452
|
+
* @throws {RequiredError}
|
|
453
|
+
*/
|
|
454
|
+
projectsUpload: async (e, t, s, r, o, c, n, i, l, d, p = {}) => {
|
|
455
|
+
u("projectsUpload", "updating", e), u("projectsUpload", "file", t);
|
|
456
|
+
const m = "/projects/upload", f = new URL(m, y);
|
|
457
|
+
let w;
|
|
458
|
+
a && (w = a.baseOptions);
|
|
459
|
+
const P = { method: "POST", ...w, ...p }, b = {}, C = {}, U = new (a && a.formDataCtor || FormData)();
|
|
460
|
+
s !== void 0 && U.append("api_token", s), r !== void 0 && U.append("id", r), e !== void 0 && U.append("updating", e), t !== void 0 && U.append("file", t), o !== void 0 && U.append("language", o), c !== void 0 && U.append("overwrite", c), n !== void 0 && U.append("sync_terms", n), i !== void 0 && U.append("tags", i), l !== void 0 && U.append("read_from_source", l), d !== void 0 && U.append("fuzzy_trigger", d), b["Content-Type"] = "multipart/form-data", j(f, C);
|
|
461
|
+
let N = w && w.headers ? w.headers : {};
|
|
462
|
+
return P.headers = { ...b, ...N, ...p.headers }, P.data = U, {
|
|
463
|
+
url: A(f),
|
|
464
|
+
options: P
|
|
465
|
+
};
|
|
466
|
+
},
|
|
467
|
+
/**
|
|
468
|
+
* View Project Details. More details in the [documentation](https://poeditor.com/docs/api#projects_view).
|
|
469
|
+
* @summary Returns projects details
|
|
470
|
+
* @param {number} id
|
|
471
|
+
* @param {string} [apiToken]
|
|
472
|
+
* @param {*} [options] Override http request option.
|
|
473
|
+
* @throws {RequiredError}
|
|
474
|
+
*/
|
|
475
|
+
projectsView: async (e, t, s = {}) => {
|
|
476
|
+
u("projectsView", "id", e);
|
|
477
|
+
const r = "/projects/view", o = new URL(r, y);
|
|
478
|
+
let c;
|
|
479
|
+
a && (c = a.baseOptions);
|
|
480
|
+
const n = { method: "POST", ...c, ...s }, i = {}, l = {}, d = new URLSearchParams();
|
|
481
|
+
t !== void 0 && d.set("api_token", t), e !== void 0 && d.set("id", e), i["Content-Type"] = "application/x-www-form-urlencoded", j(o, l);
|
|
482
|
+
let p = c && c.headers ? c.headers : {};
|
|
483
|
+
return n.headers = { ...i, ...p, ...s.headers }, n.data = d.toString(), {
|
|
484
|
+
url: A(o),
|
|
485
|
+
options: n
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
}, g = function(a) {
|
|
490
|
+
const e = ae(a);
|
|
491
|
+
return {
|
|
492
|
+
/**
|
|
493
|
+
* Add Project. More details in the [documentation](https://poeditor.com/docs/api#projects_add).
|
|
494
|
+
* @summary Creates a new project. Returns project details (if successful).
|
|
495
|
+
* @param {string} name
|
|
496
|
+
* @param {string} [apiToken]
|
|
497
|
+
* @param {string} [description]
|
|
498
|
+
* @param {*} [options] Override http request option.
|
|
499
|
+
* @throws {RequiredError}
|
|
500
|
+
*/
|
|
501
|
+
async projectsAdd(t, s, r, o) {
|
|
502
|
+
const c = await e.projectsAdd(t, s, r, o), n = a?.serverIndex ?? 0, i = x["ProjectsApi.projectsAdd"]?.[n]?.url;
|
|
503
|
+
return (l, d) => S(
|
|
504
|
+
c,
|
|
505
|
+
O,
|
|
506
|
+
v,
|
|
507
|
+
a
|
|
508
|
+
)(l, i || d);
|
|
509
|
+
},
|
|
510
|
+
/**
|
|
511
|
+
* Delete Project. More details in the [documentation](https://poeditor.com/docs/api#projects_delete).
|
|
512
|
+
* @summary Deletes the project from the account. You must be the owner of the project.
|
|
513
|
+
* @param {number} id
|
|
514
|
+
* @param {string} [apiToken]
|
|
515
|
+
* @param {*} [options] Override http request option.
|
|
516
|
+
* @throws {RequiredError}
|
|
517
|
+
*/
|
|
518
|
+
async projectsDelete(t, s, r) {
|
|
519
|
+
const o = await e.projectsDelete(t, s, r), c = a?.serverIndex ?? 0, n = x["ProjectsApi.projectsDelete"]?.[c]?.url;
|
|
520
|
+
return (i, l) => S(
|
|
521
|
+
o,
|
|
522
|
+
O,
|
|
523
|
+
v,
|
|
524
|
+
a
|
|
525
|
+
)(i, n || l);
|
|
526
|
+
},
|
|
527
|
+
/**
|
|
528
|
+
* Export. More details in the [documentation](https://poeditor.com/docs/api#projects_export).
|
|
529
|
+
* @summary Returns the link of the file (expires after 10 minutes). The settings inherited from the project will be the ones at the time of the download.
|
|
530
|
+
* @param {number} id
|
|
531
|
+
* @param {string} language
|
|
532
|
+
* @param {ProjectsExportTypeEnum} type
|
|
533
|
+
* @param {string} [apiToken]
|
|
534
|
+
* @param {string} [filters]
|
|
535
|
+
* @param {string} [order]
|
|
536
|
+
* @param {string} [tags]
|
|
537
|
+
* @param {ProjectsExportOptionsEnum} [_options]
|
|
538
|
+
* @param {*} [options] Override http request option.
|
|
539
|
+
* @throws {RequiredError}
|
|
540
|
+
*/
|
|
541
|
+
async projectsExport(t, s, r, o, c, n, i, l, d) {
|
|
542
|
+
const p = await e.projectsExport(
|
|
543
|
+
t,
|
|
544
|
+
s,
|
|
545
|
+
r,
|
|
546
|
+
o,
|
|
547
|
+
c,
|
|
548
|
+
n,
|
|
549
|
+
i,
|
|
550
|
+
l,
|
|
551
|
+
d
|
|
552
|
+
), m = a?.serverIndex ?? 0, f = x["ProjectsApi.projectsExport"]?.[m]?.url;
|
|
553
|
+
return (w, P) => S(
|
|
554
|
+
p,
|
|
555
|
+
O,
|
|
556
|
+
v,
|
|
557
|
+
a
|
|
558
|
+
)(w, f || P);
|
|
559
|
+
},
|
|
560
|
+
/**
|
|
561
|
+
* List Projects. More details in the [documentation](https://poeditor.com/docs/api#projects_list).
|
|
562
|
+
* @summary Returns the list of projects owned by user.
|
|
563
|
+
* @param {string} apiToken
|
|
564
|
+
* @param {*} [options] Override http request option.
|
|
565
|
+
* @throws {RequiredError}
|
|
566
|
+
*/
|
|
567
|
+
async projectsList(t, s) {
|
|
568
|
+
const r = await e.projectsList(t, s), o = a?.serverIndex ?? 0, c = x["ProjectsApi.projectsList"]?.[o]?.url;
|
|
569
|
+
return (n, i) => S(
|
|
570
|
+
r,
|
|
571
|
+
O,
|
|
572
|
+
v,
|
|
573
|
+
a
|
|
574
|
+
)(n, c || i);
|
|
575
|
+
},
|
|
576
|
+
/**
|
|
577
|
+
* Sync Terms. More details in the [documentation](https://poeditor.com/docs/api#projects_sync).
|
|
578
|
+
* @summary Syncs your project with the array you send (terms that are not found in the JSON object will be deleted from project and the new ones added). Please use with caution. If wrong data is sent, existing terms and their translations might be irreversibly lost.
|
|
579
|
+
* @param {number} id
|
|
580
|
+
* @param {string} data JSON format
|
|
581
|
+
* @param {string} [apiToken]
|
|
582
|
+
* @param {*} [options] Override http request option.
|
|
583
|
+
* @throws {RequiredError}
|
|
584
|
+
*/
|
|
585
|
+
async projectsSync(t, s, r, o) {
|
|
586
|
+
const c = await e.projectsSync(t, s, r, o), n = a?.serverIndex ?? 0, i = x["ProjectsApi.projectsSync"]?.[n]?.url;
|
|
587
|
+
return (l, d) => S(
|
|
588
|
+
c,
|
|
589
|
+
O,
|
|
590
|
+
v,
|
|
591
|
+
a
|
|
592
|
+
)(l, i || d);
|
|
593
|
+
},
|
|
594
|
+
/**
|
|
595
|
+
* Update Project Settings. More details in the [documentation](https://poeditor.com/docs/api#projects_update).
|
|
596
|
+
* @summary Updates project settings (name, description, reference language, fallback language). If optional parameters are not sent, their respective fields are not updated.
|
|
597
|
+
* @param {number} id
|
|
598
|
+
* @param {string} [apiToken]
|
|
599
|
+
* @param {string} [name]
|
|
600
|
+
* @param {string} [description]
|
|
601
|
+
* @param {string} [referenceLanguage]
|
|
602
|
+
* @param {string} [fallbackLanguage]
|
|
603
|
+
* @param {*} [options] Override http request option.
|
|
604
|
+
* @throws {RequiredError}
|
|
605
|
+
*/
|
|
606
|
+
async projectsUpdate(t, s, r, o, c, n, i) {
|
|
607
|
+
const l = await e.projectsUpdate(
|
|
608
|
+
t,
|
|
609
|
+
s,
|
|
610
|
+
r,
|
|
611
|
+
o,
|
|
612
|
+
c,
|
|
613
|
+
n,
|
|
614
|
+
i
|
|
615
|
+
), d = a?.serverIndex ?? 0, p = x["ProjectsApi.projectsUpdate"]?.[d]?.url;
|
|
616
|
+
return (m, f) => S(
|
|
617
|
+
l,
|
|
618
|
+
O,
|
|
619
|
+
v,
|
|
620
|
+
a
|
|
621
|
+
)(m, p || f);
|
|
622
|
+
},
|
|
623
|
+
/**
|
|
624
|
+
* Upload. More details in the [documentation](https://poeditor.com/docs/api#projects_upload).
|
|
625
|
+
* @summary Updates terms / translations - No more than one request every 20 seconds.
|
|
626
|
+
* @param {ProjectsUploadUpdatingEnum} updating
|
|
627
|
+
* @param {File} file Uploaded file (.po, .xls or any of the supported file formats)
|
|
628
|
+
* @param {string} [apiToken]
|
|
629
|
+
* @param {number} [id]
|
|
630
|
+
* @param {string} [language] The language code (Required only if `updating` is terms_translations or translations). When using `terms_translations` with `.xcstrings` file format, leave it empty to import all the languages in the file.
|
|
631
|
+
* @param {ProjectsUploadOverwriteEnum} [overwrite] Set it to 1 if you want to overwrite translations
|
|
632
|
+
* @param {ProjectsUploadSyncTermsEnum} [syncTerms] Set it to 1 if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added). Ignored if `updating` = translations.
|
|
633
|
+
* @param {string} [tags] Add tags to the project terms; available when updating terms or terms_translations; you can use the following keys: \\\"all\\\" - for the all the imported terms, \\\"new\\\" - for the terms which arent already in the project, \\\"obsolete\\\" - for the terms which are in the project but not in the imported file and \\\"overwritten_translations\\\" - for the terms for which translations change
|
|
634
|
+
* @param {ProjectsUploadReadFromSourceEnum} [readFromSource] For .xliff format only - set it to 1 if you want to import translations from the source tag
|
|
635
|
+
* @param {ProjectsUploadFuzzyTriggerEnum} [fuzzyTrigger] Set it to 1 to mark corresponding translations from the other languages as fuzzy for the updated values
|
|
636
|
+
* @param {*} [options] Override http request option.
|
|
637
|
+
* @throws {RequiredError}
|
|
638
|
+
*/
|
|
639
|
+
async projectsUpload(t, s, r, o, c, n, i, l, d, p, m) {
|
|
640
|
+
const f = await e.projectsUpload(
|
|
641
|
+
t,
|
|
642
|
+
s,
|
|
643
|
+
r,
|
|
644
|
+
o,
|
|
645
|
+
c,
|
|
646
|
+
n,
|
|
647
|
+
i,
|
|
648
|
+
l,
|
|
649
|
+
d,
|
|
650
|
+
p,
|
|
651
|
+
m
|
|
652
|
+
), w = a?.serverIndex ?? 0, P = x["ProjectsApi.projectsUpload"]?.[w]?.url;
|
|
653
|
+
return (b, C) => S(
|
|
654
|
+
f,
|
|
655
|
+
O,
|
|
656
|
+
v,
|
|
657
|
+
a
|
|
658
|
+
)(b, P || C);
|
|
659
|
+
},
|
|
660
|
+
/**
|
|
661
|
+
* View Project Details. More details in the [documentation](https://poeditor.com/docs/api#projects_view).
|
|
662
|
+
* @summary Returns projects details
|
|
663
|
+
* @param {number} id
|
|
664
|
+
* @param {string} [apiToken]
|
|
665
|
+
* @param {*} [options] Override http request option.
|
|
666
|
+
* @throws {RequiredError}
|
|
667
|
+
*/
|
|
668
|
+
async projectsView(t, s, r) {
|
|
669
|
+
const o = await e.projectsView(t, s, r), c = a?.serverIndex ?? 0, n = x["ProjectsApi.projectsView"]?.[c]?.url;
|
|
670
|
+
return (i, l) => S(
|
|
671
|
+
o,
|
|
672
|
+
O,
|
|
673
|
+
v,
|
|
674
|
+
a
|
|
675
|
+
)(i, n || l);
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
};
|
|
679
|
+
class oe extends k {
|
|
680
|
+
/**
|
|
681
|
+
* Add Project. More details in the [documentation](https://poeditor.com/docs/api#projects_add).
|
|
682
|
+
* @summary Creates a new project. Returns project details (if successful).
|
|
683
|
+
* @param {string} name
|
|
684
|
+
* @param {string} [apiToken]
|
|
685
|
+
* @param {string} [description]
|
|
686
|
+
* @param {*} [options] Override http request option.
|
|
687
|
+
* @throws {RequiredError}
|
|
688
|
+
* @memberof ProjectsApi
|
|
689
|
+
*/
|
|
690
|
+
projectsAdd(e, t, s, r) {
|
|
691
|
+
return g(this.configuration).projectsAdd(e, t, s, r).then((o) => o(this.axios, this.basePath));
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Delete Project. More details in the [documentation](https://poeditor.com/docs/api#projects_delete).
|
|
695
|
+
* @summary Deletes the project from the account. You must be the owner of the project.
|
|
696
|
+
* @param {number} id
|
|
697
|
+
* @param {string} [apiToken]
|
|
698
|
+
* @param {*} [options] Override http request option.
|
|
699
|
+
* @throws {RequiredError}
|
|
700
|
+
* @memberof ProjectsApi
|
|
701
|
+
*/
|
|
702
|
+
projectsDelete(e, t, s) {
|
|
703
|
+
return g(this.configuration).projectsDelete(e, t, s).then((r) => r(this.axios, this.basePath));
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Export. More details in the [documentation](https://poeditor.com/docs/api#projects_export).
|
|
707
|
+
* @summary Returns the link of the file (expires after 10 minutes). The settings inherited from the project will be the ones at the time of the download.
|
|
708
|
+
* @param {number} id
|
|
709
|
+
* @param {string} language
|
|
710
|
+
* @param {ProjectsExportTypeEnum} type
|
|
711
|
+
* @param {string} [apiToken]
|
|
712
|
+
* @param {string} [filters]
|
|
713
|
+
* @param {string} [order]
|
|
714
|
+
* @param {string} [tags]
|
|
715
|
+
* @param {ProjectsExportOptionsEnum} [_options]
|
|
716
|
+
* @param {*} [options] Override http request option.
|
|
717
|
+
* @throws {RequiredError}
|
|
718
|
+
* @memberof ProjectsApi
|
|
719
|
+
*/
|
|
720
|
+
projectsExport(e, t, s, r, o, c, n, i, l) {
|
|
721
|
+
return g(this.configuration).projectsExport(e, t, s, r, o, c, n, i, l).then((d) => d(this.axios, this.basePath));
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* List Projects. More details in the [documentation](https://poeditor.com/docs/api#projects_list).
|
|
725
|
+
* @summary Returns the list of projects owned by user.
|
|
726
|
+
* @param {string} apiToken
|
|
727
|
+
* @param {*} [options] Override http request option.
|
|
728
|
+
* @throws {RequiredError}
|
|
729
|
+
* @memberof ProjectsApi
|
|
730
|
+
*/
|
|
731
|
+
projectsList(e, t) {
|
|
732
|
+
return g(this.configuration).projectsList(e, t).then((s) => s(this.axios, this.basePath));
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Sync Terms. More details in the [documentation](https://poeditor.com/docs/api#projects_sync).
|
|
736
|
+
* @summary Syncs your project with the array you send (terms that are not found in the JSON object will be deleted from project and the new ones added). Please use with caution. If wrong data is sent, existing terms and their translations might be irreversibly lost.
|
|
737
|
+
* @param {number} id
|
|
738
|
+
* @param {string} data JSON format
|
|
739
|
+
* @param {string} [apiToken]
|
|
740
|
+
* @param {*} [options] Override http request option.
|
|
741
|
+
* @throws {RequiredError}
|
|
742
|
+
* @memberof ProjectsApi
|
|
743
|
+
*/
|
|
744
|
+
projectsSync(e, t, s, r) {
|
|
745
|
+
return g(this.configuration).projectsSync(e, t, s, r).then((o) => o(this.axios, this.basePath));
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Update Project Settings. More details in the [documentation](https://poeditor.com/docs/api#projects_update).
|
|
749
|
+
* @summary Updates project settings (name, description, reference language, fallback language). If optional parameters are not sent, their respective fields are not updated.
|
|
750
|
+
* @param {number} id
|
|
751
|
+
* @param {string} [apiToken]
|
|
752
|
+
* @param {string} [name]
|
|
753
|
+
* @param {string} [description]
|
|
754
|
+
* @param {string} [referenceLanguage]
|
|
755
|
+
* @param {string} [fallbackLanguage]
|
|
756
|
+
* @param {*} [options] Override http request option.
|
|
757
|
+
* @throws {RequiredError}
|
|
758
|
+
* @memberof ProjectsApi
|
|
759
|
+
*/
|
|
760
|
+
projectsUpdate(e, t, s, r, o, c, n) {
|
|
761
|
+
return g(this.configuration).projectsUpdate(e, t, s, r, o, c, n).then((i) => i(this.axios, this.basePath));
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Upload. More details in the [documentation](https://poeditor.com/docs/api#projects_upload).
|
|
765
|
+
* @summary Updates terms / translations - No more than one request every 20 seconds.
|
|
766
|
+
* @param {ProjectsUploadUpdatingEnum} updating
|
|
767
|
+
* @param {File} file Uploaded file (.po, .xls or any of the supported file formats)
|
|
768
|
+
* @param {string} [apiToken]
|
|
769
|
+
* @param {number} [id]
|
|
770
|
+
* @param {string} [language] The language code (Required only if `updating` is terms_translations or translations). When using `terms_translations` with `.xcstrings` file format, leave it empty to import all the languages in the file.
|
|
771
|
+
* @param {ProjectsUploadOverwriteEnum} [overwrite] Set it to 1 if you want to overwrite translations
|
|
772
|
+
* @param {ProjectsUploadSyncTermsEnum} [syncTerms] Set it to 1 if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added). Ignored if `updating` = translations.
|
|
773
|
+
* @param {string} [tags] Add tags to the project terms; available when updating terms or terms_translations; you can use the following keys: \\\"all\\\" - for the all the imported terms, \\\"new\\\" - for the terms which arent already in the project, \\\"obsolete\\\" - for the terms which are in the project but not in the imported file and \\\"overwritten_translations\\\" - for the terms for which translations change
|
|
774
|
+
* @param {ProjectsUploadReadFromSourceEnum} [readFromSource] For .xliff format only - set it to 1 if you want to import translations from the source tag
|
|
775
|
+
* @param {ProjectsUploadFuzzyTriggerEnum} [fuzzyTrigger] Set it to 1 to mark corresponding translations from the other languages as fuzzy for the updated values
|
|
776
|
+
* @param {*} [options] Override http request option.
|
|
777
|
+
* @throws {RequiredError}
|
|
778
|
+
* @memberof ProjectsApi
|
|
779
|
+
*/
|
|
780
|
+
projectsUpload(e, t, s, r, o, c, n, i, l, d, p) {
|
|
781
|
+
return g(this.configuration).projectsUpload(
|
|
782
|
+
e,
|
|
783
|
+
t,
|
|
784
|
+
s,
|
|
785
|
+
r,
|
|
786
|
+
o,
|
|
787
|
+
c,
|
|
788
|
+
n,
|
|
789
|
+
i,
|
|
790
|
+
l,
|
|
791
|
+
d,
|
|
792
|
+
p
|
|
793
|
+
).then((m) => m(this.axios, this.basePath));
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* View Project Details. More details in the [documentation](https://poeditor.com/docs/api#projects_view).
|
|
797
|
+
* @summary Returns projects details
|
|
798
|
+
* @param {number} id
|
|
799
|
+
* @param {string} [apiToken]
|
|
800
|
+
* @param {*} [options] Override http request option.
|
|
801
|
+
* @throws {RequiredError}
|
|
802
|
+
* @memberof ProjectsApi
|
|
803
|
+
*/
|
|
804
|
+
projectsView(e, t, s) {
|
|
805
|
+
return g(this.configuration).projectsView(e, t, s).then((r) => r(this.axios, this.basePath));
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const ne = {
|
|
809
|
+
Arb: "arb",
|
|
810
|
+
Csv: "csv",
|
|
811
|
+
Ini: "ini",
|
|
812
|
+
KeyValueJson: "key_value_json",
|
|
813
|
+
I18next: "i18next",
|
|
814
|
+
Json: "json",
|
|
815
|
+
Po: "po",
|
|
816
|
+
Pot: "pot",
|
|
817
|
+
Mo: "mo",
|
|
818
|
+
Properties: "properties",
|
|
819
|
+
Resw: "resw",
|
|
820
|
+
Resx: "resx",
|
|
821
|
+
Ts: "ts",
|
|
822
|
+
AppleStrings: "apple_strings",
|
|
823
|
+
Xliff: "xliff",
|
|
824
|
+
Xliff12: "xliff_1_2",
|
|
825
|
+
Xlf: "xlf",
|
|
826
|
+
Xmb: "xmb",
|
|
827
|
+
Xtb: "xtb",
|
|
828
|
+
Rise360Xliff: "rise_360_xliff",
|
|
829
|
+
Xls: "xls",
|
|
830
|
+
Xlsx: "xlsx",
|
|
831
|
+
AndroidStrings: "android_strings",
|
|
832
|
+
Yml: "yml",
|
|
833
|
+
Php: "php"
|
|
834
|
+
}, ie = function(a) {
|
|
835
|
+
return {
|
|
836
|
+
/**
|
|
837
|
+
* Add Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_add).
|
|
838
|
+
* @summary Adds terms to project.
|
|
839
|
+
* @param {number} id
|
|
840
|
+
* @param {string} data JSON format
|
|
841
|
+
* @param {string} [apiToken]
|
|
842
|
+
* @param {*} [options] Override http request option.
|
|
843
|
+
* @throws {RequiredError}
|
|
844
|
+
*/
|
|
845
|
+
termsAdd: async (e, t, s, r = {}) => {
|
|
846
|
+
u("termsAdd", "id", e), u("termsAdd", "data", t);
|
|
847
|
+
const o = "/terms/add", c = new URL(o, y);
|
|
848
|
+
let n;
|
|
849
|
+
a && (n = a.baseOptions);
|
|
850
|
+
const i = { method: "POST", ...n, ...r }, l = {}, d = {}, p = new URLSearchParams();
|
|
851
|
+
s !== void 0 && p.set("api_token", s), e !== void 0 && p.set("id", e), t !== void 0 && p.set("data", t), l["Content-Type"] = "application/x-www-form-urlencoded", j(c, d);
|
|
852
|
+
let m = n && n.headers ? n.headers : {};
|
|
853
|
+
return i.headers = { ...l, ...m, ...r.headers }, i.data = p.toString(), {
|
|
854
|
+
url: A(c),
|
|
855
|
+
options: i
|
|
856
|
+
};
|
|
857
|
+
},
|
|
858
|
+
/**
|
|
859
|
+
* Add Comment. More details in the [documentation](https://poeditor.com/docs/api#terms_add_comment).
|
|
860
|
+
* @summary Adds comments to existing terms.
|
|
861
|
+
* @param {number} id
|
|
862
|
+
* @param {string} data JSON format
|
|
863
|
+
* @param {string} [apiToken]
|
|
864
|
+
* @param {*} [options] Override http request option.
|
|
865
|
+
* @throws {RequiredError}
|
|
866
|
+
*/
|
|
867
|
+
termsAddComment: async (e, t, s, r = {}) => {
|
|
868
|
+
u("termsAddComment", "id", e), u("termsAddComment", "data", t);
|
|
869
|
+
const o = "/terms/add_comment", c = new URL(o, y);
|
|
870
|
+
let n;
|
|
871
|
+
a && (n = a.baseOptions);
|
|
872
|
+
const i = { method: "POST", ...n, ...r }, l = {}, d = {}, p = new URLSearchParams();
|
|
873
|
+
s !== void 0 && p.set("api_token", s), e !== void 0 && p.set("id", e), t !== void 0 && p.set("data", t), l["Content-Type"] = "application/x-www-form-urlencoded", j(c, d);
|
|
874
|
+
let m = n && n.headers ? n.headers : {};
|
|
875
|
+
return i.headers = { ...l, ...m, ...r.headers }, i.data = p.toString(), {
|
|
876
|
+
url: A(c),
|
|
877
|
+
options: i
|
|
878
|
+
};
|
|
879
|
+
},
|
|
880
|
+
/**
|
|
881
|
+
* Delete Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_delete).
|
|
882
|
+
* @summary Deletes terms from project.
|
|
883
|
+
* @param {number} id
|
|
884
|
+
* @param {string} data JSON format
|
|
885
|
+
* @param {string} [apiToken]
|
|
886
|
+
* @param {*} [options] Override http request option.
|
|
887
|
+
* @throws {RequiredError}
|
|
888
|
+
*/
|
|
889
|
+
termsDelete: async (e, t, s, r = {}) => {
|
|
890
|
+
u("termsDelete", "id", e), u("termsDelete", "data", t);
|
|
891
|
+
const o = "/terms/delete", c = new URL(o, y);
|
|
892
|
+
let n;
|
|
893
|
+
a && (n = a.baseOptions);
|
|
894
|
+
const i = { method: "POST", ...n, ...r }, l = {}, d = {}, p = new URLSearchParams();
|
|
895
|
+
s !== void 0 && p.set("api_token", s), e !== void 0 && p.set("id", e), t !== void 0 && p.set("data", t), l["Content-Type"] = "application/x-www-form-urlencoded", j(c, d);
|
|
896
|
+
let m = n && n.headers ? n.headers : {};
|
|
897
|
+
return i.headers = { ...l, ...m, ...r.headers }, i.data = p.toString(), {
|
|
898
|
+
url: A(c),
|
|
899
|
+
options: i
|
|
900
|
+
};
|
|
901
|
+
},
|
|
902
|
+
/**
|
|
903
|
+
* List Project Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_list).
|
|
904
|
+
* @summary Returns project\'s terms and translations if the argument language is provided.
|
|
905
|
+
* @param {number} id
|
|
906
|
+
* @param {string} [apiToken]
|
|
907
|
+
* @param {string} [language] The language code
|
|
908
|
+
* @param {*} [options] Override http request option.
|
|
909
|
+
* @throws {RequiredError}
|
|
910
|
+
*/
|
|
911
|
+
termsList: async (e, t, s, r = {}) => {
|
|
912
|
+
u("termsList", "id", e);
|
|
913
|
+
const o = "/terms/list", c = new URL(o, y);
|
|
914
|
+
let n;
|
|
915
|
+
a && (n = a.baseOptions);
|
|
916
|
+
const i = { method: "POST", ...n, ...r }, l = {}, d = {}, p = new URLSearchParams();
|
|
917
|
+
t !== void 0 && p.set("api_token", t), e !== void 0 && p.set("id", e), s !== void 0 && p.set("language", s), l["Content-Type"] = "application/x-www-form-urlencoded", j(c, d);
|
|
918
|
+
let m = n && n.headers ? n.headers : {};
|
|
919
|
+
return i.headers = { ...l, ...m, ...r.headers }, i.data = p.toString(), {
|
|
920
|
+
url: A(c),
|
|
921
|
+
options: i
|
|
922
|
+
};
|
|
923
|
+
},
|
|
924
|
+
/**
|
|
925
|
+
* Update Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_update).
|
|
926
|
+
* @summary Updates project terms. Lets you change the text, context, reference, plural and tags.
|
|
927
|
+
* @param {number} id
|
|
928
|
+
* @param {string} data JSON format
|
|
929
|
+
* @param {string} [apiToken]
|
|
930
|
+
* @param {TermsUpdateFuzzyTriggerEnum} [fuzzyTrigger] Set it to 1 to mark corresponding translations from the other languages as fuzzy for the updated values
|
|
931
|
+
* @param {*} [options] Override http request option.
|
|
932
|
+
* @throws {RequiredError}
|
|
933
|
+
*/
|
|
934
|
+
termsUpdate: async (e, t, s, r, o = {}) => {
|
|
935
|
+
u("termsUpdate", "id", e), u("termsUpdate", "data", t);
|
|
936
|
+
const c = "/terms/update", n = new URL(c, y);
|
|
937
|
+
let i;
|
|
938
|
+
a && (i = a.baseOptions);
|
|
939
|
+
const l = { method: "POST", ...i, ...o }, d = {}, p = {}, m = new URLSearchParams();
|
|
940
|
+
s !== void 0 && m.set("api_token", s), e !== void 0 && m.set("id", e), t !== void 0 && m.set("data", t), r !== void 0 && m.set("fuzzy_trigger", r), d["Content-Type"] = "application/x-www-form-urlencoded", j(n, p);
|
|
941
|
+
let f = i && i.headers ? i.headers : {};
|
|
942
|
+
return l.headers = { ...d, ...f, ...o.headers }, l.data = m.toString(), {
|
|
943
|
+
url: A(n),
|
|
944
|
+
options: l
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
}, I = function(a) {
|
|
949
|
+
const e = ie(a);
|
|
950
|
+
return {
|
|
951
|
+
/**
|
|
952
|
+
* Add Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_add).
|
|
953
|
+
* @summary Adds terms to project.
|
|
954
|
+
* @param {number} id
|
|
955
|
+
* @param {string} data JSON format
|
|
956
|
+
* @param {string} [apiToken]
|
|
957
|
+
* @param {*} [options] Override http request option.
|
|
958
|
+
* @throws {RequiredError}
|
|
959
|
+
*/
|
|
960
|
+
async termsAdd(t, s, r, o) {
|
|
961
|
+
const c = await e.termsAdd(t, s, r, o), n = a?.serverIndex ?? 0, i = x["TermsApi.termsAdd"]?.[n]?.url;
|
|
962
|
+
return (l, d) => S(
|
|
963
|
+
c,
|
|
964
|
+
O,
|
|
965
|
+
v,
|
|
966
|
+
a
|
|
967
|
+
)(l, i || d);
|
|
968
|
+
},
|
|
969
|
+
/**
|
|
970
|
+
* Add Comment. More details in the [documentation](https://poeditor.com/docs/api#terms_add_comment).
|
|
971
|
+
* @summary Adds comments to existing terms.
|
|
972
|
+
* @param {number} id
|
|
973
|
+
* @param {string} data JSON format
|
|
974
|
+
* @param {string} [apiToken]
|
|
975
|
+
* @param {*} [options] Override http request option.
|
|
976
|
+
* @throws {RequiredError}
|
|
977
|
+
*/
|
|
978
|
+
async termsAddComment(t, s, r, o) {
|
|
979
|
+
const c = await e.termsAddComment(t, s, r, o), n = a?.serverIndex ?? 0, i = x["TermsApi.termsAddComment"]?.[n]?.url;
|
|
980
|
+
return (l, d) => S(
|
|
981
|
+
c,
|
|
982
|
+
O,
|
|
983
|
+
v,
|
|
984
|
+
a
|
|
985
|
+
)(l, i || d);
|
|
986
|
+
},
|
|
987
|
+
/**
|
|
988
|
+
* Delete Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_delete).
|
|
989
|
+
* @summary Deletes terms from project.
|
|
990
|
+
* @param {number} id
|
|
991
|
+
* @param {string} data JSON format
|
|
992
|
+
* @param {string} [apiToken]
|
|
993
|
+
* @param {*} [options] Override http request option.
|
|
994
|
+
* @throws {RequiredError}
|
|
995
|
+
*/
|
|
996
|
+
async termsDelete(t, s, r, o) {
|
|
997
|
+
const c = await e.termsDelete(t, s, r, o), n = a?.serverIndex ?? 0, i = x["TermsApi.termsDelete"]?.[n]?.url;
|
|
998
|
+
return (l, d) => S(
|
|
999
|
+
c,
|
|
1000
|
+
O,
|
|
1001
|
+
v,
|
|
1002
|
+
a
|
|
1003
|
+
)(l, i || d);
|
|
1004
|
+
},
|
|
1005
|
+
/**
|
|
1006
|
+
* List Project Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_list).
|
|
1007
|
+
* @summary Returns project\'s terms and translations if the argument language is provided.
|
|
1008
|
+
* @param {number} id
|
|
1009
|
+
* @param {string} [apiToken]
|
|
1010
|
+
* @param {string} [language] The language code
|
|
1011
|
+
* @param {*} [options] Override http request option.
|
|
1012
|
+
* @throws {RequiredError}
|
|
1013
|
+
*/
|
|
1014
|
+
async termsList(t, s, r, o) {
|
|
1015
|
+
const c = await e.termsList(t, s, r, o), n = a?.serverIndex ?? 0, i = x["TermsApi.termsList"]?.[n]?.url;
|
|
1016
|
+
return (l, d) => S(
|
|
1017
|
+
c,
|
|
1018
|
+
O,
|
|
1019
|
+
v,
|
|
1020
|
+
a
|
|
1021
|
+
)(l, i || d);
|
|
1022
|
+
},
|
|
1023
|
+
/**
|
|
1024
|
+
* Update Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_update).
|
|
1025
|
+
* @summary Updates project terms. Lets you change the text, context, reference, plural and tags.
|
|
1026
|
+
* @param {number} id
|
|
1027
|
+
* @param {string} data JSON format
|
|
1028
|
+
* @param {string} [apiToken]
|
|
1029
|
+
* @param {TermsUpdateFuzzyTriggerEnum} [fuzzyTrigger] Set it to 1 to mark corresponding translations from the other languages as fuzzy for the updated values
|
|
1030
|
+
* @param {*} [options] Override http request option.
|
|
1031
|
+
* @throws {RequiredError}
|
|
1032
|
+
*/
|
|
1033
|
+
async termsUpdate(t, s, r, o, c) {
|
|
1034
|
+
const n = await e.termsUpdate(t, s, r, o, c), i = a?.serverIndex ?? 0, l = x["TermsApi.termsUpdate"]?.[i]?.url;
|
|
1035
|
+
return (d, p) => S(
|
|
1036
|
+
n,
|
|
1037
|
+
O,
|
|
1038
|
+
v,
|
|
1039
|
+
a
|
|
1040
|
+
)(d, l || p);
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
};
|
|
1044
|
+
class ce extends k {
|
|
1045
|
+
/**
|
|
1046
|
+
* Add Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_add).
|
|
1047
|
+
* @summary Adds terms to project.
|
|
1048
|
+
* @param {number} id
|
|
1049
|
+
* @param {string} data JSON format
|
|
1050
|
+
* @param {string} [apiToken]
|
|
1051
|
+
* @param {*} [options] Override http request option.
|
|
1052
|
+
* @throws {RequiredError}
|
|
1053
|
+
* @memberof TermsApi
|
|
1054
|
+
*/
|
|
1055
|
+
termsAdd(e, t, s, r) {
|
|
1056
|
+
return I(this.configuration).termsAdd(e, t, s, r).then((o) => o(this.axios, this.basePath));
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Add Comment. More details in the [documentation](https://poeditor.com/docs/api#terms_add_comment).
|
|
1060
|
+
* @summary Adds comments to existing terms.
|
|
1061
|
+
* @param {number} id
|
|
1062
|
+
* @param {string} data JSON format
|
|
1063
|
+
* @param {string} [apiToken]
|
|
1064
|
+
* @param {*} [options] Override http request option.
|
|
1065
|
+
* @throws {RequiredError}
|
|
1066
|
+
* @memberof TermsApi
|
|
1067
|
+
*/
|
|
1068
|
+
termsAddComment(e, t, s, r) {
|
|
1069
|
+
return I(this.configuration).termsAddComment(e, t, s, r).then((o) => o(this.axios, this.basePath));
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Delete Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_delete).
|
|
1073
|
+
* @summary Deletes terms from project.
|
|
1074
|
+
* @param {number} id
|
|
1075
|
+
* @param {string} data JSON format
|
|
1076
|
+
* @param {string} [apiToken]
|
|
1077
|
+
* @param {*} [options] Override http request option.
|
|
1078
|
+
* @throws {RequiredError}
|
|
1079
|
+
* @memberof TermsApi
|
|
1080
|
+
*/
|
|
1081
|
+
termsDelete(e, t, s, r) {
|
|
1082
|
+
return I(this.configuration).termsDelete(e, t, s, r).then((o) => o(this.axios, this.basePath));
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* List Project Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_list).
|
|
1086
|
+
* @summary Returns project\'s terms and translations if the argument language is provided.
|
|
1087
|
+
* @param {number} id
|
|
1088
|
+
* @param {string} [apiToken]
|
|
1089
|
+
* @param {string} [language] The language code
|
|
1090
|
+
* @param {*} [options] Override http request option.
|
|
1091
|
+
* @throws {RequiredError}
|
|
1092
|
+
* @memberof TermsApi
|
|
1093
|
+
*/
|
|
1094
|
+
termsList(e, t, s, r) {
|
|
1095
|
+
return I(this.configuration).termsList(e, t, s, r).then((o) => o(this.axios, this.basePath));
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Update Terms. More details in the [documentation](https://poeditor.com/docs/api#terms_update).
|
|
1099
|
+
* @summary Updates project terms. Lets you change the text, context, reference, plural and tags.
|
|
1100
|
+
* @param {number} id
|
|
1101
|
+
* @param {string} data JSON format
|
|
1102
|
+
* @param {string} [apiToken]
|
|
1103
|
+
* @param {TermsUpdateFuzzyTriggerEnum} [fuzzyTrigger] Set it to 1 to mark corresponding translations from the other languages as fuzzy for the updated values
|
|
1104
|
+
* @param {*} [options] Override http request option.
|
|
1105
|
+
* @throws {RequiredError}
|
|
1106
|
+
* @memberof TermsApi
|
|
1107
|
+
*/
|
|
1108
|
+
termsUpdate(e, t, s, r, o) {
|
|
1109
|
+
return I(this.configuration).termsUpdate(e, t, s, r, o).then((c) => c(this.axios, this.basePath));
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
const le = function(a) {
|
|
1113
|
+
return {
|
|
1114
|
+
/**
|
|
1115
|
+
* Add Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_add).
|
|
1116
|
+
* @summary Adds translations to project. If translation exists, it will not overwrite it.
|
|
1117
|
+
* @param {number} id
|
|
1118
|
+
* @param {string} language The language code
|
|
1119
|
+
* @param {string} data JSON format
|
|
1120
|
+
* @param {string} [apiToken]
|
|
1121
|
+
* @param {*} [options] Override http request option.
|
|
1122
|
+
* @throws {RequiredError}
|
|
1123
|
+
*/
|
|
1124
|
+
translationsAdd: async (e, t, s, r, o = {}) => {
|
|
1125
|
+
u("translationsAdd", "id", e), u("translationsAdd", "language", t), u("translationsAdd", "data", s);
|
|
1126
|
+
const c = "/translations/add", n = new URL(c, y);
|
|
1127
|
+
let i;
|
|
1128
|
+
a && (i = a.baseOptions);
|
|
1129
|
+
const l = { method: "POST", ...i, ...o }, d = {}, p = {}, m = new URLSearchParams();
|
|
1130
|
+
r !== void 0 && m.set("api_token", r), e !== void 0 && m.set("id", e), t !== void 0 && m.set("language", t), s !== void 0 && m.set("data", s), d["Content-Type"] = "application/x-www-form-urlencoded", j(n, p);
|
|
1131
|
+
let f = i && i.headers ? i.headers : {};
|
|
1132
|
+
return l.headers = { ...d, ...f, ...o.headers }, l.data = m.toString(), {
|
|
1133
|
+
url: A(n),
|
|
1134
|
+
options: l
|
|
1135
|
+
};
|
|
1136
|
+
},
|
|
1137
|
+
/**
|
|
1138
|
+
* Update Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_automatic).
|
|
1139
|
+
* @summary Updates existing translations.
|
|
1140
|
+
* @param {number} id
|
|
1141
|
+
* @param {TranslationsAutomaticProviderEnum} provider
|
|
1142
|
+
* @param {string} [apiToken]
|
|
1143
|
+
* @param {string} [sourceLanguage] The language code
|
|
1144
|
+
* @param {string} [providerSourceLanguage] The language code
|
|
1145
|
+
* @param {string} [targetLanguages] A JSON of the languages to translate to
|
|
1146
|
+
* @param {string} [_options] A JSON of the advanced options you want to use with the selected provider. Possible options include the POEditor tag of the strings you want to send for translation and some provider-specific options
|
|
1147
|
+
* @param {*} [options] Override http request option.
|
|
1148
|
+
* @throws {RequiredError}
|
|
1149
|
+
*/
|
|
1150
|
+
translationsAutomatic: async (e, t, s, r, o, c, n, i = {}) => {
|
|
1151
|
+
u("translationsAutomatic", "id", e), u("translationsAutomatic", "provider", t);
|
|
1152
|
+
const l = "/translations/automatic", d = new URL(l, y);
|
|
1153
|
+
let p;
|
|
1154
|
+
a && (p = a.baseOptions);
|
|
1155
|
+
const m = { method: "POST", ...p, ...i }, f = {}, w = {}, P = new URLSearchParams();
|
|
1156
|
+
s !== void 0 && P.set("api_token", s), e !== void 0 && P.set("id", e), r !== void 0 && P.set("source_language", r), o !== void 0 && P.set("provider_source_language", o), t !== void 0 && P.set("provider", t), c !== void 0 && P.set("target_languages", c), n !== void 0 && P.set("options", n), f["Content-Type"] = "application/x-www-form-urlencoded", j(d, w);
|
|
1157
|
+
let b = p && p.headers ? p.headers : {};
|
|
1158
|
+
return m.headers = { ...f, ...b, ...i.headers }, m.data = P.toString(), {
|
|
1159
|
+
url: A(d),
|
|
1160
|
+
options: m
|
|
1161
|
+
};
|
|
1162
|
+
},
|
|
1163
|
+
/**
|
|
1164
|
+
* Delete Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_delete).
|
|
1165
|
+
* @summary Deletes translations from specified language.
|
|
1166
|
+
* @param {number} id
|
|
1167
|
+
* @param {string} language The language code
|
|
1168
|
+
* @param {string} data JSON format
|
|
1169
|
+
* @param {string} [apiToken]
|
|
1170
|
+
* @param {*} [options] Override http request option.
|
|
1171
|
+
* @throws {RequiredError}
|
|
1172
|
+
*/
|
|
1173
|
+
translationsDelete: async (e, t, s, r, o = {}) => {
|
|
1174
|
+
u("translationsDelete", "id", e), u("translationsDelete", "language", t), u("translationsDelete", "data", s);
|
|
1175
|
+
const c = "/translations/delete", n = new URL(c, y);
|
|
1176
|
+
let i;
|
|
1177
|
+
a && (i = a.baseOptions);
|
|
1178
|
+
const l = { method: "POST", ...i, ...o }, d = {}, p = {}, m = new URLSearchParams();
|
|
1179
|
+
r !== void 0 && m.set("api_token", r), e !== void 0 && m.set("id", e), t !== void 0 && m.set("language", t), s !== void 0 && m.set("data", s), d["Content-Type"] = "application/x-www-form-urlencoded", j(n, p);
|
|
1180
|
+
let f = i && i.headers ? i.headers : {};
|
|
1181
|
+
return l.headers = { ...d, ...f, ...o.headers }, l.data = m.toString(), {
|
|
1182
|
+
url: A(n),
|
|
1183
|
+
options: l
|
|
1184
|
+
};
|
|
1185
|
+
},
|
|
1186
|
+
/**
|
|
1187
|
+
* Update Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_update).
|
|
1188
|
+
* @summary Updates existing translations.
|
|
1189
|
+
* @param {number} id
|
|
1190
|
+
* @param {string} language The language code
|
|
1191
|
+
* @param {string} data JSON format
|
|
1192
|
+
* @param {string} [apiToken]
|
|
1193
|
+
* @param {*} [options] Override http request option.
|
|
1194
|
+
* @throws {RequiredError}
|
|
1195
|
+
*/
|
|
1196
|
+
translationsUpdate: async (e, t, s, r, o = {}) => {
|
|
1197
|
+
u("translationsUpdate", "id", e), u("translationsUpdate", "language", t), u("translationsUpdate", "data", s);
|
|
1198
|
+
const c = "/translations/update", n = new URL(c, y);
|
|
1199
|
+
let i;
|
|
1200
|
+
a && (i = a.baseOptions);
|
|
1201
|
+
const l = { method: "POST", ...i, ...o }, d = {}, p = {}, m = new URLSearchParams();
|
|
1202
|
+
r !== void 0 && m.set("api_token", r), e !== void 0 && m.set("id", e), t !== void 0 && m.set("language", t), s !== void 0 && m.set("data", s), d["Content-Type"] = "application/x-www-form-urlencoded", j(n, p);
|
|
1203
|
+
let f = i && i.headers ? i.headers : {};
|
|
1204
|
+
return l.headers = { ...d, ...f, ...o.headers }, l.data = m.toString(), {
|
|
1205
|
+
url: A(n),
|
|
1206
|
+
options: l
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
}, D = function(a) {
|
|
1211
|
+
const e = le(a);
|
|
1212
|
+
return {
|
|
1213
|
+
/**
|
|
1214
|
+
* Add Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_add).
|
|
1215
|
+
* @summary Adds translations to project. If translation exists, it will not overwrite it.
|
|
1216
|
+
* @param {number} id
|
|
1217
|
+
* @param {string} language The language code
|
|
1218
|
+
* @param {string} data JSON format
|
|
1219
|
+
* @param {string} [apiToken]
|
|
1220
|
+
* @param {*} [options] Override http request option.
|
|
1221
|
+
* @throws {RequiredError}
|
|
1222
|
+
*/
|
|
1223
|
+
async translationsAdd(t, s, r, o, c) {
|
|
1224
|
+
const n = await e.translationsAdd(t, s, r, o, c), i = a?.serverIndex ?? 0, l = x["TranslationsApi.translationsAdd"]?.[i]?.url;
|
|
1225
|
+
return (d, p) => S(
|
|
1226
|
+
n,
|
|
1227
|
+
O,
|
|
1228
|
+
v,
|
|
1229
|
+
a
|
|
1230
|
+
)(d, l || p);
|
|
1231
|
+
},
|
|
1232
|
+
/**
|
|
1233
|
+
* Update Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_automatic).
|
|
1234
|
+
* @summary Updates existing translations.
|
|
1235
|
+
* @param {number} id
|
|
1236
|
+
* @param {TranslationsAutomaticProviderEnum} provider
|
|
1237
|
+
* @param {string} [apiToken]
|
|
1238
|
+
* @param {string} [sourceLanguage] The language code
|
|
1239
|
+
* @param {string} [providerSourceLanguage] The language code
|
|
1240
|
+
* @param {string} [targetLanguages] A JSON of the languages to translate to
|
|
1241
|
+
* @param {string} [_options] A JSON of the advanced options you want to use with the selected provider. Possible options include the POEditor tag of the strings you want to send for translation and some provider-specific options
|
|
1242
|
+
* @param {*} [options] Override http request option.
|
|
1243
|
+
* @throws {RequiredError}
|
|
1244
|
+
*/
|
|
1245
|
+
async translationsAutomatic(t, s, r, o, c, n, i, l) {
|
|
1246
|
+
const d = await e.translationsAutomatic(
|
|
1247
|
+
t,
|
|
1248
|
+
s,
|
|
1249
|
+
r,
|
|
1250
|
+
o,
|
|
1251
|
+
c,
|
|
1252
|
+
n,
|
|
1253
|
+
i,
|
|
1254
|
+
l
|
|
1255
|
+
), p = a?.serverIndex ?? 0, m = x["TranslationsApi.translationsAutomatic"]?.[p]?.url;
|
|
1256
|
+
return (f, w) => S(
|
|
1257
|
+
d,
|
|
1258
|
+
O,
|
|
1259
|
+
v,
|
|
1260
|
+
a
|
|
1261
|
+
)(f, m || w);
|
|
1262
|
+
},
|
|
1263
|
+
/**
|
|
1264
|
+
* Delete Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_delete).
|
|
1265
|
+
* @summary Deletes translations from specified language.
|
|
1266
|
+
* @param {number} id
|
|
1267
|
+
* @param {string} language The language code
|
|
1268
|
+
* @param {string} data JSON format
|
|
1269
|
+
* @param {string} [apiToken]
|
|
1270
|
+
* @param {*} [options] Override http request option.
|
|
1271
|
+
* @throws {RequiredError}
|
|
1272
|
+
*/
|
|
1273
|
+
async translationsDelete(t, s, r, o, c) {
|
|
1274
|
+
const n = await e.translationsDelete(
|
|
1275
|
+
t,
|
|
1276
|
+
s,
|
|
1277
|
+
r,
|
|
1278
|
+
o,
|
|
1279
|
+
c
|
|
1280
|
+
), i = a?.serverIndex ?? 0, l = x["TranslationsApi.translationsDelete"]?.[i]?.url;
|
|
1281
|
+
return (d, p) => S(
|
|
1282
|
+
n,
|
|
1283
|
+
O,
|
|
1284
|
+
v,
|
|
1285
|
+
a
|
|
1286
|
+
)(d, l || p);
|
|
1287
|
+
},
|
|
1288
|
+
/**
|
|
1289
|
+
* Update Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_update).
|
|
1290
|
+
* @summary Updates existing translations.
|
|
1291
|
+
* @param {number} id
|
|
1292
|
+
* @param {string} language The language code
|
|
1293
|
+
* @param {string} data JSON format
|
|
1294
|
+
* @param {string} [apiToken]
|
|
1295
|
+
* @param {*} [options] Override http request option.
|
|
1296
|
+
* @throws {RequiredError}
|
|
1297
|
+
*/
|
|
1298
|
+
async translationsUpdate(t, s, r, o, c) {
|
|
1299
|
+
const n = await e.translationsUpdate(
|
|
1300
|
+
t,
|
|
1301
|
+
s,
|
|
1302
|
+
r,
|
|
1303
|
+
o,
|
|
1304
|
+
c
|
|
1305
|
+
), i = a?.serverIndex ?? 0, l = x["TranslationsApi.translationsUpdate"]?.[i]?.url;
|
|
1306
|
+
return (d, p) => S(
|
|
1307
|
+
n,
|
|
1308
|
+
O,
|
|
1309
|
+
v,
|
|
1310
|
+
a
|
|
1311
|
+
)(d, l || p);
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
};
|
|
1315
|
+
class de extends k {
|
|
1316
|
+
/**
|
|
1317
|
+
* Add Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_add).
|
|
1318
|
+
* @summary Adds translations to project. If translation exists, it will not overwrite it.
|
|
1319
|
+
* @param {number} id
|
|
1320
|
+
* @param {string} language The language code
|
|
1321
|
+
* @param {string} data JSON format
|
|
1322
|
+
* @param {string} [apiToken]
|
|
1323
|
+
* @param {*} [options] Override http request option.
|
|
1324
|
+
* @throws {RequiredError}
|
|
1325
|
+
* @memberof TranslationsApi
|
|
1326
|
+
*/
|
|
1327
|
+
translationsAdd(e, t, s, r, o) {
|
|
1328
|
+
return D(this.configuration).translationsAdd(e, t, s, r, o).then((c) => c(this.axios, this.basePath));
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Update Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_automatic).
|
|
1332
|
+
* @summary Updates existing translations.
|
|
1333
|
+
* @param {number} id
|
|
1334
|
+
* @param {TranslationsAutomaticProviderEnum} provider
|
|
1335
|
+
* @param {string} [apiToken]
|
|
1336
|
+
* @param {string} [sourceLanguage] The language code
|
|
1337
|
+
* @param {string} [providerSourceLanguage] The language code
|
|
1338
|
+
* @param {string} [targetLanguages] A JSON of the languages to translate to
|
|
1339
|
+
* @param {string} [_options] A JSON of the advanced options you want to use with the selected provider. Possible options include the POEditor tag of the strings you want to send for translation and some provider-specific options
|
|
1340
|
+
* @param {*} [options] Override http request option.
|
|
1341
|
+
* @throws {RequiredError}
|
|
1342
|
+
* @memberof TranslationsApi
|
|
1343
|
+
*/
|
|
1344
|
+
translationsAutomatic(e, t, s, r, o, c, n, i) {
|
|
1345
|
+
return D(this.configuration).translationsAutomatic(
|
|
1346
|
+
e,
|
|
1347
|
+
t,
|
|
1348
|
+
s,
|
|
1349
|
+
r,
|
|
1350
|
+
o,
|
|
1351
|
+
c,
|
|
1352
|
+
n,
|
|
1353
|
+
i
|
|
1354
|
+
).then((l) => l(this.axios, this.basePath));
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Delete Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_delete).
|
|
1358
|
+
* @summary Deletes translations from specified language.
|
|
1359
|
+
* @param {number} id
|
|
1360
|
+
* @param {string} language The language code
|
|
1361
|
+
* @param {string} data JSON format
|
|
1362
|
+
* @param {string} [apiToken]
|
|
1363
|
+
* @param {*} [options] Override http request option.
|
|
1364
|
+
* @throws {RequiredError}
|
|
1365
|
+
* @memberof TranslationsApi
|
|
1366
|
+
*/
|
|
1367
|
+
translationsDelete(e, t, s, r, o) {
|
|
1368
|
+
return D(this.configuration).translationsDelete(e, t, s, r, o).then((c) => c(this.axios, this.basePath));
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Update Translations. More details in the [documentation](https://poeditor.com/docs/api#translations_update).
|
|
1372
|
+
* @summary Updates existing translations.
|
|
1373
|
+
* @param {number} id
|
|
1374
|
+
* @param {string} language The language code
|
|
1375
|
+
* @param {string} data JSON format
|
|
1376
|
+
* @param {string} [apiToken]
|
|
1377
|
+
* @param {*} [options] Override http request option.
|
|
1378
|
+
* @throws {RequiredError}
|
|
1379
|
+
* @memberof TranslationsApi
|
|
1380
|
+
*/
|
|
1381
|
+
translationsUpdate(e, t, s, r, o) {
|
|
1382
|
+
return D(this.configuration).translationsUpdate(e, t, s, r, o).then((c) => c(this.axios, this.basePath));
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
class pe {
|
|
1386
|
+
/**
|
|
1387
|
+
* parameter for apiKey security
|
|
1388
|
+
* @param name security name
|
|
1389
|
+
* @memberof Configuration
|
|
1390
|
+
*/
|
|
1391
|
+
apiKey;
|
|
1392
|
+
/**
|
|
1393
|
+
* parameter for basic security
|
|
1394
|
+
*
|
|
1395
|
+
* @type {string}
|
|
1396
|
+
* @memberof Configuration
|
|
1397
|
+
*/
|
|
1398
|
+
username;
|
|
1399
|
+
/**
|
|
1400
|
+
* parameter for basic security
|
|
1401
|
+
*
|
|
1402
|
+
* @type {string}
|
|
1403
|
+
* @memberof Configuration
|
|
1404
|
+
*/
|
|
1405
|
+
password;
|
|
1406
|
+
/**
|
|
1407
|
+
* parameter for oauth2 security
|
|
1408
|
+
* @param name security name
|
|
1409
|
+
* @param scopes oauth2 scope
|
|
1410
|
+
* @memberof Configuration
|
|
1411
|
+
*/
|
|
1412
|
+
accessToken;
|
|
1413
|
+
/**
|
|
1414
|
+
* override base path
|
|
1415
|
+
*
|
|
1416
|
+
* @type {string}
|
|
1417
|
+
* @memberof Configuration
|
|
1418
|
+
*/
|
|
1419
|
+
basePath;
|
|
1420
|
+
/**
|
|
1421
|
+
* override server index
|
|
1422
|
+
*
|
|
1423
|
+
* @type {number}
|
|
1424
|
+
* @memberof Configuration
|
|
1425
|
+
*/
|
|
1426
|
+
serverIndex;
|
|
1427
|
+
/**
|
|
1428
|
+
* base options for axios calls
|
|
1429
|
+
*
|
|
1430
|
+
* @type {any}
|
|
1431
|
+
* @memberof Configuration
|
|
1432
|
+
*/
|
|
1433
|
+
baseOptions;
|
|
1434
|
+
/**
|
|
1435
|
+
* The FormData constructor that will be used to create multipart form data
|
|
1436
|
+
* requests. You can inject this here so that execution environments that
|
|
1437
|
+
* do not support the FormData class can still run the generated client.
|
|
1438
|
+
*
|
|
1439
|
+
* @type {new () => FormData}
|
|
1440
|
+
*/
|
|
1441
|
+
formDataCtor;
|
|
1442
|
+
constructor(e = {}) {
|
|
1443
|
+
this.apiKey = e.apiKey, this.username = e.username, this.password = e.password, this.accessToken = e.accessToken, this.basePath = e.basePath, this.serverIndex = e.serverIndex, this.baseOptions = e.baseOptions, this.formDataCtor = e.formDataCtor;
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Check if the given MIME is a JSON MIME.
|
|
1447
|
+
* JSON MIME examples:
|
|
1448
|
+
* application/json
|
|
1449
|
+
* application/json; charset=UTF8
|
|
1450
|
+
* APPLICATION/JSON
|
|
1451
|
+
* application/vnd.company+json
|
|
1452
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
1453
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
1454
|
+
*/
|
|
1455
|
+
isJsonMime(e) {
|
|
1456
|
+
const t = new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$", "i");
|
|
1457
|
+
return e !== null && (t.test(e) || e.toLowerCase() === "application/json-patch+json");
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
class me {
|
|
1461
|
+
apiToken;
|
|
1462
|
+
projectId;
|
|
1463
|
+
axiosInstance;
|
|
1464
|
+
projectsApi;
|
|
1465
|
+
termsApi;
|
|
1466
|
+
translationsApi;
|
|
1467
|
+
constructor(e) {
|
|
1468
|
+
this.apiToken = e.apiToken, this.projectId = e.projectId, this.axiosInstance = O.create({
|
|
1469
|
+
baseURL: "https://api.poeditor.com/v2"
|
|
1470
|
+
});
|
|
1471
|
+
const t = new pe({
|
|
1472
|
+
apiKey: e.apiToken
|
|
1473
|
+
});
|
|
1474
|
+
this.projectsApi = new oe(t, void 0, this.axiosInstance), this.termsApi = new ce(t, void 0, this.axiosInstance), this.translationsApi = new de(t, void 0, this.axiosInstance);
|
|
1475
|
+
}
|
|
1476
|
+
async downloadTranslations(e) {
|
|
1477
|
+
try {
|
|
1478
|
+
const t = await this.projectsApi.projectsExport(
|
|
1479
|
+
this.projectId,
|
|
1480
|
+
e,
|
|
1481
|
+
ne.KeyValueJson,
|
|
1482
|
+
this.apiToken
|
|
1483
|
+
);
|
|
1484
|
+
if (t.data.result?.url)
|
|
1485
|
+
return (await this.axiosInstance.get(t.data.result.url)).data || {};
|
|
1486
|
+
throw new Error("No download URL received from POEditor");
|
|
1487
|
+
} catch (t) {
|
|
1488
|
+
throw new Error(`Failed to download translations for ${e}: ${t}`);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
async uploadTerms(e) {
|
|
1492
|
+
try {
|
|
1493
|
+
const t = Object.entries(e).map(([s, r]) => ({
|
|
1494
|
+
term: s,
|
|
1495
|
+
context: r.description,
|
|
1496
|
+
reference: r.file,
|
|
1497
|
+
comment: `Default: ${r.defaultMessage}`
|
|
1498
|
+
}));
|
|
1499
|
+
await this.termsApi.termsAdd(this.projectId, JSON.stringify(t), this.apiToken);
|
|
1500
|
+
} catch (t) {
|
|
1501
|
+
throw new Error(`Failed to upload terms: ${t}`);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
async uploadTranslations(e, t) {
|
|
1505
|
+
try {
|
|
1506
|
+
const s = Object.entries(e).map(([r, o]) => ({
|
|
1507
|
+
term: r,
|
|
1508
|
+
translation: {
|
|
1509
|
+
content: o.defaultMessage,
|
|
1510
|
+
fuzzy: 0
|
|
1511
|
+
}
|
|
1512
|
+
}));
|
|
1513
|
+
await this.translationsApi.translationsAdd(this.projectId, t, JSON.stringify(s), this.apiToken);
|
|
1514
|
+
} catch (s) {
|
|
1515
|
+
throw new Error(`Failed to upload translations for ${t}: ${s}`);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
async downloadTerms() {
|
|
1519
|
+
try {
|
|
1520
|
+
const e = await this.termsApi.termsList(this.projectId, this.apiToken);
|
|
1521
|
+
return e.data.result?.terms ? e.data.result.terms.map((t) => ({
|
|
1522
|
+
term: t.term || "",
|
|
1523
|
+
context: t.context || "",
|
|
1524
|
+
reference: t.reference || "",
|
|
1525
|
+
comment: t.comment || ""
|
|
1526
|
+
})) : [];
|
|
1527
|
+
} catch (e) {
|
|
1528
|
+
throw new Error(`Failed to get terms: ${e}`);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
async removeTerms(e) {
|
|
1532
|
+
try {
|
|
1533
|
+
await this.termsApi.termsDelete(this.projectId, JSON.stringify(e), this.apiToken);
|
|
1534
|
+
} catch (t) {
|
|
1535
|
+
throw new Error(`Failed to remove terms: ${t}`);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
async getTranslationsInDefaultLanguage(e) {
|
|
1539
|
+
try {
|
|
1540
|
+
let t;
|
|
1541
|
+
const s = await this.projectsApi.projectsView(this.projectId, this.apiToken);
|
|
1542
|
+
if (s.data.result?.project && (t = s.data.result.project.reference_language), !t)
|
|
1543
|
+
throw new Error("No reference language found");
|
|
1544
|
+
const r = await this.downloadTranslations(t);
|
|
1545
|
+
return e.map((o) => ({
|
|
1546
|
+
term: o.term,
|
|
1547
|
+
translation: r[o.term] || ""
|
|
1548
|
+
}));
|
|
1549
|
+
} catch (t) {
|
|
1550
|
+
throw new Error(`Failed to get translations in default language: ${t}`);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
function Ce({
|
|
1555
|
+
poeditorApiToken: a,
|
|
1556
|
+
poeditorProjectId: e
|
|
1557
|
+
}) {
|
|
1558
|
+
if (a && e)
|
|
1559
|
+
return new me({
|
|
1560
|
+
apiToken: a,
|
|
1561
|
+
projectId: e
|
|
1562
|
+
});
|
|
1563
|
+
throw new Error("No configuration for translations service client provided.");
|
|
1564
|
+
}
|
|
1565
|
+
export {
|
|
1566
|
+
W as a,
|
|
1567
|
+
be as b,
|
|
1568
|
+
ge as c,
|
|
1569
|
+
Ae as d,
|
|
1570
|
+
h as e,
|
|
1571
|
+
Se as f,
|
|
1572
|
+
Te as g,
|
|
1573
|
+
je as h,
|
|
1574
|
+
Ue as l,
|
|
1575
|
+
Ce as m,
|
|
1576
|
+
Re as s,
|
|
1577
|
+
se as u
|
|
1578
|
+
};
|