Skip to content

feat: locales for model of edition_1 - #7945

Merged
fit2cloudwxx merged 1 commit into
v3from
pr@v3@feat_localesForModelE_1
Nov 16, 2026
Merged

fit2cloudwxx merged 1 commit into
v3from
pr@v3@feat_localesForModelE_1

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

feat: locales for model of edition_1

<el-button type="primary" @click="submitEdit">{{ t('common.actions.save') }}</el-button>
</template>
</MkDialog>
</template>

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

Issues / irregularities

  1. Inconsistent key naming for "option value" placeholder

    • Label placeholder: t('dynamicForm.tree.labelPlaceholder') (a "*Placeholder" key)
    • Value placeholder: t('dynamicForm.options.valueRequired') — this looks like a required-error message key, not a placeholder. Likely wrong key; placeholders should use a ...Placeholder key (e.g. dynamicForm.options.valuePlaceholder). The same suspicious key is reused in both add and edit dialogs.
  2. Wrong namespace mixing (tree.* vs options.* vs fields.*)

    • dynamicForm.options.label / dynamicForm.options.value are used for field labels, but dynamicForm.fields.defaultValue uses fields.*. This inconsistency will be hard to maintain. Pick one convention.
  3. common.actions.edit used as a dialog title

    • Using an action key ("Edit") as a title is a mismatch. Prefer something like dynamicForm.tree.editTitle or common.titles.edit.
  4. MsgConfirm signature changed

    • Original used ('提示', msg, { type }); new version adds cancelButtonText/confirmButtonText. Verify that MsgConfirm's options actually support these keys — otherwise they're silently ignored. Also confirm common.titles.notice exists.
  5. Formatting / line length

    • The el-form-item with :rules now has a very long single-line binding. Consider extracting rules into a computed property for readability and reuse.
    • <MkDialog ... :title="addDialog.mode === 'root' ? t(...) : t(...)" — ternary inside template attribute works but is hard to read; consider a computed addDialogTitle.
  6. blur: 'change' in rules object

    • blur should be a boolean trigger flag per Element Plus API (trigger: 'change' is typical). blur: 'change' looks incorrect — worth double-checking it wasn't already a latent bug carried over.
  7. Mixed i18n scopes

    • useI18n({ useScope: 'global' }) inside script setup plus direct t() usage in template — fine, but note that if the component ever needs local messages you'll have to switch scope. Also ensure t reactivity works for <el-form-item :rules> (rules won't re-evaluate on locale change unless wrapped in computed).
  8. Rules array recreated on every render

    • The inline :rules="[{ required: true, message: t(...) }]" creates a new array/object each render and captures t() at render time. Wrap in computed(() => [...]) so it updates properly on language change and is stable.
  9. Hardcoded remaining Chinese

    • Search the rest of the file for other untranslated strings (comments are fine, but any UI strings should be checked).
  10. .catch(() => {}) is silent — acceptable, but consider logging in dev.

Optimization suggestions

  • Extract rule arrays to computed properties.
  • Add a dynamicForm.options.valuePlaceholder key and use it consistently.
  • Unify i18n key namespaces (options.label, options.value, options.valuePlaceholder, etc.).
  • Move the add-dialog title ternary into a computed.
  • Verify MsgConfirm supports cancelButtonText/confirmButtonText and that all referenced keys exist in the locale files (a missing key falls back to the raw key string, which users will see).
  • Reformat the multi-attribute el-form-item to multiple lines for consistency with rest of the file.

{{ t('common.actions.delete') }}
</MkDropdownItem>
</MkTableMoreDropdown>
</div>

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.

Code Review

Potential Issues

  1. searchFields reactivity bug — This is the most significant issue. searchFields was a computed, but its dependency on t() may not trigger re-evaluation on locale change depending on i18n version/config. More importantly, since creatorOptions.value and remoteMethod are captured inside, changing creatorOptions won't recompute unless it's accessed reactively (it is via .value, so OK). But translations won't update on language switch unless t is reactive in the computed context — generally fine with useScope: 'global', but worth verifying.

  2. modelTypeOptions now a computed — Correct improvement (fixes stale labels on locale change). Ensure all consumers handle a computed ref; usage in template is fine, but providerOptions/modelTypeOptions passed as props will auto-unwrap only in templates. Confirm MkTableFilter :options receives unwrapped array (template ok).

  3. Non-null assertion MODEL_TYPE_LABELS[row.model_type]! — The ternary guard makes this safe, but a cleaner pattern:

    {{ MODEL_TYPE_LABELS[row.model_type] ?? row.model_type }}

    If you want translation:

    const label = (v) => MODEL_TYPE_LABELS[v] ? t(MODEL_TYPE_LABELS[v]) : v
  4. MsgConfirm signature change — Verify the 3rd argument ({ cancelButtonText, confirmButtonText }) is actually supported by MsgConfirm. If unsupported, buttons silently fall back to defaults or throw.

  5. t('system.resourceManagement.delete.modelReferenced') — Cross-module key used in the model module. Fine functionally, but consider namespacing under model.* for maintainability and translator ownership clarity.

  6. useI18n({ useScope: 'global' }) — Consistent with rest of app? If other components omit scope, ensure global messages include all referenced keys (common.fields.*, model.*, system.resourceManagement.*).

  7. Locale-change reactivity of column labels — el-table-column label bindings via :label="t(...)" will update, good. But MkViewLayout :title="t('model.title')" — verify MkViewLayout re-renders on title prop change.

