多语言如果选择了不支持的语言,默认为英文
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m17s

This commit is contained in:
TJH 2026-05-27 17:35:51 +08:00
parent 4d45e6338f
commit c6cc9873f1
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) => { const task = new Promise<SpriteFrame>((resolve, reject) => {
resources.load(path, SpriteFrame, (err, sf) => { resources.load(path, SpriteFrame, (err, sf) => {
this._sfTasks.delete(key); 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); this.spriteFrameCache.set(key, sf);
resolve(sf); resolve(sf);
}); });
@ -103,6 +110,9 @@ export class I18nManager {
let okSpine = await this.preloadAssets('spine', []); let okSpine = await this.preloadAssets('spine', []);
this.ready = okSprite && okAtlas && okSpine; this.ready = okSprite && okAtlas && okSpine;
if (!this.ready) {
this.init('en', languageJson)
}
} catch (error) { } catch (error) {
console.error('I18nManager init failed:', error); console.error('I18nManager init failed:', error);
} }

View File

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