mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Fix i18n translation addition (#9451)
This commit is contained in:
@@ -186,6 +186,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
parentTypes: {
|
parentTypes: {
|
||||||
type: Array as PropType<string[]>,
|
type: Array as PropType<string[]>,
|
||||||
|
default: () => [],
|
||||||
},
|
},
|
||||||
credentialData: {},
|
credentialData: {},
|
||||||
credentialId: {
|
credentialId: {
|
||||||
@@ -274,7 +275,7 @@ export default defineComponent({
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const appName = getAppNameFromCredType((this.credentialType as ICredentialType).displayName);
|
const appName = getAppNameFromCredType(this.credentialType.displayName);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
appName ||
|
appName ||
|
||||||
@@ -282,13 +283,13 @@ export default defineComponent({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
credentialTypeName(): string {
|
credentialTypeName(): string {
|
||||||
return (this.credentialType as ICredentialType)?.name;
|
return this.credentialType?.name;
|
||||||
},
|
},
|
||||||
credentialOwnerName(): string {
|
credentialOwnerName(): string {
|
||||||
return this.credentialsStore.getCredentialOwnerNameById(`${this.credentialId}`);
|
return this.credentialsStore.getCredentialOwnerNameById(`${this.credentialId}`);
|
||||||
},
|
},
|
||||||
documentationUrl(): string {
|
documentationUrl(): string {
|
||||||
const type = this.credentialType as ICredentialType;
|
const type = this.credentialType;
|
||||||
const activeNode = this.ndvStore.activeNode;
|
const activeNode = this.ndvStore.activeNode;
|
||||||
const isCommunityNode = activeNode ? isCommunityPackageName(activeNode.type) : false;
|
const isCommunityNode = activeNode ? isCommunityPackageName(activeNode.type) : false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { Plugin } from 'vue';
|
import type { Plugin } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
import type { I18nOptions } from 'vue-i18n';
|
|
||||||
import { locale } from 'n8n-design-system';
|
import { locale } from 'n8n-design-system';
|
||||||
import type { INodeProperties, INodePropertyCollection, INodePropertyOptions } from 'n8n-workflow';
|
import type { INodeProperties, INodePropertyCollection, INodePropertyOptions } from 'n8n-workflow';
|
||||||
|
|
||||||
@@ -437,9 +436,7 @@ async function setLanguage(language: string) {
|
|||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadLanguage(language?: string) {
|
export async function loadLanguage(language: string) {
|
||||||
if (!language) return;
|
|
||||||
|
|
||||||
if (i18nInstance.global.locale === language) {
|
if (i18nInstance.global.locale === language) {
|
||||||
return await setLanguage(language);
|
return await setLanguage(language);
|
||||||
}
|
}
|
||||||
@@ -466,25 +463,15 @@ export async function loadLanguage(language?: string) {
|
|||||||
*/
|
*/
|
||||||
export function addNodeTranslation(
|
export function addNodeTranslation(
|
||||||
nodeTranslation: { [nodeType: string]: object },
|
nodeTranslation: { [nodeType: string]: object },
|
||||||
language: keyof I18nOptions['messages'],
|
language: string,
|
||||||
) {
|
) {
|
||||||
const oldNodesBase: { nodes: {} } = i18nInstance.global.messages[language]['n8n-nodes-base'] ?? {
|
const newMessages = {
|
||||||
nodes: {},
|
'n8n-nodes-base': {
|
||||||
|
nodes: nodeTranslation,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const updatedNodes = {
|
i18nInstance.global.mergeLocaleMessage(language, newMessages);
|
||||||
...oldNodesBase.nodes,
|
|
||||||
...nodeTranslation,
|
|
||||||
};
|
|
||||||
|
|
||||||
const newNodesBase = {
|
|
||||||
'n8n-nodes-base': Object.assign(oldNodesBase, { nodes: updatedNodes }),
|
|
||||||
};
|
|
||||||
|
|
||||||
i18nInstance.global.setLocaleMessage(
|
|
||||||
language,
|
|
||||||
Object.assign(i18nInstance.global.messages[language], newNodesBase),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -492,38 +479,22 @@ export function addNodeTranslation(
|
|||||||
*/
|
*/
|
||||||
export function addCredentialTranslation(
|
export function addCredentialTranslation(
|
||||||
nodeCredentialTranslation: { [credentialType: string]: object },
|
nodeCredentialTranslation: { [credentialType: string]: object },
|
||||||
language: keyof I18nOptions['messages'],
|
language: string,
|
||||||
) {
|
) {
|
||||||
const oldNodesBase: { credentials: {} } = i18nInstance.global.messages[language][
|
const newMessages = {
|
||||||
'n8n-nodes-base'
|
'n8n-nodes-base': {
|
||||||
] || { credentials: {} };
|
credentials: nodeCredentialTranslation,
|
||||||
|
},
|
||||||
const updatedCredentials = {
|
|
||||||
...oldNodesBase.credentials,
|
|
||||||
...nodeCredentialTranslation,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const newNodesBase = {
|
i18nInstance.global.mergeLocaleMessage(language, newMessages);
|
||||||
'n8n-nodes-base': Object.assign(oldNodesBase, { credentials: updatedCredentials }),
|
|
||||||
};
|
|
||||||
|
|
||||||
i18nInstance.global.setLocaleMessage(
|
|
||||||
language,
|
|
||||||
Object.assign(i18nInstance.global.messages[language], newNodesBase),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a node's header strings to the i18n instance's `messages` object.
|
* Add a node's header strings to the i18n instance's `messages` object.
|
||||||
*/
|
*/
|
||||||
export function addHeaders(
|
export function addHeaders(headers: INodeTranslationHeaders, language: string) {
|
||||||
headers: INodeTranslationHeaders,
|
i18nInstance.global.mergeLocaleMessage(language, { headers });
|
||||||
language: keyof I18nOptions['messages'],
|
|
||||||
) {
|
|
||||||
i18nInstance.global.setLocaleMessage(
|
|
||||||
language,
|
|
||||||
Object.assign(i18nInstance.global.messages[language], { headers }),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const i18n: I18nClass = new I18nClass();
|
export const i18n: I18nClass = new I18nClass();
|
||||||
|
|||||||
Reference in New Issue
Block a user