Optimization Suggestions

  1. Extract repeated translation lookups — e.g. t('common.fields.creator') appears twice; t('common.actions.delete') twice. Minor, but a small local helper could reduce duplication.

  2. Memoize modelTypeOptions translation — Object.entries(...).map runs on every locale change; acceptable, but if MODEL_TYPE_LABELS is large, consider precomputing translated map.

  3. selectedProvider/selectedModelType type safety — ref('') works but MkTableFilter with mode="single" may emit null/undefined; consider ref<string | undefined>().

  4. Inline array literal in v-if — ['TTS','LLM',...].includes(row.model_type) allocates on every render. Hoist to a Set constant:

    const PARAM_SETTING_TYPES = new Set(['TTS','LLM','IMAGE','TTI','STT','EMBEDDING'])
    // ...PARAM_SETTING_TYPES.has(row.model_type)
  5. Test coverage — Add a test verifying that switching locale updates table headers/filters (regression guard for the i18n refactor).

  6. Long <MkTableFilter> lines — Multi-line formatting introduced is good; keep for consistency across all filters.

Summary

The diff is a clean i18n migration. Main risk points: verify MsgConfirm third-arg support, confirm global message keys exist in all locales, and double-check searchFields / options recompute on locale switch. Optional micro-optimizations noted above.

<el-button type="primary" :loading="loading" @click="handleSubmit">{{ t('common.actions.save') }}</el-button>
</template>
</MkDrawer>
</template>

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

Irregularities / potential issues

  1. useI18n({ useScope: 'global' }) inside <script setup> — Fine, but ensure the component is within an i18n app context; otherwise t() will warn at runtime.

  2. Rule messages are computed once (not reactive to locale changes) — :rules="{ ... message: t(...) }" is evaluated on each render so this is OK for re-render, but Element Plus caches rule validation state. If the user switches language while the form is open with a visible error, the message may not update until re-validation. Minor.

  3. Inconsistent translation source for model_type rule message — You used t('model.form.type.placeholder') ("请选择模型类型"/similar) as the validation message instead of a dedicated model.form.type.required. Placeholder text and a validation error are semantically different keys; reuse is misleading and couples them. Add a dedicated required key.

  4. MODEL_TYPE_LABELS now passed through t(label) — This assumes every value in MODEL_TYPE_LABELS is already an i18n key (e.g. model.types.llm.label). If it still contains raw Chinese strings, t() will just return them verbatim (works), but it silently breaks the convention and may emit missing-key warnings depending on config. Verify the constant was migrated to keys, or wrap conditionally.

  5. MsgWarning/MsgSuccess calls now depend on t at call time — Good. But the fallback branch loadBuiltin shows MsgWarning('usingBuiltinModels') unconditionally before checking whether built-ins were actually used; unchanged behavior, but worth confirming that applyBaseModelOptions success/failure is what determines the warning vs. silent fallback.

  6. Hard-coded drawer title concatenation removed correctly, but check that model.form.editTitle uses a named interpolation {providerName} and that other locales also have that placeholder — a missing param renders the literal {providerName}.

  7. Footer buttons still close via visible = false directly — unchanged; consider calling an onClose handler if you need to reset state/icons consistently.

Optimization suggestions

  • Deduplicate t() lookups: t('common.actions.cancel'), t('common.actions.save') etc. are called per render — trivial cost, but referencing t directly in template is idiomatic and fine.
  • Extract rule objects into computed so they react cleanly to locale:
    const nameRules = computed(() => [{ whitespace: true, required: true, message: t('model.form.name.required'), trigger: 'blur' }])
    This avoids inline object recreation each render and makes rule changes testable.
  • Tooltip content lists: 9 sequential <p>{{ t(...) }}</p> entries could be driven by a v-for over a computed array of type descriptions (model.types.*.description) — reduces template noise and keeps ordering centralized.
  • MkTooltip :content="t(...)" vs <template #content> inconsistency: some tooltips bind content, others use slot. Consider standardizing (slot supports rich content; content is plain text).
  • Language switch reactivity: since t from global scope is reactive, computed-based rules/titles will update automatically. Using inline t() in :rules prevents this because Element Plus holds the resolved string. Migrating to computed rules fixes point 2 above.
  • Sanity check: confirm all new keys (model.form.name.*, model.form.baseModel.*, model.actions.fetchModels, model.types.*.description, common.messages.modified) exist in every locale file; missing keys will surface UI bugs only in non-default locales.

Summary

No functional regressions in the diff. Main actionable items: (a) add a dedicated model.form.type.required key instead of reusing the placeholder, (b) verify MODEL_TYPE_LABELS values are i18n keys, (c) move validation rules into computed for locale reactivity, (d) audit locale files for completeness of the new keys.

@fit2cloudwxx
fit2cloudwxx merged commit 41089a1 into v3 Nov 16, 2026
3 of 4 checks passed
@fit2cloudwxx
fit2cloudwxx deleted the pr@v3@feat_localesForModelE_1 branch November 16, 2026 10:08
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