fix(editor): Fix unique names for node duplication (#6134)

* 🐛 Fix unique names for node duplication

* 🐛 Fix i18n references
This commit is contained in:
Iván Ovejero
2023-04-28 15:53:59 +02:00
committed by GitHub
parent 20a72bb28b
commit 71ae6c66ef
9 changed files with 227 additions and 102 deletions

View File

@@ -1,5 +1,19 @@
import { i18n } from '@/plugins/i18n';
import { useRootStore } from '@/stores/n8nRootStore';
export function useI18n() {
return i18n;
const isEnglishLocale = useRootStore().defaultLocale === 'en';
function localizeNodeName(nodeName: string, type: string) {
if (isEnglishLocale) return nodeName;
const nodeTypeName = i18n.shortNodeType(type);
return i18n.headerText({
key: `headers.${nodeTypeName}.displayName`,
fallback: nodeName,
});
}
return { i18n, localizeNodeName };
}