The app allows you to generate a resource files out of translate Crowdin strings.
This app allows you to create your own simple bundle generator using JavaScript.
JavaScript code is executed in a sandboxed environment with no access to I/O (file system, network) or external NPM modules.
This application will expose the following variables in the global environment:
strings
- an array of objects containing all strings that Crowdin has identified as translatable. Please refer to the Developer Portal to learn more about the data structures.projectId
- the Crowdin project ID;error
- the error message to return. If set, the import will be aborted and the error message will be shown to the user;code
- this variable should contain the content (string) of the file to be exported after your code is executed;const result = strings.map(s => {
return {
id: s.identifier,
text: s.translations[languageId].text
}
})
content = JSON.stringify(result);
a JSON with plurals serialized for Vue i18n lib
let result = {};
strings.map(s => {
if (s.hasPlurals) {
result[s.identifier] = Object.values(s.translations[languageId].text).join(' | ');
} else {
result[s.identifier] = s.translations[languageId].text;
}
});
content = JSON.stringify(result);
This code exports strings as JSON, an array of objects with two properties, id
and text
.
Crowdin is a platform that helps you manage and translate content into different languages. Integrate Crowdin with your repo, CMS, or other systems. Source content is always up to date for your translators, and translated content is returned automatically.
Learn MoreReleased on Sep 23, 2023
Updated on Jul 30, 2024
Published by Awesome Crowdin
Identifier:custom-bundle-generator