if Players.LocalPlayer==nil then(Players:GetPropertyChangedSignal("\076\111\099\097\108\080\108\097\121\101\114")):Wait()end local e local function C()if e==nil then e=CoreGui.CoreScriptLocalization:GetTranslator(LocalizationService.RobloxLocaleId)end return e end local D={}local function m(e)local C=D[e]if C then return C end C=CoreGui.CoreScriptLocalization:GetTranslator(e)D[e]=C return C end local function S(e,C,D)local m,S=pcall(function()return D:FormatByKey(e,C)end)if m then return S else return FALLBACK_ENGLISH_TRANSLATOR:FormatByKey(e,C)end end local I={}function I.FormatByKey(m,e,D)if FFlagCoreScriptEnableRobloxTranslatorFallback then return S(e,D,C())else return(C()):FormatByKey(e,D)end end function I.FormatByKeyForLocale(I,e,C,D)if FFlagCoreScriptEnableRobloxTranslatorFallback then return S(e,D,m(C))else return(m(C)):FormatByKey(e,D)end end return I
-- Waiting for the player ensures that the RobloxLocaleId has been set.
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
