2025-07-18 01:11:49 +08:00
|
|
|
-- 本地化读取工具
|
2025-07-16 00:45:20 +08:00
|
|
|
local Localization = {}
|
|
|
|
|
|
|
|
--> Services
|
|
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
|
|
local LocalizationService = game:GetService("LocalizationService")
|
|
|
|
|
|
|
|
--> Modules
|
|
|
|
local Utils = require(ReplicatedStorage.Tools.Utils)
|
|
|
|
|
|
|
|
--> Json
|
|
|
|
local JsonLanguage_En_US = require(ReplicatedStorage.Json.Language_En_US)
|
|
|
|
local JsonLanguage_Zh_CN = require(ReplicatedStorage.Json.Language_Zh_CN)
|
|
|
|
local JsonImage_En_US = require(ReplicatedStorage.Json.Image_En_US)
|
|
|
|
local JsonImage_Zh_CN = require(ReplicatedStorage.Json.Image_Zh_CN)
|
|
|
|
|
|
|
|
--> Variables
|
|
|
|
local LocalPlayer = game.Players.LocalPlayer
|
2025-07-18 01:11:49 +08:00
|
|
|
local SystemLocaleId = LocalizationService.SystemLocaleId
|
2025-07-16 00:45:20 +08:00
|
|
|
|
|
|
|
-- 获取本地Json文件
|
|
|
|
function Localization:GetLocalizationJson()
|
|
|
|
if SystemLocaleId == "zh-CN" then
|
|
|
|
return JsonLanguage_Zh_CN, JsonImage_Zh_CN
|
|
|
|
else
|
|
|
|
return JsonLanguage_En_US, JsonImage_En_US
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-07-18 01:11:49 +08:00
|
|
|
local JsonLanguage, JsonImage = Localization:GetLocalizationJson()
|
|
|
|
|
2025-07-16 00:45:20 +08:00
|
|
|
-- 获取文本Id数据
|
|
|
|
function Localization:GetLanguageData(Id: number)
|
|
|
|
if not Id then return end
|
|
|
|
return Utils:GetIdDataFromJson(JsonLanguage, Id).text
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 获取图片Id数据
|
|
|
|
function Localization:GetImageData(Id: number)
|
|
|
|
if not Id then return end
|
|
|
|
return Utils:GetIdDataFromJson(JsonImage, Id).sourceId
|
|
|
|
end
|
|
|
|
|
|
|
|
return Localization
|