if Players.LocalPlayer==nil then(Players:GetPropertyChangedSignal("\076\111\099\097\108\080\108\097\121\101\114")):Wait()end local F local function B()if F==nil then F=CoreGui.CoreScriptLocalization:GetTranslator(LocalizationService.RobloxLocaleId)end return F end local N={}local function j(F)local B=N[F]if B then return B end B=CoreGui.CoreScriptLocalization:GetTranslator(F)N[F]=B return B end local function x(F,B,N)local j,x=pcall(function()return N:FormatByKey(F,B)end)if j then return x else return FALLBACK_ENGLISH_TRANSLATOR:FormatByKey(F,B)end end local p={}function p.FormatByKey(j,F,N)if FFlagCoreScriptEnableRobloxTranslatorFallback then return x(F,N,B())else return(B()):FormatByKey(F,N)end end function p.FormatByKeyForLocale(p,F,B,N)if FFlagCoreScriptEnableRobloxTranslatorFallback then return x(F,N,j(B))else return(j(B)):FormatByKey(F,N)end end return p

if Players.LocalPlayer == nil then
    Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
end

local coreScriptTableTranslator
local function getTranslator()
    if coreScriptTableTranslator == nil then
        coreScriptTableTranslator = CoreGui.CoreScriptLocalization:GetTranslator(
            LocalizationService.RobloxLocaleId)
    end
    return coreScriptTableTranslator
end

local translatorsCache = {}

local function getTranslatorForLocale(locale)
    local translator = translatorsCache[locale]
    if translator then
        return translator
    end

    translator = CoreGui.CoreScriptLocalization:GetTranslator(locale)
    translatorsCache[locale] = translator

    return translator
end

local function formatByKeyWithFallback(key, args, translator)
    local success, result = pcall(function()
        return translator:FormatByKey(key, args)
    end)

    if success then
        return result
    else
        return FALLBACK_ENGLISH_TRANSLATOR:FormatByKey(key, args)
    end
end

local RobloxTranslator = {}

function RobloxTranslator:FormatByKey(key, args)
    if FFlagCoreScriptEnableRobloxTranslatorFallback then
        return formatByKeyWithFallback(key, args, getTranslator())
    else
        return getTranslator():FormatByKey(key, args)
    end
end

function RobloxTranslator:FormatByKeyForLocale(key, locale, args)
    if FFlagCoreScriptEnableRobloxTranslatorFallback then
        return formatByKeyWithFallback(key, args, getTranslatorForLocale(locale))
    else
        return getTranslatorForLocale(locale):FormatByKey(key, args)
    end
end

return RobloxTranslator
