refactor(editor): Extract @n8n/i18n package for internationalization (no-changelog) (#15466)

This commit is contained in:
Alex Grozav
2025-05-30 11:44:33 +02:00
committed by GitHub
parent bbe2b12bf2
commit e704077864
408 changed files with 1002 additions and 767 deletions

View File

@@ -7,7 +7,6 @@ import { useNDVStore } from '@/stores/ndv.store';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { usePostHog } from '@/stores/posthog.store';
import { useRootStore } from '@n8n/stores/useRootStore';
import { useI18n } from '@/composables/useI18n';
import { useToast } from '@/composables/useToast';
import type { INodeProperties } from 'n8n-workflow';
@@ -16,7 +15,16 @@ vi.mock('@/stores/workflows.store');
vi.mock('@/stores/posthog.store');
vi.mock('@n8n/stores/useRootStore');
vi.mock('@/api/ai');
vi.mock('@/composables/useI18n');
vi.mock('@n8n/i18n', async (importOriginal) => ({
...(await importOriginal()),
useI18n: () => ({
baseText: vi.fn().mockReturnValue('Mocked Text'),
nodeText: () => ({
inputLabelDisplayName: vi.fn().mockReturnValue('Mocked Display Name'),
inputLabelDescription: vi.fn().mockReturnValue('Mocked Description'),
}),
}),
}));
vi.mock('@/composables/useToast');
describe('ButtonParameter', () => {
@@ -66,14 +74,6 @@ describe('ButtonParameter', () => {
pushRef: 'testPushRef',
} as any);
vi.mocked(useI18n).mockReturnValue({
baseText: vi.fn().mockReturnValue('Mocked Text'),
nodeText: () => ({
inputLabelDisplayName: vi.fn().mockReturnValue('Mocked Display Name'),
inputLabelDescription: vi.fn().mockReturnValue('Mocked Description'),
}),
} as any);
vi.mocked(useToast).mockReturnValue({
showMessage: vi.fn(),
} as any);

View File

@@ -3,7 +3,7 @@ import { type INodeProperties, type NodePropertyAction } from 'n8n-workflow';
import type { INodeUi, IUpdateInformation } from '@/Interface';
import { ref, computed, onMounted } from 'vue';
import { N8nButton, N8nInput, N8nTooltip } from '@n8n/design-system/components';
import { useI18n } from '@/composables/useI18n';
import { useI18n } from '@n8n/i18n';
import { useToast } from '@/composables/useToast';
import { useNDVStore } from '@/stores/ndv.store';
import {
@@ -31,7 +31,8 @@ export type Props = {
};
const props = defineProps<Props>();
const { activeNode } = useNDVStore();
const ndvStore = useNDVStore();
const activeNode = computed(() => ndvStore.activeNode);
const i18n = useI18n();
@@ -57,7 +58,7 @@ const isSubmitEnabled = computed(() => {
return true;
});
const promptUpdated = computed(() => {
const lastPrompt = activeNode?.parameters[AI_TRANSFORM_CODE_GENERATED_FOR_PROMPT] as string;
const lastPrompt = activeNode.value?.parameters[AI_TRANSFORM_CODE_GENERATED_FOR_PROMPT] as string;
if (!lastPrompt) return false;
return lastPrompt.trim() !== prompt.value.trim();
});
@@ -81,7 +82,7 @@ async function onSubmit() {
const action: string | NodePropertyAction | undefined =
props.parameter.typeOptions?.buttonConfig?.action;
if (!action || !activeNode) return;
if (!action || !activeNode.value) return;
if (typeof action === 'string') {
switch (action) {
@@ -196,8 +197,8 @@ async function updateCursorPositionOnMouseMove(event: MouseEvent, activeDrop: bo
<div>
<n8n-input-label
v-if="hasInputField"
:label="i18n.nodeText().inputLabelDisplayName(parameter, path)"
:tooltip-text="i18n.nodeText().inputLabelDescription(parameter, path)"
:label="i18n.nodeText(activeNode?.type).inputLabelDisplayName(parameter, path)"
:tooltip-text="i18n.nodeText(activeNode?.type).inputLabelDescription(parameter, path)"
:bold="false"
size="small"
color="text-dark"