Help with Language on chat

Hey there,
So before I begin, a short reason why I am creating this thread -

Simple, I speak 2 languages : English and Hebrew,

Now-
When I type something in Hebrew in roblox games, it goes backwards. Example:

If I said “מה קורה”( “Ma Kore”) which is translated to “Sup”
It would appear on chat as “קורה מה” (“Kore Ma”)( opposite)

So to make it easier for you to understand,
Assume I have 2 words - “Hey” and “There”.

Obviously, if I said that on chat, the results should be completely fine. Now,
What if it went backwards ( instead of “Hey there”, it would go as “there Hey”).
I hope it’s understandable.

How would I make it spell out my Hebrew words correctly? I tried to use Unicode and some characters, but didnt seem to work.

Try dividing your string up into words (separate with space) and then reverse their order.

Yeah, that’s what I’d thought to do before I posted it but nothing seemed to work. Weird.

Tried doing this?

local msg = "Kore Ma"

local words = msg:split(" ")

local reversed = ""
for i=#words, 1, -1 do
	reversed ..= words[i] .. " "
end
print(msg) -- "Kore Ma"
print(reversed) -- "Ma Kore"

Yeah, works nice with english. But not with hebrew words.

Video:

Its because :split will only use english characters, i assume. I dont really think theres a workaround for this, i think you may just have to manually do it if its for a NPC chat.

1 Like

Is it possible to make it for chat? I mean, I want hebrew speakers to properly see their messages as its supposed to be

I currently have this function

local function replace_non_letters(str, replace_to)
	str = str:gsub("[%d%p]", '')
	local ret = ''
	for _, char in utf8.codes(str) do
		local add_letter = false
		
		if char == 32 -- Spaces
			--Hebrew
			or ((char >= 0x590) and (char <= 0x6d5))
		then
			add_letter = true
		end
		if add_letter then
			ret = ret .. utf8.char(char)
		else
			ret = ret .. (replace_to or '')
		end
	end
	return ret
end

I tested it , and it printed the exactly way it’s supposed to! Although, on chat - still incorrect version,
So I thought I could just replace the incorrect sentence from the chat with the correct one [using that function]

1 Like

Yeah if chat doesnt work properly, you can just ovverride it by sending messages and potentially deleting the users original chat.

1 Like
local function replace_non_letters(str, replace_to)
	str = str:gsub("[%d%p]", '')
	local ret = ''
	for _, char in utf8.codes(str) do
		local add_letter = false

		if char == 32 -- Spaces
			--Hebrew
			or ((char >= 0x590) and (char <= 0x6d5))
		then
			add_letter = true
		end
		if add_letter then
			ret = ret .. utf8.char(char)
		else
			ret = ret .. (replace_to or '')
		end
	end
	return ret
end


local functionId = "FixHebrew"

local function doFilter(speaker, messageObject, channelName)
	messageObject.Message = replace_non_letters(messageObject.Message)
end

local function runChatModule(ChatService)
	ChatService:RegisterFilterMessageFunction(functionId, doFilter)
end

return runChatModule

I have this module inside the ChatModule folder, and now these 2 happen:
1.When I say an English word, it just removes it from chat.
2.Does not replace the incorrect one.

I am prob missing here something

I think the only issue I am having now is with the bubble chat itself, I need to replace that one with the correct one.

local chat = game:GetService("Chat")

local function replace_non_letters(str, replace_to)
	str = str:gsub("[%d%p]", '')
	local ret = ''
	for _, char in utf8.codes(str) do
		local add_letter = false

		if char == 32 -- Spaces
			--Hebrew
			or ((char >= 0x590) and (char <= 0x6d5))
		then
			add_letter = true
		end
		if add_letter then
			ret = ret .. utf8.char(char)
		else
			ret = ret .. (replace_to or '')
		end
	end
	return ret
end


local functionId = "FixHebrew"

local function doFilter(speaker, messageObject, channelName)
	messageObject.Message = replace_non_letters(messageObject.Message)
	print(messageObject.Message)
	print(replace_non_letters(messageObject.Message))
	print(speaker)
	chat:Chat(game.Workspace:FindFirstChild(speaker).Head,replace_non_letters(messageObject.Message))
end

local function runChatModule(ChatService)
	ChatService:RegisterFilterMessageFunction(functionId, doFilter)
end

return runChatModule

I currently have this

I solved it, thanks everyone who gave their opinions and help!