feat(i18n): enhance notification templates with raw message handling
Updated the notification system to utilize the `tm` function for template resolution, ensuring that placeholders like `{name}` and `{role}` remain intact for proper rendering. This change improves the display of workspace and role information in login and tenant switch notifications, allowing for better localization and visual consistency across the application. Adjustments were made in `App.vue`, `Login.vue`, and related utility functions to accommodate the new template handling.
This commit is contained in:
@@ -18,7 +18,7 @@ import zhCNConfig from 'tdesign-vue-next/esm/locale/zh_CN'
|
||||
import koKRConfig from 'tdesign-vue-next/esm/locale/ko_KR'
|
||||
import ruRUConfig from 'tdesign-vue-next/esm/locale/ru_RU'
|
||||
|
||||
const { locale, t } = useI18n()
|
||||
const { locale, t, tm } = useI18n()
|
||||
const { formatRole, roleIcon } = useRoleLabel()
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
@@ -144,7 +144,7 @@ const handleGlobalOIDCCallback = async () => {
|
||||
if (response.success) {
|
||||
clearOIDCCallbackState('/')
|
||||
await persistOIDCLoginResponse(response)
|
||||
notifyLoginSuccess(response, t, formatRole, roleIcon)
|
||||
notifyLoginSuccess(response, t, tm, formatRole, roleIcon)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -207,10 +207,16 @@ const showPendingTenantSwitchToast = () => {
|
||||
const templateKey = pending.role
|
||||
? 'tenant.switchSuccessContentWithRole'
|
||||
: 'tenant.switchSuccessContent'
|
||||
// Use tm() not t() — vue-i18n v11's `t()` replaces unspecified named
|
||||
// placeholders with empty strings, which would strip {name}/{role}
|
||||
// before the chip renderer can split on them. tm() returns the raw
|
||||
// message verbatim.
|
||||
const rawTemplate = tm(templateKey)
|
||||
const template = typeof rawTemplate === 'string' ? rawTemplate : ''
|
||||
NotifyPlugin.success({
|
||||
title: t('tenant.switchSuccessTitle'),
|
||||
content: renderWorkspaceNotifyContent({
|
||||
template: t(templateKey),
|
||||
template,
|
||||
name: pending.name,
|
||||
roleLabel: pending.role,
|
||||
roleEnum: pending.roleEnum,
|
||||
|
||||
Reference in New Issue
Block a user