feat(libretranslate): add translate text action
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
import translateText from './translate-text/index.js';
|
||||||
|
|
||||||
|
export default [translateText];
|
@@ -0,0 +1,86 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Translate text',
|
||||||
|
key: 'translateText',
|
||||||
|
description: 'Translate a text.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Text',
|
||||||
|
key: 'text',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: 'The text to translate.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Source Language',
|
||||||
|
key: 'sourceLanguage',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listLanguages',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Target Language',
|
||||||
|
key: 'targetLanguage',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listLanguages',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Format',
|
||||||
|
key: 'format',
|
||||||
|
type: 'dropdown',
|
||||||
|
description: '',
|
||||||
|
required: false,
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Text',
|
||||||
|
value: 'text',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'HTML',
|
||||||
|
value: 'html',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const { text, sourceLanguage, targetLanguage, format } = $.step.parameters;
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
q: text,
|
||||||
|
source: sourceLanguage,
|
||||||
|
target: targetLanguage,
|
||||||
|
format,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await $.http.post('/translate', body);
|
||||||
|
|
||||||
|
$.setActionItem({ raw: response.data });
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,3 @@
|
|||||||
|
import listLanguages from './list-languages/index.js';
|
||||||
|
|
||||||
|
export default [listLanguages];
|
@@ -0,0 +1,25 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List languages',
|
||||||
|
key: 'listLanguages',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const languages = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get('/languages');
|
||||||
|
|
||||||
|
if (!data?.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const language of data) {
|
||||||
|
languages.data.push({
|
||||||
|
value: language.code,
|
||||||
|
name: language.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return languages;
|
||||||
|
},
|
||||||
|
};
|
@@ -2,6 +2,8 @@ import defineApp from '../../helpers/define-app.js';
|
|||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
import addApiKey from './common/add-api-key.js';
|
import addApiKey from './common/add-api-key.js';
|
||||||
import setBaseUrl from './common/set-base-url.js';
|
import setBaseUrl from './common/set-base-url.js';
|
||||||
|
import actions from './actions/index.js';
|
||||||
|
import dynamicData from './dynamic-data/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'LibreTranslate',
|
name: 'LibreTranslate',
|
||||||
@@ -14,4 +16,6 @@ export default defineApp({
|
|||||||
primaryColor: 'ffffff',
|
primaryColor: 'ffffff',
|
||||||
beforeRequest: [setBaseUrl, addApiKey],
|
beforeRequest: [setBaseUrl, addApiKey],
|
||||||
auth,
|
auth,
|
||||||
|
actions,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
@@ -248,6 +248,7 @@ export default defineConfig({
|
|||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
|
{ text: 'Actions', link: '/apps/libretranslate/actions' },
|
||||||
{ text: 'Connection', link: '/apps/libretranslate/connection' },
|
{ text: 'Connection', link: '/apps/libretranslate/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
12
packages/docs/pages/apps/libretranslate/actions.md
Normal file
12
packages/docs/pages/apps/libretranslate/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/libretranslate.svg
|
||||||
|
items:
|
||||||
|
- name: Translate text
|
||||||
|
desc: Translate a text.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -25,6 +25,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [HTTP Request](/apps/http-request/actions)
|
- [HTTP Request](/apps/http-request/actions)
|
||||||
- [HubSpot](/apps/hubspot/actions)
|
- [HubSpot](/apps/hubspot/actions)
|
||||||
- [Invoice Ninja](/apps/invoice-ninja/triggers)
|
- [Invoice Ninja](/apps/invoice-ninja/triggers)
|
||||||
|
- [LibreTranslate](/apps/libretranslate/actions)
|
||||||
- [Mattermost](/apps/mattermost/actions)
|
- [Mattermost](/apps/mattermost/actions)
|
||||||
- [Miro](/apps/miro/actions)
|
- [Miro](/apps/miro/actions)
|
||||||
- [Notion](/apps/notion/triggers)
|
- [Notion](/apps/notion/triggers)
|
||||||
|
Reference in New Issue
Block a user