Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/translate_com/.gitignore

This file was deleted.

50 changes: 50 additions & 0 deletions components/translate_com/actions/translate-text/translate-text.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../translate_com.app.mjs";

export default {
name: "Translate Text",
version: "0.0.1",
key: "translate_com-translate-text",
description: "Translante a text using machine. [See the documentation](https://translation-api.translate.com/api/documentation?_gl=1*1qes1da*_ga*MTMwNzkzMTg3OC4xNjk1NDE3MDIy*_ga_T51KL347BB*MTY5NTQxNzAyMS4xLjAuMTY5NTQxNzAyMS42MC4wLjA.#/Machine Translation)",
type: "action",
props: {
app,
sourceLanguage: {
label: "Source language",
description: "The language of the source text",
propDefinition: [
app,
"language",
],
},
translationLanguage: {
type: "string",
label: "Translation language",
description: "The translation language",
propDefinition: [
app,
"language",
],
},
text: {
type: "string",
label: "Text",
description: "Text to be translated",
},
},
async run({ $ }) {
const response = await this.app.translateText({
$,
data: {
source_language: this.sourceLanguage,
translation_language: this.translationLanguage,
text: this.text,
},
});

if (response) {
$.export("$summary", "Successfully translated text");
}

return response;
},
};
13 changes: 0 additions & 13 deletions components/translate_com/app/translate_com.app.ts

This file was deleted.

7 changes: 3 additions & 4 deletions components/translate_com/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"name": "@pipedream/translate_com",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Translate.com Components",
"main": "dist/app/translate_com.app.mjs",
"main": "translate_com.app.mjs",
"keywords": [
"pipedream",
"translate_com"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/translate_com",
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
}
}
}
54 changes: 54 additions & 0 deletions components/translate_com/translate_com.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "translate_com",
propDefinitions: {
language: {
type: "string",
label: "Language",
description: "A language",
async options() {
const languages = await this.getLanguages();

return languages.map((language) => ({
value: language.code,
label: language.name,
}));
},
},
},
methods: {
_apiKey() {
return this.$auth.api_key;
},
_apiUrl() {
return "https://translation-api.translate.com/translate/v1";
},
async _makeRequest({
$ = this, path, ...args
}) {
return axios($, {
url: `${this._apiUrl()}${path}`,
...args,
headers: {
...args.headers,
"x-api-key": this._apiKey(),
},
});
},
translateText(args = {}) {
return this._makeRequest({
path: "/mt",
method: "post",
...args,
});
},
getLanguages(args = {}) {
return this._makeRequest({
path: "/mt-langs",
...args,
});
},
},
};