fix: useI18n fallback for empty string translations from chrome.i18n

This commit is contained in:
雨霖铃
2026-05-28 21:53:35 +08:00
parent 5175677b24
commit 97159cb799
+2 -2
View File
@@ -36,8 +36,8 @@ export function useI18n(namespace?: string | string[]) {
// 先尝试直接查找 key // 先尝试直接查找 key
let message = getMessage(msgId); let message = getMessage(msgId);
// 如果直接查找未命中,尝试命名空间前缀(使用转换后的 msgId) // 如果直接查找未命中(空字符串或返回 key 本身),尝试命名空间前缀(使用转换后的 msgId)
if (message === msgId && namespaces.length > 0) { if ((!message || message === msgId) && namespaces.length > 0) {
for (const ns of namespaces) { for (const ns of namespaces) {
const candidate = `${ns}_${msgId}`; const candidate = `${ns}_${msgId}`;
const result = getMessage(candidate); const result = getMessage(candidate);