Localizations = { defaultLang = 'en', --英文 ["en"] = { ["ERROR: Carrier unit %s is not found in mission."] = "ERROR: Carrier unit %s is not found in mission.", ["world"] = "World", ["welcome"] = "Welcome" }, --中文 ["zh"] = { ["ERROR: Carrier unit %s is not found in mission."] = "错误: 在任务中没有找到航母单位 %s .", ["world"] = "世界", ["welcome"] = "欢迎" } } do function Localizations:translate(text, langCode) if not text then return end if not langCode or type(langCode) ~= 'string' then langCode = self.defaultLang end langCode = string.lower(langCode) local langTable = Localizations[langCode] local result = text if not langTable then local defaultLangTable = Localizations[self.defaultLang] if defaultLangTable then local result = defaultLangTable[text] or text end end if langTable then result = langTable[text] or text end return result end end