Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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/crowdin/.gitignore

This file was deleted.

102 changes: 102 additions & 0 deletions components/crowdin/actions/add-file/add-file.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { TYPE_OPTIONS } from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import crowdin from "../../crowdin.app.mjs";

export default {
key: "crowdin-add-file",
name: "Add File to Project",
description: "Adds a file into the created project. [See the documentation](https://developer.crowdin.com/api/v2/#tag/source-files/operation/api.projects.files.post)",
version: "0.0.1",
type: "action",
props: {
crowdin,
projectId: {
propDefinition: [
crowdin,
"projectId",
],
},
storageId: {
propDefinition: [
crowdin,
"storageId",
],
},
name: {
type: "string",
label: "Name",
description: "The name of the file in Crowdin. **Note:** Can't contain `\\ / : * ? \" < > |` symbols. `ZIP` files are not allowed.",
},
branchId: {
propDefinition: [
crowdin,
"branchId",
(c) => ({
projectId: c.projectId,
}),
],
},
directoryId: {
propDefinition: [
crowdin,
"directoryId",
(c) => ({
projectId: c.projectId,
}),
],
},
title: {
type: "string",
label: "Title",
description: "Use to provide more details for translators. Title is available in UI only",
optional: true,
},
context: {
type: "string",
label: "Context",
description: "Use to provide context about whole file",
optional: true,
},
type: {
type: "string",
label: "File Type",
description: "The type of the file. **Note:** Use `docx` type to import each cell as a separate source string for XLSX file. Default is `auto`",
options: TYPE_OPTIONS,
optional: true,
},
parserVersion: {
type: "integer",
label: "Parser Version",
description: "Using latest parser version by default. **Note:** Must be used together with `type`.",
optional: true,
},
attachLabelIds: {
propDefinition: [
crowdin,
"attachLabelIds",
(c) => ({
projectId: c.projectId,
}),
],
},
},
async run({ $ }) {
const {
crowdin,
attachLabelIds,
projectId,
...data
} = this;

const response = await crowdin.uploadFileToProject({
$,
projectId,
data: {
...data,
attachLabelIds: parseObject(attachLabelIds),
},
});
$.export("$summary", `Successfully uploaded file: ${this.name}`);
return response;
},
};
184 changes: 184 additions & 0 deletions components/crowdin/actions/create-project/create-project.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import { ConfigurationError } from "@pipedream/platform";
import {
LANGUAGE_ACCESS_POLICY_OPTIONS,
TAGS_DETECTION_OPTIONS,
VISIBILITY_OPTIONS,
} from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import crowdin from "../../crowdin.app.mjs";

