From f456287c2e79628d37facafd5b36ef430bd75534 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Tue, 14 Jul 2026 23:19:11 +0800 Subject: [PATCH] fix: use Deal terminology in trash --- plugins/trash/frontend/src/index.js | 4 ++-- plugins/trash/locales/en.json | 4 ++-- plugins/trash/locales/ru.json | 4 ++-- scripts/smoke-trash-plugin.js | 21 ++++++++++++++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/plugins/trash/frontend/src/index.js b/plugins/trash/frontend/src/index.js index 4641f9b..392fce4 100644 --- a/plugins/trash/frontend/src/index.js +++ b/plugins/trash/frontend/src/index.js @@ -217,7 +217,7 @@ value: state.workspace, 'data-trash-filter-workspace': '', onChange: function (event) { state.workspace = event.target.value; render(); } - }, [el('option', { value: '' }, [tr('ui.allWorkspaces', null, 'All workspaces')])]); + }, [el('option', { value: '' }, [tr('ui.allWorkspaces', null, 'All Deals')])]); workspaceOptions().forEach(function (workspace) { workspaceSelect.appendChild(el('option', { value: workspace }, [workspace])); }); @@ -270,7 +270,7 @@ var list = el('div', { className: 'trash-list', 'data-trash-list': '' }); list.appendChild(el('div', { className: 'trash-header' }, [ el('span', {}, [tr('ui.name', null, 'Name')]), - el('span', {}, [tr('ui.workspace', null, 'Workspace')]), + el('span', {}, [tr('ui.workspace', null, 'Deal')]), el('span', {}, [tr('ui.originalPath', null, 'Original path')]), el('span', {}, [tr('ui.deleted', null, 'Deleted')]), el('span', {}, [tr('ui.typeSize', null, 'Type / size')]), diff --git a/plugins/trash/locales/en.json b/plugins/trash/locales/en.json index 719a739..1568482 100644 --- a/plugins/trash/locales/en.json +++ b/plugins/trash/locales/en.json @@ -10,7 +10,7 @@ "ui.cannotUndo": "This cannot be undone.", "ui.cancel": "Cancel", "ui.deleting": "Deleting...", - "ui.allWorkspaces": "All workspaces", + "ui.allWorkspaces": "All Deals", "ui.allTypes": "All types", "ui.files": "Files", "ui.folders": "Folders", @@ -22,7 +22,7 @@ "ui.total": "{count} total", "ui.filter": "Filter name or path", "ui.refresh": "Refresh", - "ui.workspace": "Workspace", + "ui.workspace": "Deal", "ui.originalPath": "Original path", "ui.deleted": "Deleted", "ui.typeSize": "Type / size", diff --git a/plugins/trash/locales/ru.json b/plugins/trash/locales/ru.json index 5f44ba8..9b5674c 100644 --- a/plugins/trash/locales/ru.json +++ b/plugins/trash/locales/ru.json @@ -10,7 +10,7 @@ "ui.cannotUndo": "Это действие нельзя отменить.", "ui.cancel": "Отмена", "ui.deleting": "Удаление...", - "ui.allWorkspaces": "Все рабочие пространства", + "ui.allWorkspaces": "Все Дела", "ui.allTypes": "Все типы", "ui.files": "Файлы", "ui.folders": "Папки", @@ -22,7 +22,7 @@ "ui.total": "Всего: {count}", "ui.filter": "Фильтр по имени или пути", "ui.refresh": "Обновить", - "ui.workspace": "Рабочее пространство", + "ui.workspace": "Дело", "ui.originalPath": "Исходный путь", "ui.deleted": "Удалён", "ui.typeSize": "Тип / размер", diff --git a/scripts/smoke-trash-plugin.js b/scripts/smoke-trash-plugin.js index 887fa94..2a504b9 100644 --- a/scripts/smoke-trash-plugin.js +++ b/scripts/smoke-trash-plugin.js @@ -5,8 +5,10 @@ const vm = require('vm'); const root = path.resolve(__dirname, '..'); const sourcePath = path.join(root, 'plugins', 'trash', 'frontend', 'src', 'index.js'); const manifestPath = path.join(root, 'plugins', 'trash', 'plugin.json'); +const russianLocalePath = path.join(root, 'plugins', 'trash', 'locales', 'ru.json'); const source = fs.readFileSync(sourcePath, 'utf8'); const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); +const russianLocale = JSON.parse(fs.readFileSync(russianLocalePath, 'utf8')); class FakeClassList { constructor(node) { @@ -159,7 +161,7 @@ function loadTrashComponent(document) { return component; } -function makeApi() { +function makeApi(locale = null) { let entries = [ { trashId: 'old-project-file', @@ -194,6 +196,11 @@ function makeApi() { return { restoreCalls, deleteCalls, + i18n: locale ? { + t(key, params, fallback) { + return String(locale[key] || fallback || key).replace(/\{(\w+)\}/g, (_match, name) => String((params || {})[name] ?? '')); + }, + } : null, files: { listTrash: async () => entries.slice(), restoreTrash: async (trashId, options) => { @@ -237,6 +244,10 @@ function findByData(rootNode, name, value) { component.mount(container, {}, api); await flush(); + if (!container.textContent.includes('All Deals') || !container.textContent.includes('Deal')) { + throw new Error('global Trash did not use Deal terminology'); + } + const latestRow = findByData(container, 'data-trash-row', 'latest-client-report'); if (!latestRow || !latestRow.textContent.includes('ClientA') || !latestRow.textContent.includes('ClientA/Archive/report.pdf')) { throw new Error(`global Trash must render workspace and original path: ${container.textContent}`); @@ -298,6 +309,14 @@ function findByData(rootNode, name, value) { } component.unmount(container); + + const russianContainer = new FakeNode('div'); + component.mount(russianContainer, {}, makeApi(russianLocale)); + await flush(); + if (!russianContainer.textContent.includes('Все Дела') || !russianContainer.textContent.includes('Дело')) { + throw new Error('global Trash did not localize Deal terminology'); + } + component.unmount(russianContainer); console.log('trash frontend smoke passed'); })().catch((err) => { console.error(err);