多语言如果选择了不支持的语言,默认为英文

This commit is contained in:
TJH 2026-05-27 17:35:51 +08:00
parent 4d45e6338f
commit 33bbb63b9a
2 changed files with 12 additions and 2 deletions

View File

@ -33,7 +33,14 @@ export class I18nManager {
const task = new Promise<SpriteFrame>((resolve, reject) => {
resources.load(path, SpriteFrame, (err, sf) => {
this._sfTasks.delete(key);
if (err || !sf) return reject(err);
if (err || !sf) {
resources.load(`i18nSprite2/en/${name}/spriteFrame`, SpriteFrame, (err, sf) => {
this._sfTasks.delete(key);
this.spriteFrameCache.set(key, sf);
resolve(sf);
});
return;
}
this.spriteFrameCache.set(key, sf);
resolve(sf);
});
@ -103,6 +110,9 @@ export class I18nManager {
let okSpine = await this.preloadAssets('spine', []);
this.ready = okSprite && okAtlas && okSpine;
if (!this.ready) {
this.init('en', languageJson)
}
} catch (error) {
console.error('I18nManager init failed:', error);
}

View File

@ -38,7 +38,7 @@ export class UIManager {
let main = prefab.getChildByName('main');
if (!main) {
console.error(`UIManager ${name}prefab 没有main节点命名不规范: ${path}`);
// console.error(`UIManager ${name}prefab 没有main节点命名不规范: ${path}`);
return;
}
if (callBack) callBack(prefab);