Skip to content

Commit 1302a03

Browse files
author
李磊
committed
fix: i18n bug
1 parent 60fccb7 commit 1302a03

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"editor.defaultFormatter": "esbenp.prettier-vscode"
5757
},
5858
"[jsonc]": {
59-
"editor.defaultFormatter": "esbenp.prettier-vscode"
59+
"editor.defaultFormatter": "vscode.json-language-features"
6060
},
6161
"[vue]": {
6262
"editor.defaultFormatter": "esbenp.prettier-vscode"

packages/i18n/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ class I18n {
113113
}
114114
this.logger.warn(`[i18n] Key not found: ${key}`);
115115
}
116-
return (i18next.t(key, options) || key) as string;
116+
return (i18next.t(key, {
117+
...options,
118+
lng: lang || DEFAULT_LNG,
119+
}) || key) as string;
117120
}
118121

119122
/**
@@ -126,7 +129,10 @@ class I18n {
126129
if (!key) return false;
127130
const lang = reactiveLang.value;
128131
if (i18next.exists(key)) {
129-
return i18next.t(key, options) as string;
132+
return i18next.t(key, {
133+
...options,
134+
lng: lang || DEFAULT_LNG,
135+
}) as string;
130136
} else if (lang) {
131137
const obj = i18next.getResourceBundle(lang, 'translation');
132138
if (obj && obj[key]) {

0 commit comments

Comments
 (0)