Skip to content

Commit 4319fa9

Browse files
fix: 🐛 修复部分国际化文本不正确的问题 (#970)
1 parent 49fe25a commit 4319fa9

3 files changed

Lines changed: 6 additions & 16 deletions

File tree

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
/*
2-
* @Author: weisheng
3-
* @Date: 2024-01-25 23:06:48
4-
* @LastEditTime: 2025-02-14 11:20:02
5-
* @LastEditors: 810505339
6-
* @Description:
7-
* @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\components\composables\useTranslate.ts
8-
* 记得注释
9-
*/
10-
import { camelCase, getPropByPath, isFunction } from '../common/util'
1+
import { camelCase, getPropByPath, isDef, isFunction } from '../common/util'
112
import Locale from '../../locale'
123

134
export const useTranslate = (name?: string) => {
145
const prefix = name ? camelCase(name) + '.' : ''
156
const translate = (key: string, ...args: unknown[]) => {
167
const currentMessages = Locale.messages()
178
const message = getPropByPath(currentMessages, prefix + key)
18-
return isFunction(message) ? message(...args) : message
9+
return isFunction(message) ? message(...args) : isDef(message) ? message : `${prefix}${key}`
1910
}
20-
2111
return { translate }
2212
}

src/uni_modules/wot-design-uni/locale/lang/en-US.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export default {
7979
pagination: {
8080
prev: 'Previous',
8181
next: 'Next',
82-
page: (value: number) => `Page${value}`,
83-
total: (total: number) => `Total${total}`,
82+
page: (value: number) => `Page: ${value}`,
83+
total: (total: number) => `Total: ${total}`,
8484
size: (size: number) => `${size}/page`
8585
},
8686
picker: {

src/uni_modules/wot-design-uni/locale/lang/fr-FR.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export default {
7575
pagination: {
7676
prev: 'Précédent',
7777
next: 'Suivant',
78-
page: (value: number) => `Page : ${value}`,
79-
total: (total: number) => `Total : ${total}`,
78+
page: (value: number) => `Page: ${value}`,
79+
total: (total: number) => `Total: ${total}`,
8080
size: (size: number) => `${size}/Page`
8181
},
8282
picker: {

0 commit comments

Comments
 (0)