@crowdin/app-project-module 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -69,9 +69,19 @@ function handleParseFile(baseUrl, dataFolder, config, file, req) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
if (res.strings) {
|
|
72
|
-
|
|
72
|
+
let strings = res.strings;
|
|
73
|
+
if (config.autoUploadTranslations) {
|
|
74
|
+
strings = strings.map(string => {
|
|
75
|
+
const translations = {};
|
|
76
|
+
req.targetLanguages
|
|
77
|
+
.map(targetLanguage => targetLanguage.id)
|
|
78
|
+
.forEach(targetLanguage => (translations[targetLanguage] = { text: string.text }));
|
|
79
|
+
return Object.assign(Object.assign({}, string), { translations });
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const stringsJson = JSON.stringify(strings);
|
|
73
83
|
if (Buffer.byteLength(stringsJson, 'utf8') < MAX_BODY_SIZE) {
|
|
74
|
-
response.strings =
|
|
84
|
+
response.strings = strings;
|
|
75
85
|
}
|
|
76
86
|
else {
|
|
77
87
|
const storedFile = yield storeFile(stringsJson, dataFolder);
|
package/out/models/index.d.ts
CHANGED
|
@@ -329,9 +329,13 @@ export interface CustomFileFormatLogic {
|
|
|
329
329
|
*/
|
|
330
330
|
multilingual?: boolean;
|
|
331
331
|
/**
|
|
332
|
-
*
|
|
332
|
+
* Contains fileName and/or fileContent regular expressions used to detect file type when uploading a new source file via UI (or via API without specified type parameter). If the file matches regular expressions, it's labeled as a custom format file.
|
|
333
333
|
*/
|
|
334
334
|
signaturePatterns?: SignaturePatterns;
|
|
335
|
+
/**
|
|
336
|
+
* Flag to automatically upload translations
|
|
337
|
+
*/
|
|
338
|
+
autoUploadTranslations?: boolean;
|
|
335
339
|
/**
|
|
336
340
|
* Used for initial source file upload, source file update, and translation upload
|
|
337
341
|
*/
|
|
@@ -379,7 +383,12 @@ export interface ProcessFileString {
|
|
|
379
383
|
hasPlurals?: boolean;
|
|
380
384
|
labels?: string[];
|
|
381
385
|
text: string | SourceStringsModel.PluralText;
|
|
382
|
-
translations?:
|
|
386
|
+
translations?: StringTranslations;
|
|
387
|
+
}
|
|
388
|
+
export interface StringTranslations {
|
|
389
|
+
[language: string]: {
|
|
390
|
+
text: string | SourceStringsModel.PluralText;
|
|
391
|
+
};
|
|
383
392
|
}
|
|
384
393
|
export interface CustomMTLogic {
|
|
385
394
|
translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number, source: string, target: string, strings: string[]) => Promise<string[]>;
|
|
@@ -61,6 +61,8 @@
|
|
|
61
61
|
<crowdin-toasts></crowdin-toasts>
|
|
62
62
|
</body>
|
|
63
63
|
<script type="text/javascript">
|
|
64
|
+
const loginButton = document.querySelector('crowdin-button');
|
|
65
|
+
|
|
64
66
|
function oauthLogin() {
|
|
65
67
|
const url = '{{{ oauthUrl }}}';
|
|
66
68
|
const oauthWindow = window.open(url, '{{ name }}', 'location=0,status=0,width=800,height=400');
|
|
@@ -86,6 +88,8 @@
|
|
|
86
88
|
{{/ifeq}}
|
|
87
89
|
{{/each}}
|
|
88
90
|
};
|
|
91
|
+
loginButton.setAttribute('disabled', true);
|
|
92
|
+
loginButton.setAttribute('is-loading', true);
|
|
89
93
|
checkOrigin()
|
|
90
94
|
.then(queryParams =>
|
|
91
95
|
fetch(`api/login${queryParams}`, {
|
|
@@ -96,7 +100,11 @@
|
|
|
96
100
|
)
|
|
97
101
|
.then(checkResponse)
|
|
98
102
|
.then(reloadLocation)
|
|
99
|
-
.catch(e => catchRejection(e, 'Credentials are not stored'))
|
|
103
|
+
.catch(e => catchRejection(e, 'Credentials are not stored'))
|
|
104
|
+
.finally(() => {
|
|
105
|
+
loginButton.setAttribute('disabled', false);
|
|
106
|
+
loginButton.setAttribute('is-loading', false);
|
|
107
|
+
});
|
|
100
108
|
}
|
|
101
109
|
</script>
|
|
102
110
|
|
package/package.json
CHANGED