The pre-import module allows you to modify your files before importing them to Crowdin. With the pre-import module, you can apply automated modifications to selected files. This module can work with a wide range of file formats, such as TXT, XML, JSON, and many more, to customize their contents.
By using the pre-import module in your Crowdin app, you can adjust the file format, structure, and content. Since the module is executed before Crowdin imports the file, you can fine-tune the content before the file is processed by the system.
You can grant access to this module to one of the following user categories:
For Crowdin:
For Crowdin Enterprise:
{
"file-pre-import": [
{
"key": "your-pre-import-module-key",
"url": "/import-file",
"signaturePatterns": {
"fileName": "^.+\\.xml$",
"fileContent": "<properties>\\s*<property\\s+name=.*value=.*/>"
}
}
]
}
key | Type: Required: yes Description: Module identifier within the Crowdin app. |
url | Type: Required: yes Description: The relative URL triggered on file import, update, and translation upload. |
signaturePatterns | Type: Description: Contains Note: fileContent regular expression checks only the first 64 KB of the file content. |
When importing a file, Crowdin detects an appropriate module using the signaturePatterns
parameter and makes an HTTP request to the app’s URL ($baseUrl . $url
) for further processing.
Additionally, during the file import, Crowdin will also validate the file name and content to ensure they match the appropriate file processing app modules. This process can include the pre-import processing module to modify the content of the file before it is imported and the post-import processing module to modify the strings extracted from the file.
To modify the file content, the system first locates the appropriate pre-import module and sends the file content to it. The module then performs the predetermined modifications, which may include file format changes, structure, and content updates.
Once the pre-import module has completed the file modifications, Crowdin receives the modified file content, as well as a new file name or extension if applicable.
Request payload example:
// max request payload - 5 MB
// wait timeout - 2 minutes
{
"jobType": "file-pre-import",
"organization": {
"id": 1,
"domain": "{domain}",
"baseUrl": "https://{domain}.crowdin.com",
"apiBaseUrl": "https://{domain}.api.crowdin.com"
},
"project": {
"id": 1,
"identifier": "your-project-identifier",
"name": "Your Project Name"
},
"file": {
"id": 1,
"name": "file.xml",
"content": "VGhpcyBpcyBmaWxlIGNvbnRlbnQ=", // base64 encoded source file content
"contentUrl": "https://crowdin-tmp.downloads.crowdin.com/1/file.xml?aws-signature=..." // source file public URL
},
"sourceLanguage": {
"id": "es",
"name": "Spanish",
"editorCode": "es",
"twoLettersCode": "es",
"threeLettersCode": "spa",
"locale": "es-ES",
"androidCode": "es-rES",
"osxCode": "es.lproj",
"osxLocale": "es",
"pluralCategoryNames": ["one"],
"pluralRules": "(n != 1)"
},
"targetLanguages": [
{
// same structure as for sourceLanguage, empty when uploading a new source file, one element for import_translations, can be more for miltilingual files
}
]
}
Properties:
jobType | Type: Value: Description: Specifies the action of the file pre-import module. |
file.content , file.contentUrl | Type: Description: Parameters used to pass the base64 encoded source file content ( |
Response payload example:
// max response payload - 5 MB
// wait timeout - 2 minutes
{
"data": {
"content": "VGhpcyBpcyBmaWxlIGNvbnRlbnQ=", // base64 encoded modified file content
"contentUrl": "https://crowdin-tmp.downloads.crowdin.com/1/file.xml?aws-signature=...", // modified file public URL
"fileName": "file.html", // optional, new file name with extension
"fileType": "webxml" // optional, an importer Crowdin should use to import a file
},
"error": {
"message": "Your error message"
}
}
Properties:
data.content , data.contentUrl | Type(data.content): Type(data.contentUrl): Description: Parameters used to pass the base64 encoded modified file content ( |
fileName | Type: Description: Optional parameter used to overwrite a file name and extension with a new one. |
fileType | Type: Description: Optional parameter to specify an importer Crowdin should use to import a file. |
error.message | Type: Description: An error message that can be passed from the app to Crowdin and will be visible to a user in the UI. |