@liujitcn/kratos-taro-app-core 0.0.75 → 0.0.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/locales/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* 各语言 JSON 由模块定义文件导入,不能在 JSON 文件内添加注释。
|
|
4
4
|
*/
|
|
5
5
|
import Taro from '@tarojs/taro'
|
|
6
|
+
import { useCallback } from 'react'
|
|
6
7
|
import { create } from 'zustand'
|
|
7
8
|
import type { KratosTaroModule } from '../module'
|
|
8
9
|
import type { I18nCustomItem } from '../rpc/base/v1/config'
|
|
@@ -196,10 +197,14 @@ export function t(key: string, params: LocaleParams = {}, locale = getCurrentLoc
|
|
|
196
197
|
export function useI18n() {
|
|
197
198
|
useLocaleMessagesRevision()
|
|
198
199
|
const locale = useLocaleStore((state) => state.locale)
|
|
200
|
+
const translate = useCallback(
|
|
201
|
+
(key: string, params: LocaleParams = {}) => t(key, params, locale),
|
|
202
|
+
[locale],
|
|
203
|
+
)
|
|
199
204
|
return {
|
|
200
205
|
locale,
|
|
201
206
|
setLocale: setCurrentLocale,
|
|
202
|
-
t:
|
|
207
|
+
t: translate,
|
|
203
208
|
}
|
|
204
209
|
}
|
|
205
210
|
|