Skip to content

Commit 1e5d90e

Browse files
committed
crowdin init
1 parent 7f501a2 commit 1e5d90e

File tree

8 files changed

+917
-1
lines changed

8 files changed

+917
-1
lines changed
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
import crowdin from "../../crowdin.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "crowdin-create-project",
6+
name: "Create Project",
7+
description: "Creates a new project within Crowdin. [See the documentation](https://support.crowdin.com/developer/api/v2/#/projects-api/create-project)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
crowdin,
12+
name: {
13+
type: "string",
14+
label: "Project Name",
15+
description: "The name of the project to be created",
16+
},
17+
sourceLanguageId: {
18+
propDefinition: [
19+
crowdin,
20+
"sourceLanguageId",
21+
],
22+
},
23+
targetLanguageIds: {
24+
propDefinition: [
25+
crowdin,
26+
"targetLanguageIds",
27+
],
28+
optional: true,
29+
},
30+
identifier: {
31+
type: "string",
32+
label: "Identifier",
33+
description: "A custom identifier for the project",
34+
optional: true,
35+
},
36+
type: {
37+
type: "integer",
38+
label: "Type",
39+
description: "Defines the project type. To create a file-based project, use 0.",
40+
optional: true,
41+
},
42+
visibility: {
43+
type: "string",
44+
label: "Visibility",
45+
description: "Defines how users can join the project.",
46+
optional: true,
47+
options: [
48+
"open",
49+
"private",
50+
],
51+
default: "private",
52+
},
53+
languageAccessPolicy: {
54+
type: "string",
55+
label: "Language Access Policy",
56+
description: "Defines access to project languages.",
57+
optional: true,
58+
options: [
59+
"open",
60+
"moderate",
61+
],
62+
default: "open",
63+
},
64+
cname: {
65+
type: "string",
66+
label: "Custom Domain Name",
67+
description: "Custom domain name for the project.",
68+
optional: true,
69+
},
70+
description: {
71+
type: "string",
72+
label: "Project Description",
73+
description: "The description of the project.",
74+
optional: true,
75+
},
76+
tagsDetection: {
77+
type: "integer",
78+
label: "Tags Detection",
79+
description: "Values available: 0 - Auto, 1 - Count tags, 2 - Skip tags.",
80+
optional: true,
81+
default: 0,
82+
},
83+
isMtAllowed: {
84+
type: "boolean",
85+
label: "Allow Machine Translation",
86+
description: "Allows machine translations to be visible for translators.",
87+
optional: true,
88+
default: true,
89+
},
90+
taskBasedAccessControl: {
91+
type: "boolean",
92+
label: "Task Based Access Control",
93+
description: "Allow project members to work with tasks they're assigned to.",
94+
optional: true,
95+
default: false,
96+
},
97+
autoSubstitution: {
98+
type: "boolean",
99+
label: "Auto Substitution",
100+
description: "Allows auto-substitution.",
101+
optional: true,
102+
default: true,
103+
},
104+
autoTranslateDialects: {
105+
type: "boolean",
106+
label: "Auto Translate Dialects",
107+
description: "Automatically fill in regional dialects.",
108+
optional: true,
109+
default: false,
110+
},
111+
publicDownloads: {
112+
type: "boolean",
113+
label: "Public Downloads",
114+
description: "Allows translators to download source files.",
115+
optional: true,
116+
default: true,
117+
},
118+
hiddenStringsProofreadersAccess: {
119+
type: "boolean",
120+
label: "Hidden Strings Proofreaders Access",
121+
description: "Allows proofreaders to work with hidden strings.",
122+
optional: true,
123+
default: true,
124+
},
125+
useGlobalTm: {
126+
type: "boolean",
127+
label: "Use Global Translation Memory",
128+
description: "If true, machine translations from connected MT engines will appear as suggestions.",
129+
optional: true,
130+
},
131+
showTmSuggestionsDialects: {
132+
type: "boolean",
133+
label: "Show TM Suggestions for Dialects",
134+
description: "Show primary language TM suggestions for dialects if there are no dialect-specific ones.",
135+
optional: true,
136+
default: true,
137+
},
138+
skipUntranslatedStrings: {
139+
type: "boolean",
140+
label: "Skip Untranslated Strings",
141+
description: "Defines whether to skip untranslated strings.",
142+
optional: true,
143+
},
144+
exportApprovedOnly: {
145+
type: "boolean",
146+
label: "Export Approved Only",
147+
description: "Defines whether to export only approved strings.",
148+
optional: true,
149+
},
150+
qaCheckIsActive: {
151+
type: "boolean",
152+
label: "QA Check Is Active",
153+
description: "If true, QA checks are active.",
154+
optional: true,
155+
default: true,
156+
},
157+
savingsReportSettingsTemplateId: {
158+
type: "integer",
159+
label: "Savings Report Settings Template ID",
160+
description: "Report Settings Templates Identifier.",
161+
optional: true,
162+
async options() {
163+
const templates = await this.crowdin.listSavingsReportSettingsTemplates();
164+
return templates.map((template) => ({
165+
label: template.name,
166+
value: template.id,
167+
}));
168+
},
169+
},
170+
defaultTmId: {
171+
type: "integer",
172+
label: "Default TM ID",
173+
description: "Translation Memory ID. If omitted, a new translation memory will be created.",
174+
optional: true,
175+
async options() {
176+
const tms = await this.crowdin.listTMs();
177+
return tms.map((tm) => ({
178+
label: tm.name,
179+
value: tm.id,
180+
}));
181+
},
182+
},
183+
defaultGlossaryId: {
184+
type: "integer",
185+
label: "Default Glossary ID",
186+
description: "Glossary ID. If omitted, a new Glossary will be created.",
187+
optional: true,
188+
async options() {
189+
const glossaries = await this.crowdin.listGlossaries();
190+
return glossaries.map((glossary) => ({
191+
label: glossary.name,
192+
value: glossary.id,
193+
}));
194+
},
195+
},
196+
},
197+
async run({ $ }) {
198+
const data = {
199+
name: this.name,
200+
sourceLanguageId: this.sourceLanguageId,
201+
identifier: this.identifier,
202+
type: this.type,
203+
targetLanguageIds: this.targetLanguageIds,
204+
visibility: this.visibility,
205+
languageAccessPolicy: this.languageAccessPolicy,
206+
cname: this.cname,
207+
description: this.description,
208+
tagsDetection: this.tagsDetection,
209+
isMtAllowed: this.isMtAllowed,
210+
taskBasedAccessControl: this.taskBasedAccessControl,
211+
autoSubstitution: this.autoSubstitution,
212+
autoTranslateDialects: this.autoTranslateDialects,
213+
publicDownloads: this.publicDownloads,
214+
hiddenStringsProofreadersAccess: this.hiddenStringsProofreadersAccess,
215+
useGlobalTm: this.useGlobalTm,
216+
showTmSuggestionsDialects: this.showTmSuggestionsDialects,
217+
skipUntranslatedStrings: this.skipUntranslatedStrings,
218+
exportApprovedOnly: this.exportApprovedOnly,
219+
qaCheckIsActive: this.qaCheckIsActive,
220+
savingsReportSettingsTemplateId: this.savingsReportSettingsTemplateId,
221+
defaultTmId: this.defaultTmId,
222+
defaultGlossaryId: this.defaultGlossaryId,
223+
};
224+
225+
const response = await this.crowdin.createProject(data);
226+
$.export("$summary", `Project "${response.name}" created successfully`);
227+
return response;
228+
},
229+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import crowdin from "../../crowdin.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "crowdin-translate-via-machine-translation",
6+
name: "Translate via Machine Translation",
7+
description: "Performs machine translation of the uploaded files. [See the documentation](https://support.crowdin.com/developer/api/v2/)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
crowdin,
12+
mtId: {
13+
propDefinition: [
14+
crowdin,
15+
"mtId",
16+
],
17+
},
18+
targetLanguageId: {
19+
type: "string",
20+
label: "Target Language ID",
21+
description: "The language ID for the target translation language",
22+
async options() {
23+
const languages = await this.crowdin.listSupportedLanguages();
24+
return languages.map((language) => ({
25+
label: language.name,
26+
value: language.id,
27+
}));
28+
},
29+
},
30+
strings: {
31+
propDefinition: [
32+
crowdin,
33+
"strings",
34+
],
35+
},
36+
languageRecognitionProvider: {
37+
type: "string",
38+
label: "Language Recognition Provider",
39+
description: "Optional language recognition provider",
40+
optional: true,
41+
},
42+
sourceLanguageId: {
43+
type: "string",
44+
label: "Source Language ID",
45+
description: "The language ID of the source language",
46+
async options() {
47+
const languages = await this.crowdin.listSupportedLanguages();
48+
return languages.map((language) => ({
49+
label: language.name,
50+
value: language.id,
51+
}));
52+
},
53+
},
54+
},
55+
async run({ $ }) {
56+
const response = await this.crowdin.performMachineTranslation({
57+
mtId: this.mtId,
58+
targetLanguageId: this.targetLanguageId,
59+
strings: this.strings,
60+
languageRecognitionProvider: this.languageRecognitionProvider,
61+
sourceLanguageId: this.sourceLanguageId,
62+
});
63+
64+
$.export("$summary", "Successfully performed machine translation");
65+
return response;
66+
},
67+
};

0 commit comments

Comments
 (0)