add gs
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
local GuiRoot = CoreGui:FindFirstChild("RobloxGui")
|
||||
local Modules = GuiRoot:FindFirstChild("Modules")
|
||||
local ShellModules = Modules:FindFirstChild("Shell")
|
||||
local Utility = require(ShellModules:FindFirstChild('Utility'))
|
||||
local enUS = require(Modules:FindFirstChild('en-us'))
|
||||
|
||||
local defaultLocale = nil
|
||||
local success;
|
||||
local LocaleId;
|
||||
success, LocaleId = pcall(function() return game:GetService("LocalizationService").RobloxLocaleId end)
|
||||
|
||||
local this = {}
|
||||
|
||||
function this:GetLocale()
|
||||
local localeModule = Modules:FindFirstChild(LocaleId)
|
||||
if success and localeModule then
|
||||
defaultLocale = require(localeModule)
|
||||
else
|
||||
-- we don't have a country code for the module, so find it by language
|
||||
-- ex. we store Spanish as "es.lua"
|
||||
for lang in string.gmatch(LocaleId ,"([^-]+)") do
|
||||
local module = Modules:FindFirstChild(lang)
|
||||
if module then
|
||||
defaultLocale = require(module)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defaultLocale == nil then
|
||||
defaultLocale = enUS
|
||||
end
|
||||
|
||||
return defaultLocale
|
||||
end
|
||||
|
||||
function this:LocalizedString(stringKey)
|
||||
local locale = defaultLocale and defaultLocale or self:GetLocale()
|
||||
local result = locale and locale[stringKey]
|
||||
if not result then
|
||||
Utility.DebugLog("LocalizedString: Could not find string for:" , stringKey , "using locale:" , locale)
|
||||
result = enUS[stringKey] or stringKey
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
return this
|
||||
Reference in New Issue
Block a user