Skip to content

feat: tool translation - #7968

Merged
wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@feat_tool_translation
Nov 17, 2026
Merged

wangdan-fit2cloud merged 1 commit into
v3from
pr@v3@feat_tool_translation

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: tool translation

:label="t('common.actions.delete')"
:api="SystemSharedToolApi"
:tool="tool"
@delete="refreshTools"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. ToolStatusSwitch permission 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 ToolStatusSwitch actually declares and enforces a disabled prop. If it does not, Vue may just pass disabled as 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.
  2. Ensure t is 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.label
      • common.status.label
      • common.status.enabled
      • common.status.disabled
      • common.labels.creator
      • tool.title
      • tool.categories.all
      • tool.workflow.label
      • tool.initParams.title
      • resource.mcpConfig.title
      • resource.workspaceAuthorization.title
      • resource.relations.title
      • resource.actions.viewExecutionRecords
    • Prefer a type-safe i18n setup or key-extraction check to catch missing keys.
  3. searchFields computed reactivity is probably fine, but verify child behavior

    • creatorOptions.value is captured inside the computed. In Vue 3 this should track the ref, so replacing/updating creatorOptions should recompute searchFields.
    • However, if the search component stores the initial searchFields array/options and does not watch prop changes, updated creator options or locale changes may not appear. Ensure the child reacts to searchFields changes.
  4. 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.
  5. i18n key naming is somewhat inconsistent

    • Some action labels use resource.*.title, while others use resource.actions.*.
    • Not a runtime bug, but consider standardizing action labels under a consistent namespace, e.g. resource.actions.* or common.actions.*.
  6. Minor semantic check

    • CopyToolAction now uses t('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.

@wangdan-fit2cloud
wangdan-fit2cloud merged commit 70e524b into v3 Nov 17, 2026
3 of 4 checks passed
@wangdan-fit2cloud
wangdan-fit2cloud deleted the pr@v3@feat_tool_translation branch November 17, 2026 07:20
<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>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Confirm the new translation keys exist

    • tool.source.label
    • tool.source.reference
    • tool.source.custom

    Missing keys in any locale can cause raw key output or fallback text.

  2. Check for key collisions / semantic mismatch

    • Moving from tool.inputParams.source.* to the more generic tool.source.* may conflict with an existing tool.source namespace elsewhere.
    • If these labels are only for input parameters, keeping the feature-scoped key is safer: tool.inputParams.source.*.
  3. Search for old key usage

    • Ensure no other components/tests/snapshots still reference:
      • tool.inputParams.source.label
      • tool.inputParams.source.reference
      • tool.inputParams.source.custom
  4. 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.
  5. No functional issue in the diff

    • The v-model, el-option values, and form structure are unchanged.
    • The @blur trim and @click.prevent lines are unrelated to this diff but appear intentional.

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',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.title becomes 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 title as 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 like tool.title.
  • A genuine title that happens to be tool.title would 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.tool and route.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 string tool.title in 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants