fix: 🐛 修复部分国际化文本不正确的问题 (#970)

This commit is contained in:
不如摸鱼去 2025-03-24 21:26:52 +08:00 committed by GitHub
parent 49fe25a99b
commit 4319fa9bad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 16 deletions

View File

@ -1,13 +1,4 @@
/* import { camelCase, getPropByPath, isDef, isFunction } from '../common/util'
* @Author: weisheng
* @Date: 2024-01-25 23:06:48
* @LastEditTime: 2025-02-14 11:20:02
* @LastEditors: 810505339
* @Description:
* @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\components\composables\useTranslate.ts
*
*/
import { camelCase, getPropByPath, isFunction } from '../common/util'
import Locale from '../../locale' import Locale from '../../locale'
export const useTranslate = (name?: string) => { export const useTranslate = (name?: string) => {
@ -15,8 +6,7 @@ export const useTranslate = (name?: string) => {
const translate = (key: string, ...args: unknown[]) => { const translate = (key: string, ...args: unknown[]) => {
const currentMessages = Locale.messages() const currentMessages = Locale.messages()
const message = getPropByPath(currentMessages, prefix + key) const message = getPropByPath(currentMessages, prefix + key)
return isFunction(message) ? message(...args) : message return isFunction(message) ? message(...args) : isDef(message) ? message : `${prefix}${key}`
} }
return { translate } return { translate }
} }

View File

@ -79,8 +79,8 @@ export default {
pagination: { pagination: {
prev: 'Previous', prev: 'Previous',
next: 'Next', next: 'Next',
page: (value: number) => `Page${value}`, page: (value: number) => `Page: ${value}`,
total: (total: number) => `Total${total}`, total: (total: number) => `Total: ${total}`,
size: (size: number) => `${size}/page` size: (size: number) => `${size}/page`
}, },
picker: { picker: {

View File

@ -75,8 +75,8 @@ export default {
pagination: { pagination: {
prev: 'Précédent', prev: 'Précédent',
next: 'Suivant', next: 'Suivant',
page: (value: number) => `Page : ${value}`, page: (value: number) => `Page: ${value}`,
total: (total: number) => `Total : ${total}`, total: (total: number) => `Total: ${total}`,
size: (size: number) => `${size}/Page` size: (size: number) => `${size}/Page`
}, },
picker: { picker: {