Repository navigation
feat: tool translation - #7968
Conversation
| :label="t('common.actions.delete')" | ||
| :api="SystemSharedToolApi" | ||
| :tool="tool" | ||
| @delete="refreshTools" |
There was a problem hiding this comment.
Overall, the shown diff is mostly a mechanical i18n change, and the label="..." → :label="t(...)" bindings are correct. I do not see an obvious syntax error in the diff itself.
Main issues / things to verify:
-
ToolStatusSwitchpermission behavior changed- Before:
v-if="perm.tool.share.switch()"hid the switch completely when the user lacked permission. - After: the switch is always rendered and only receives
:disabled="!perm.tool.share.switch()". - This is not equivalent:
- Verify
ToolStatusSwitchactually declares and enforces adisabledprop. If it does not, Vue may just passdisabledas a fallthrough attribute while the internal switch remains interactive. - Verify the component does not make API calls on mount or emit changes while disabled.
- If the intended UX is “hide from unauthorized users,” keep
v-if. If the intended UX is “show disabled,” add a tooltip/accessible explanation and test unauthorized interaction.
- Verify
- Before:
-
Ensure
tis available in the script and all i18n keys exist- Make sure
const { t } = useI18n()or equivalent exists in<script setup>. - Missing keys will render raw keys like
common.labels.creator. - Pay special attention to these newly introduced keys:
common.name.labelcommon.status.labelcommon.status.enabledcommon.status.disabledcommon.labels.creatortool.titletool.categories.alltool.workflow.labeltool.initParams.titleresource.mcpConfig.titleresource.workspaceAuthorization.titleresource.relations.titleresource.actions.viewExecutionRecords
- Prefer a type-safe i18n setup or key-extraction check to catch missing keys.
- Make sure
-
searchFieldscomputed reactivity is probably fine, but verify child behaviorcreatorOptions.valueis captured inside the computed. In Vue 3 this should track the ref, so replacing/updatingcreatorOptionsshould recomputesearchFields.- However, if the search component stores the initial
searchFieldsarray/options and does not watch prop changes, updated creator options or locale changes may not appear. Ensure the child reacts tosearchFieldschanges.
-
Translated labels may be longer than Chinese labels
- Check layout/overflow for dropdown actions, search field labels, and the header/category title.
- English translations such as “View Execution Records” or “Workspace Authorization” may be much wider than the original Chinese text.
-
i18n key naming is somewhat inconsistent
- Some action labels use
resource.*.title, while others useresource.actions.*. - Not a runtime bug, but consider standardizing action labels under a consistent namespace, e.g.
resource.actions.*orcommon.actions.*.
- Some action labels use
-
Minor semantic check
CopyToolActionnow usest('common.actions.duplicate'). Make sure “duplicate” is the intended product term and not “copy.”MkViewLayout :title="t('tool.title')"plus the separate<h4>{{ t('tool.categories.all') }}</h4>is probably fine, but confirm the layout title does not duplicate the header content unexpectedly.
Suggested priority: first verify the ToolStatusSwitch disabled behavior and that no unauthorized API call/toggle is possible; then run an i18n key validation and check translated-label layout.
| <el-option :label="t('tool.source.custom')" value="custom" /> | ||
| </el-select> | ||
| </el-form-item> | ||
| <el-form-item :label="t('dynamicForm.fields.required.label')" @click.prevent><el-switch v-model="inputFieldForm.is_required" /></el-form-item> |
There was a problem hiding this comment.
The shown diff only changes i18n key paths for the “source” select. I don’t see syntax or Vue template issues in the change itself, but there are a few things to verify:
-
Confirm the new translation keys exist
tool.source.labeltool.source.referencetool.source.custom
Missing keys in any locale can cause raw key output or fallback text.
-
Check for key collisions / semantic mismatch
- Moving from
tool.inputParams.source.*to the more generictool.source.*may conflict with an existingtool.sourcenamespace elsewhere. - If these labels are only for input parameters, keeping the feature-scoped key is safer:
tool.inputParams.source.*.
- Moving from
-
Search for old key usage
- Ensure no other components/tests/snapshots still reference:
tool.inputParams.source.labeltool.inputParams.source.referencetool.inputParams.source.custom
- Ensure no other components/tests/snapshots still reference:
-
Update translation resources consistently
- Add/remove keys in all supported locale files.
- Remove or deprecate old keys if they are no longer used, to avoid dead translations.
-
No functional issue in the diff
- The
v-model,el-optionvalues, and form structure are unchanged. - The
@blurtrim and@click.preventlines are unrelated to this diff but appear intentional.
- The
Recommendation: keep the old feature-scoped keys unless tool.source.* is intentionally shared globally, and verify translations/tests before merging.
| meta: { title: 'tool.title', order: 20, permission: perm.tool.share.read, next: 'system-shared-models' }, | ||
| }, | ||
| { | ||
| path: 'models', |
There was a problem hiding this comment.
Review of the diff
The change itself is small (hardcoded Chinese meta.title → i18n key tool.title), but it introduces a few consistency and design issues.
1. Inconsistent migration — the rest of the file still uses literals
Only these two routes were converted. Sibling routes in the same file (e.g. models, and other systemRoutes entries) still contain hardcoded Chinese such as title: '工具' / '模型'.
- Result:
meta.titlebecomes a mixed bag of literal strings and translation keys, so every consumer (menu, breadcrumb, tab bar,document.title) must guess which is which. - Either migrate all titles in the same change, or keep
titleas a literal and introduce a separate field.
2. Overloading title as a translation key is ambiguous
meta.title traditionally holds a display string. Using it as a key means:
- Any code doing
meta.title === '工具', string interpolation, or logging now gets a key liketool.title. - A genuine title that happens to be
tool.titlewould be silently translated.
Recommended alternative:
meta: {
title: 'tool.title', // key
titleFallback: '工具', // optional, dev fallback
titleIsI18n: true,
}or, cleaner, use a dedicated field:
meta: { titleKey: 'tool.title', order: 30, ... }and resolve with t(meta.titleKey) at render time.
3. Reactive language switching
Make sure the title is resolved lazily (inside a computed/template using t()), not once when systemRoutes is declared. Since systemRoutes is a module-level constant, the value here is just a string — that's fine — but if any downstream code caches the resolved title (menu builder, tab store, document.title setter), switching locale won't update until refresh. Check those consumers.
4. Duplicate key for two different pages
Both system-resource-tools and system-shared-tools now use the same key tool.title.
- If both should read "Tools", fine — but then they may be indistinguishable in breadcrumbs/tabs, and any future need to differentiate ("System Tools" vs "Shared Tools") requires touching both.
- Prefer explicit, distinct keys, e.g.
route.system.resourceManagement.toolandroute.system.sharedResources.tool.
5. Key naming convention
tool.title is a shallow, generic namespace that risks collisions with other title keys. Recommend a namespaced scheme:
route.system.resource-management.tool
route.system.shared-resources.tool
6. Missing translations / type safety
- Verify the key exists in every locale file (
zh-CN,en-US, …). A missing key typically renders the raw stringtool.titlein the UI — easy to miss in review. - Consider typing the key to get compile-time safety, e.g.:
type I18nKey = keyof typeof messages['zh-CN']
meta: { title: 'tool.title' satisfies I18nKey }or generate a typed union from the locale JSON.
7. Search for equality checks on the old strings
Before merging, grep for comparisons such as meta.title === '工具', includes('工具'), tab-key/keep-alive matching on title, or hardcoded titles in permission/menu filters. These will break silently.
8. Minor
- Unrelated fields (
order,permission,next) are untouched — good, the change is minimal and scoped. - Hunk headers indicate no stray whitespace/EOL changes — good.
- Consider extracting the repeated
{ order, permission, next }shape into a helper if more routes get converted.
Summary
Low-risk change if (a) the key exists in all locales, (b) no code compares against the old literal, and (c) menu/breadcrumb/tab rendering already routes title through t(). The main design concerns are the mixed literal/key state of meta.title and the shared key across two distinct routes.
feat: tool translation