diff --git a/packages/cli/src/NodeTypes.ts b/packages/cli/src/NodeTypes.ts index 5cc9e956ab..046123927b 100644 --- a/packages/cli/src/NodeTypes.ts +++ b/packages/cli/src/NodeTypes.ts @@ -41,10 +41,9 @@ class NodeTypesClass implements INodeTypes { } /** - * Variant of `getByNameAndVersion` that includes the node's source path, - * to be used for locating the node's `/translations` dir. + * Variant of `getByNameAndVersion` that includes the node's source path, used to locate a node's translations. */ - getWithPath( + getWithSourcePath( nodeTypeName: string, version: number, ): { description: INodeTypeDescription } & { sourcePath: string } { diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index e72e455811..9d3bb4ea7f 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -25,6 +25,8 @@ /* eslint-disable no-restricted-syntax */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable import/no-dynamic-require */ +/* eslint-disable no-await-in-loop */ + import * as express from 'express'; import { readFileSync, existsSync } from 'fs'; import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path'; @@ -145,7 +147,7 @@ import { InternalHooksManager } from './InternalHooksManager'; import { TagEntity } from './databases/entities/TagEntity'; import { WorkflowEntity } from './databases/entities/WorkflowEntity'; import { NameRequest } from './WorkflowHelpers'; -import { getExpectedNodeTranslationPath } from './TranslationHelpers'; +import { getNodeTranslationPath } from './TranslationHelpers'; require('body-parser-xml')(bodyParser); @@ -1179,33 +1181,28 @@ class App { ResponseHelper.send( async (req: express.Request, res: express.Response): Promise => { const nodeInfos = _.get(req, 'body.nodeInfos', []) as INodeTypeNameVersion[]; - const nodeTypes = NodeTypes(); - const language = config.get('defaultLocale') ?? req.headers['accept-language'] ?? 'en'; if (language === 'en') { return nodeInfos.reduce((acc, { name, version }) => { - const { description } = nodeTypes.getByNameAndVersion(name, version); + const { description } = NodeTypes().getByNameAndVersion(name, version); acc.push(description); return acc; }, []); } - const nodeTypesWithTranslations: INodeTypeDescription[] = []; + const nodeTypes: INodeTypeDescription[] = []; for (const { name, version } of nodeInfos) { - const { description, sourcePath } = nodeTypes.getWithPath(name, version); - // eslint-disable-next-line no-await-in-loop - const nodeTranslationPath = await getExpectedNodeTranslationPath(sourcePath, language); - - if (existsSync(nodeTranslationPath)) { - description.translation = require(nodeTranslationPath); + const { description, sourcePath } = NodeTypes().getWithSourcePath(name, version); + const translationPath = await getNodeTranslationPath(sourcePath, language); + if (existsSync(translationPath)) { + description.translation = require(translationPath); } - - nodeTypesWithTranslations.push(description); + nodeTypes.push(description); } - return nodeTypesWithTranslations; + return nodeTypes; }, ), ); @@ -2896,6 +2893,12 @@ export async function start(): Promise { console.log(`n8n ready on ${ADDRESS}, port ${PORT}`); console.log(`Version: ${versions.cli}`); + const defaultLocale = config.get('defaultLocale'); + + if (!defaultLocale || defaultLocale !== 'en') { + console.log(`Locale: ${config.get('defaultLocale')}`); + } + await app.externalHooks.run('n8n.ready', [app]); const cpus = os.cpus(); const diagnosticInfo: IDiagnosticInfo = { diff --git a/packages/cli/src/TranslationHelpers.ts b/packages/cli/src/TranslationHelpers.ts index 9ebbc577a3..5f152b96e5 100644 --- a/packages/cli/src/TranslationHelpers.ts +++ b/packages/cli/src/TranslationHelpers.ts @@ -26,7 +26,7 @@ async function getMaxVersion(from: string) { return Math.max(...dirnames.map((d) => parseInt(d.charAt(1), 10))); } -export async function getExpectedNodeTranslationPath( +export async function getNodeTranslationPath( nodeSourcePath: string, language: string, ): Promise { diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialConfig.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialConfig.vue index 05827a1cb7..c92c07b7ee 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialConfig.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialConfig.vue @@ -203,17 +203,12 @@ export default mixins(renderText, restApi).extend({ }, /** - * Add to the translation object the node translation - * for the credential being viewed. + * Add to the translation object the node translation for the credential in the modal. */ async addNodeTranslationForCredential() { - // TODO i18n: Check if node translation has already been added (via NodeView) - const { nodeType }: { nodeType: string } = this.$store.getters.credentialTextRenderKeys; const version = await this.getCurrentNodeVersion(nodeType); - const nodeToBeFetched = [{ name: nodeType, version }]; - const nodesInfo = await this.restApi().getNodesInformation(nodeToBeFetched); const nodeInfo = nodesInfo.pop(); diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialInfo.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialInfo.vue index a8bda75fd7..b7f9c96304 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialInfo.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialInfo.vue @@ -78,7 +78,7 @@ export default mixins(renderText).extend({ }); }, shortNodeType(nodeType: INodeTypeDescription) { - return nodeType.name.replace('n8n-nodes-base.', ''); + return this.$shortNodeType(nodeType.name); }, }, }); diff --git a/packages/editor-ui/src/components/DisplayWithChange.vue b/packages/editor-ui/src/components/DisplayWithChange.vue index 5f1ed0007b..dc3b424eab 100644 --- a/packages/editor-ui/src/components/DisplayWithChange.vue +++ b/packages/editor-ui/src/components/DisplayWithChange.vue @@ -34,7 +34,7 @@ export default mixins(genericHelpers).extend({ }; if (this.keyName === 'name' && this.node.type.startsWith('n8n-nodes-base.')) { - const shortNodeType = this.node.type.replace('n8n-nodes-base.', ''); + const shortNodeType = this.$shortNodeType(this.node.type); return this.$headerText({ key: `headers.${shortNodeType}.displayName`, diff --git a/packages/editor-ui/src/components/ExecutionsList.vue b/packages/editor-ui/src/components/ExecutionsList.vue index e2283bff0c..f7982d88f9 100644 --- a/packages/editor-ui/src/components/ExecutionsList.vue +++ b/packages/editor-ui/src/components/ExecutionsList.vue @@ -115,10 +115,9 @@ - +