export default {
key: "crowdin-create-project",
name: "Create Project",
description: "Creates a new project within Crowdin. [See the documentation](https://support.crowdin.com/developer/api/v2/#/projects-api/create-project)",
version: "0.0.1",
type: "action",
props: {
crowdin,
name: {
type: "string",
label: "Project Name",
description: "The name of the project to be created",
},
sourceLanguageId: {
propDefinition: [
crowdin,
"sourceLanguageId",
],
},
targetLanguageIds: {
propDefinition: [
crowdin,
"sourceLanguageId",
],
type: "string[]",
label: "Target Language IDs",
description: "Array of target language IDs",
optional: true,
},
identifier: {
type: "string",
label: "Identifier",
description: "A custom identifier for the project",
optional: true,
},
visibility: {
type: "string",
label: "Visibility",
description: "Defines how users can join the project.",
options: VISIBILITY_OPTIONS,
optional: true,
},
languageAccessPolicy: {
type: "string",
label: "Language Access Policy",
description: "Defines access to project languages.",
optional: true,
options: LANGUAGE_ACCESS_POLICY_OPTIONS,
},
cname: {
type: "string",
label: "Custom Domain Name",
description: "Custom domain name for the project.",
optional: true,
},
description: {
type: "string",
label: "Project Description",
description: "The description of the project.",
optional: true,
},
tagsDetection: {
type: "string",
label: "Tags Detection",
description: "The type of the tags detection.",
options: TAGS_DETECTION_OPTIONS,
optional: true,
},
isMtAllowed: {
type: "boolean",
label: "Allow Machine Translation",
description: "Allows machine translations to be visible for translators. Default is **true**.",
optional: true,
},
taskBasedAccessControl: {
type: "boolean",
label: "Task Based Access Control",
description: "Allow project members to work with tasks they're assigned to. Default is **false**.",
optional: true,
default: false,
},
autoSubstitution: {
type: "boolean",
label: "Auto Substitution",
description: "Allows auto-substitution. Default is **true**.",
optional: true,
default: true,
},
autoTranslateDialects: {
type: "boolean",
label: "Auto Translate Dialects",
description: "Automatically fill in regional dialects. Default is **false**.",
optional: true,
},
publicDownloads: {
type: "boolean",
label: "Public Downloads",
description: "Allows translators to download source files. Default is **true**.",
optional: true,
},
hiddenStringsProofreadersAccess: {
type: "boolean",
label: "Hidden Strings Proofreaders Access",
description: "Allows proofreaders to work with hidden strings. Default is **true**.",
optional: true,
default: true,
},
useGlobalTm: {
type: "boolean",
label: "Use Global Translation Memory",
description: "If true, machine translations from connected MT engines will appear as suggestions. Default is **true**.",
optional: true,
},
showTmSuggestionsDialects: {
type: "boolean",
label: "Show TM Suggestions for Dialects",
description: "Show primary language TM suggestions for dialects if there are no dialect-specific ones. Default is **true**.",
optional: true,
default: true,
},
skipUntranslatedStrings: {
type: "boolean",
label: "Skip Untranslated Strings",
description: "Defines whether to skip untranslated strings.",
optional: true,
},
exportApprovedOnly: {
type: "boolean",
label: "Export Approved Only",
description: "Defines whether to export only approved strings.",
optional: true,
},
qaCheckIsActive: {
type: "boolean",
label: "QA Check Is Active",
description: "If true, QA checks are active. Default is **true**.",
optional: true,
},
type: {
type: "string",
label: "Type",
description: "Defines the project type. To create a file-based project, use 0.",
options: [
"0",
"1",
],
optional: true,
},
},
async run({ $ }) {
try {
const {
crowdin,
type,
targetLanguageIds,
tagsDetection,
...data
} = this;

const response = await crowdin.createProject({
$,
data: {
...data,
type: parseInt(type),
targetLanguageIds: parseObject(targetLanguageIds),
tagsDetection: parseInt(tagsDetection),
},
});
$.export("$summary", `Project created successfully with Id: ${response.data.id}`);
return response;
} catch ({ response }) {
throw new ConfigurationError(response.data.errors[0]?.error?.errors[0]?.message);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { LANGUAGE_R_PROVIDER_OPTIONS } from "../../common/constants.mjs";
import crowdin from "../../crowdin.app.mjs";

export default {
key: "crowdin-translate-via-machine-translation",
name: "Translate via Machine Translation",
description: "Performs machine translation of the uploaded files. [See the documentation](https://support.crowdin.com/developer/api/v2/)",
version: "0.0.1",
type: "action",
props: {
crowdin,
mtId: {
propDefinition: [
crowdin,
"mtId",
],
},
targetLanguageId: {
propDefinition: [
crowdin,
"sourceLanguageId",
],
type: "string",
label: "Target Language ID",
description: "The language ID for the target translation language",
},
languageRecognitionProvider: {
type: "string",
label: "Language Recognition Provider",
description: "Select a provider for language recognition **Note:** Is required if the source language is not selected",
options: LANGUAGE_R_PROVIDER_OPTIONS,
},
sourceLanguageId: {
propDefinition: [
crowdin,
"sourceLanguageId",
],
},
strings: {
type: "string[]",
label: "Strings",
description: "Array of strings to be translated. **Note:** You can translate up to 100 strings at a time.",
},
},
async run({ $ }) {
const response = await this.crowdin.performMachineTranslation({
$,
mtId: this.mtId,
data: {
targetLanguageId: this.targetLanguageId,
strings: this.strings,
languageRecognitionProvider: this.languageRecognitionProvider,
sourceLanguageId: this.sourceLanguageId,
},
});

$.export("$summary", "Successfully performed machine translation");
return response;
},
};
13 changes: 0 additions & 13 deletions components/crowdin/app/crowdin.app.ts

This file was deleted.

Loading
Loading