Skip to content

Context Menu

The module allows creating the item in the context menu where possible. A context menu item can open a specified app module with additional context related to the selected record or custom URL.

Sample

Redirect to Integration App

index.js
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
contextMenu: {
location: 'source_file',
type: 'redirect',
module: 'project-integrations'
},
projectIntegration: {
// integration app logic
}
}

Open in New Tab

index.js
const crowdinModule = require('@crowdin/app-project-module');
const app = crowdinModule.express();
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
contextMenu: {
location: 'source_file',
type: 'new_tab',
uiPath: __dirname + '/' + 'public',
signaturePatterns: {
fileName: '.*.json'
},
name: 'Check file structure'
}
};
const crowdinApp = crowdinModule.addCrowdinEndpoints(app, configuration);
app.get('/result', (req, res) => {
res.json({
organizationId: req.query.organization_id,
projectId: req.query.project_id,
fileId: req.query.file_id
});
});
app.listen(3000, () => console.log('Crowdin app started'));

Please note that the App defines a new endpoint /result by utilizing the Express instance provided by the Crowdin module. The endpoint is used to receive the context data from the Crowdin app.

Open Modal

index.js
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
modal: {
formSchema: {
26 collapsed lines
"title": "A registration form",
"description": "A simple form example.",
"type": "object",
"required": [
"firstName",
"lastName"
],
"properties": {
"firstName": {
"type": "string",
"title": "First name",
"default": "Chuck"
},
"lastName": {
"type": "string",
"title": "Last name"
}
}
},
formUiSchema: {
"ui:submitButtonOptions": {
"submitText": "Confirm Details"
},
"lastName": {
"ui:help": "Hint: Choose cool lastname!"
}
}
},
contextMenu: {
location: 'source_file',
type: 'modal',
module: 'modal'
}
};

Read more about Modal and React JSON Schema forms.

Configuration

Parameter
DescriptionAllowed values
locationThe location in UI where the context menu can be added.tm, glossary, language, screenshot, source_file, translated_file
typeThe type of action this module will perform.modal, new_tab, redirect
moduleUI Modules type.modal, redirect
uiPathFolder where UI of the module is located (js, html, css files).-
nameThe label of the context menu item displayed to the user.-
signaturePatternsContains fileName and/or nodeType used to detect file-

Detecting File Type

index.js
signaturePatterns: {
fileName: '.*.json',
nodeType: [0, 1]
},
Parameter
DescriptionAllowed values
fileNameContains fileName regular expressions used to detect file type.Regex
nodeTypeArray of node types0 - folder, 1 - file, 2 - branch