import Config from "../Config"; import { gameMethod } from "../common/gameMethod"; import { Lang } from "../data/const/TypeConst"; import { I18n } from "./I18nUtil"; import { uiCommon } from "./UICommon"; const { ccclass, property, menu } = cc._decorator; @ccclass @menu("I18N/I18nLabel") export default class I18nLabel extends cc.Component { @property(cc.String) key: string = ""; @property(cc.Boolean)//是否是表内文本 isLang: boolean = false; @property(cc.Boolean)//是否修正字体布局 fix:boolean = false @property([cc.String]) args: string[] = []; setI18nLabel() { //优先key值 let str = ""; if (this.isLang) { str = I18n.getI18nLang(this.key, ...this.args); } else str = I18n.getI18nText(this.key, ...this.args); uiCommon.setLabel(this.node, this.fix ? uiCommon.fixName(str) : str); } onLoad() { this.setI18nLabel(); } }