-- try localize whole/part of string
-- no more-than-1 replacement for current existing keys.

function ChatLocalization:tryLocalize(rawString)
	if existingKey[rawString] then
		return self:Get(existingKey[rawString], rawString)
	end

	for enString, localizationKey in pairs(existingKey) do
		if string.find(rawString, enString) then
			local localizedPart = self:Get(localizationKey, enString)
			return string.gsub(rawString, enString, localizedPart, 1)
		end
	end

	for pattern, info in pairs(whisperPatterns) do
		local startIndex = string.find(rawString, pattern)
		local namePart = string.match(rawString, pattern)
		if startIndex and namePart then
			local localizedPart = self:Get(info.LocalizationKey, info.English)
			local startPart = if startIndex > 1 then rawString:sub(1, startIndex - 1) else ""
			return startPart .. localizedPart .. namePart
		end
	end

	return rawString
end

return ChatLocalization
