@translated/lara
Version:
Official Lara SDK for JavaScript and Node.js
38 lines (37 loc) • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageTranslator = void 0;
class ImageTranslator {
constructor(client) {
this.client = client;
}
async translate(file, source, target, options) {
const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { "X-No-Trace": "true" } : {};
headers["Content-Type"] = "multipart/form-data";
return this.client.post(`/v2/images/translate`, {
source,
target,
adapt_to: JSON.stringify(options === null || options === void 0 ? void 0 : options.adaptTo),
glossaries: JSON.stringify(options === null || options === void 0 ? void 0 : options.glossaries),
style: options === null || options === void 0 ? void 0 : options.style,
text_removal: options === null || options === void 0 ? void 0 : options.textRemoval
}, {
image: file
}, headers, true);
}
async translateText(file, source, target, options) {
const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { "X-No-Trace": "true" } : {};
headers["Content-Type"] = "multipart/form-data";
return this.client.post(`/v2/images/translate-text`, {
source,
target,
adapt_to: JSON.stringify(options === null || options === void 0 ? void 0 : options.adaptTo),
glossaries: JSON.stringify(options === null || options === void 0 ? void 0 : options.glossaries),
style: options === null || options === void 0 ? void 0 : options.style,
verbose: JSON.stringify(options === null || options === void 0 ? void 0 : options.verbose)
}, {
image: file
}, headers);
}
}
exports.ImageTranslator = ImageTranslator;