mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
⚡ Populate translations without blocking
This commit is contained in:
parent
e22febb3f3
commit
a07f0ea575
|
@ -1193,22 +1193,32 @@ class App {
|
|||
}, []);
|
||||
}
|
||||
|
||||
const nodeTypes: INodeTypeDescription[] = [];
|
||||
|
||||
for (const { name, version } of nodeInfos) {
|
||||
async function populateTranslation(
|
||||
name: string,
|
||||
version: number,
|
||||
nodeTypes: INodeTypeDescription[],
|
||||
) {
|
||||
const { description, sourcePath } = NodeTypes().getWithSourcePath(name, version);
|
||||
const translationPath = await getNodeTranslationPath(sourcePath, defaultLocale);
|
||||
|
||||
try {
|
||||
const translation = await readFile(translationPath, 'utf8');
|
||||
description.translation = JSON.parse(translation);
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (error) {
|
||||
// file not accessible
|
||||
// ignore - no translation at expected translation path
|
||||
}
|
||||
|
||||
nodeTypes.push(description);
|
||||
}
|
||||
|
||||
const nodeTypes: INodeTypeDescription[] = [];
|
||||
|
||||
const promises = nodeInfos.map(async ({ name, version }) =>
|
||||
populateTranslation(name, version, nodeTypes),
|
||||
);
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
return nodeTypes;
|
||||
},
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue