Ahmed Ly Posted August 29, 2017 Posted August 29, 2017 hello guys how can i make translate. Arabic To English for Example if i put in memo "ا" translated to "A" Code ; translations = { ["A"] = "ا" , ["B"] = "ب" } window = guiCreateWindow(262, 164, 590, 357, "", false) guiWindowSetSizable(window, false) guiSetVisible(window,false) English = guiCreateMemo(14, 44, 215, 176, "", false, window) Arabic = guiCreateMemo(370, 44, 211, 176, "", false, window) addEventHandler("onClientGUIChanged",root, function () if source == Arabic then local selectedLanguage = guiGetText(Arabic) guiSetText(English, translations[selectedLanguage]['A']) end end ) function open () if guiGetVisible(window) == false then guiSetVisible(window,true) showCursor(true) else guiSetVisible(window,false) showCursor(false) end end bindKey("F6","down",open)
Zorgman Posted August 29, 2017 Posted August 29, 2017 This would be transliteration, not actual translation, and be warned that it follows particular sets of rules, depending on the language. You may find this useful: https://en.wikipedia.org/wiki/Romanization_of_Arabic Cheers
Moderators IIYAMA Posted August 29, 2017 Moderators Posted August 29, 2017 https://stackoverflow.com/questions/19782148/lua-substitute-list-of-characters-in-string 1
Scripting Moderators thisdp Posted August 30, 2017 Scripting Moderators Posted August 30, 2017 (edited) translations = { ["A"] = "ا" , ["B"] = "ب" } function ArabicToEnglish(str) for k,v in pairs(translations) do str = str:gsub(v,k) end return str end translations = { ["ا"] = "A" , ["ب"] = "B" , } function ArabicToEnglish(str) str:gsub(".",translations) --I don't know whether this works return str end Edited August 30, 2017 by thisdp 1
Ahmed Ly Posted August 30, 2017 Author Posted August 30, 2017 4 hours ago, thisdp said: translations = {["A"] = "ا" ,["B"] = "ب"}function ArabicToEnglish(str) for k,v in pairs(translations) do str = str:gsub(v,k) end return strend translations = {["ا"] = "A" ,["ب"] = "B" ,}function ArabicToEnglish(str) str:gsub(".",translations) --I don't know whether this works return strend thank you bro
Scripting Moderators thisdp Posted August 30, 2017 Scripting Moderators Posted August 30, 2017 2 hours ago, Ahmed Ly said: thank you bro np 2 hours ago, Ahmed Ly said: thank you bro I have made a mistake translations = { ["ا"] = "A" , ["ب"] = "B" , } function ArabicToEnglish(str) return str:gsub(".",translations) --I don't know whether this works end 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now