Skip to content

Commit 3f9d7e9

Browse files
committed
fix: comments
1 parent 40b3cae commit 3f9d7e9

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

packages/runtime/plugin-i18n/src/runtime/i18n/detection/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ const initializeI18nForDetector = async (
383383

384384
const safeUserOptions = pickSafeDetectionOptions(options.userInitOptions);
385385

386-
// 仅初始化检测能力,不加载任何资源,避免与后续 backend 初始化冲突。
386+
// Only initialize detection capability, don't load any resources to avoid conflicts with subsequent backend initialization
387387
const initOptions: I18nInitOptions = {
388388
...safeUserOptions,
389389
fallbackLng: options.fallbackLanguage,
@@ -395,7 +395,7 @@ const initializeI18nForDetector = async (
395395
},
396396
};
397397

398-
// 确保检测实例加载了语言探测插件
398+
// Ensure the detector instance has the language detection plugin loaded
399399
useI18nextLanguageDetector(instance);
400400

401401
if (!instance.isInitialized) {
@@ -465,9 +465,9 @@ const detectLanguageFromI18nextDetector = async (
465465
} catch (error) {
466466
// Silently ignore errors
467467
} finally {
468-
// 清理临时实例,避免影响后续正式初始化
468+
// Clean up temporary instance to avoid affecting subsequent formal initialization
469469
if (isTemporary && detectorInstance !== i18nInstance) {
470-
// 临时实例保存在缓存中,留待复用
470+
// Temporary instance is saved in cache for reuse
471471
detectorInstanceCache.set(i18nInstance, {
472472
instance: detectorInstance,
473473
isTemporary: true,
@@ -478,7 +478,7 @@ const detectLanguageFromI18nextDetector = async (
478478
),
479479
});
480480
} else if (detectorInstance === i18nInstance) {
481-
// 作为兜底,防止 i18nInstance 被检测 init 污染
481+
// As a fallback, prevent i18nInstance from being polluted by detector init
482482
(i18nInstance as any).isInitialized = false;
483483
delete (i18nInstance as any).language;
484484
}

tests/integration/i18n/custom-i18n-wrapper/src/App.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,15 @@ export default function App() {
55
const { language, changeLanguage, i18nInstance } = useModernI18n();
66
const [text, setText] = useState('');
77

8-
// 更新文本的函数
98
const updateText = () => {
109
if (i18nInstance) {
1110
setText((i18nInstance as any).t('key'));
1211
}
1312
};
1413

1514
useEffect(() => {
16-
// 初始更新
1715
updateText();
1816

19-
// 监听资源加载和语言变更事件
2017
const loadedHandler = () => {
2118
updateText();
2219
};
@@ -37,7 +34,6 @@ export default function App() {
3734
};
3835
}, [i18nInstance]);
3936

40-
// 当语言改变时,立即更新文本(因为资源可能已经加载)
4137
useEffect(() => {
4238
updateText();
4339
}, [language, i18nInstance]);

tests/integration/i18n/custom-i18n-wrapper/src/starlingWrapper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function createStarlingWrapper() {
4040
t(...args: any[]) {
4141
return inner.t.apply(inner, args as any);
4242
},
43-
// 事件系统:转发到内部的 i18next 实例
43+
// Event system: forward to inner i18next instance
4444
on(event: string, callback: (...args: any[]) => void) {
4545
if (typeof inner.on === 'function') {
4646
inner.on(event, callback);
@@ -59,7 +59,6 @@ export function createStarlingWrapper() {
5959
}
6060
return this;
6161
},
62-
// 其他可能需要的属性
6362
get isInitialized() {
6463
return inner.isInitialized;
6564
},

0 commit comments

Comments
 (0)