oh yea. Args are no table anymore. Lets see..
Solved Chat translation
Discussion in 'Plugin Requests' started by Arion, Jan 23, 2015.
-
I had a few free minutes, so.. check this out.
Attached Files:
-
-
Thanks for your help! all of you!
finally i can speak language of my own! thanks! how kind! -
Glad to help
And here's a little update to prevent possible abuse of tags.Attached Files:
-
-
hmm I got little problem
this script can't show complete Hangul(Korean) character
it convert like this ㅇㅗㄱㅅㅏㅇㅣㄷㅡ (Oxide as hangul) ,complete character is 옥사이드(Oxide as hangul)
T^TAttached Files:
-
-
I have only parsed everything from the lua script, probably it's been incomplete? -
Hangul is the structure in which one character is completed by combining the at least one consonant and one vowel .
[DOUBLEPOST=1442850266][/DOUBLEPOST]like thisAttached Files:
-
-
Did it worked correctly on 1.18?
-
yup and other korean experimental server uses korean translation plugin, but they never share the plugin
-
That's strange. I've just tested your Lua version in a standalone way.
Ideone.com
Result:
ㅒㅌㅑㅇㄷ
It isn't right? -
o -> ㅐ , x -> ㅌ, i -> ㅑ, d -> ㅇ
it's corret and
dhrtkdlem = 옥사이드 -
ㅇㅗㄱㅅㅏㅇㅣㄷㅡ
Don't know where is the problem.. code, ideone, my browser or my locale. No idea, and especially i've never worked with such situations. -
this is working script of older oxide
hmm...Attached Files:
-
-
You do not have permission to view this page or perform this action.... why cant download...
-
Give players the ability to select a language via command (say /russian) and from then on when they type in global chat it is shared with all other people subscribed to /russian but not others.
They should still receive the default global chat (so they can monitor what is going on, trades, etc). -
Looking for a mod similar to that of the one on rust. THis plugin would simply translate anything said in chat to english by posting the original text in their language and then the translation after.
-
Recently I continue my server and I'm still looking for korean translation plugin
I found this source and I translated comments for convenience
Code:// Chosung = Consonant // [You can ignore this] private static string m_ChoSungTbl = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ"; private static string elements_ConsonantTbl = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ";// Jungsung = Vowel // [You can ignore this] private static string m_JungSungTbl = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ"; private static string elements_VowelTbl = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ";// Jongsung = Final consonant // [You can ignore this] private static string m_JongSungTbl = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ"; // Don't remove space, It's stands for that doesn't have final consonant character private static string elements_FinalConsonantTbl = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ";// Hangul unicode starts here private static ushort ref_UniCodeHangulBase = 0xAC00; // Hangul unicode ends here private static ushort ref_UniCodeHangulLast = 0xD79F;// Hangul = consonant + vowel + final consonant // ex) ㅇ + ㅗ + ㄱ = 옥// Unicode hangul consonant address = consonant index * 21 // Unicode hangul vowel address = vowel index * 28 // Unicode hangul final consonant address = final consonant index// thus UnicodeHangulChar = ref_UniCodeHangulBase + (ConsonantPos * 21 + VowelPos * 28) + FinalConsonantPospublic static string MergeElements(string Consonant, string Vowel, string FinalConsonant) { int ConsonantPos, VowelPos, FinalConsonantPos; int UnicodeHangul; ConsonantPos = elements_ConsonantTbl.IndexOf(Consonant); // Consonant position VowelPos = elements_VowelTbl.IndexOf(Vowel); // Vowel position FinalConsonantPos = elements_FinalConsonantTbl.IndexOf(FinalConsonant); // Final consonant position' UnicodeHangul = ref_UniCodeHangulBase + (ConsonantPos * 21 + VowelPos) * 28 + FinalConsonantPos; // Convert unicode to char char temp = Convert.ToChar(UnicodeHangul); return temp.ToString(); }
I need your help!
I think it's better
[DOUBLEPOST=1455044221,1455032842][/DOUBLEPOST]Code:PLUGIN.Title = "EnglishToKorean" PLUGIN.Description = "convert english chat to korean."function PLUGIN:Init() self:AddChatCommand( "ko", self.ToKorean ) end function PLUGIN:ToKorean( netuser, cmd, args ) local str = ""; for i,v in pairs(args) do str = str .. self:englishToKorean(v) .. " " end rust.BroadcastChat( "nickname", str )endfunction PLUGIN:conv2utf8(unicode_list) local result = '' local w,x,y,z = 0,0,0,0 local function modulo(a, b) return a - math.floor(a/b) * b end for i,v in ipairs(unicode_list) do if v ~= 0 and v ~= nil then if v <= 0x7F then -- same as ASCII result = result .. string.char(v) elseif v >= 0x80 and v <= 0x7FF then -- 2 bytes y = math.floor(modulo(v, 0x000800) / 64) z = modulo(v, 0x000040) result = result .. string.char(0xC0 + y, 0x80 + z) elseif (v >= 0x800 and v <= 0xD7FF) or (v >= 0xE000 and v <= 0xFFFF) then -- 3 bytes x = math.floor(modulo(v, 0x010000) / 4096) y = math.floor(modulo(v, 0x001000) / 64) z = modulo(v, 0x000040) result = result .. string.char(0xE0 + x, 0x80 + y, 0x80 + z) elseif (v >= 0x10000 and v <= 0x10FFFF) then -- 4 bytes w = math.floor(modulo(v, 0x200000) / 262144) x = math.floor(modulo(v, 0x040000) / 4096) y = math.floor(modulo(v, 0x001000) / 64) z = modulo(v, 0x000040) result = result .. string.char(0xF0 + w, 0x80 + x, 0x80 + y, 0x80 + z) end end end return result endfunction PLUGIN:englishToKorean(msg) if msg == nil then return "nil" end local text = msg; -- 한글의 초,중,종성의 인덱스 local initialCode = 0; local medialCode = 0; local finalCode = 0; -- 루프와 결과 저장을 위한 변수 local textLength = #text local ret = ""; local cont = 0 for idx = 1, textLength do -- lua는 루프 내부에서 idx 변수를 변화 시켜도 루프에 영향을 주지 않는다. -- 스킵한 문자를 위한 continue 처리를 위해 cont 사용 if cont < idx then -- 초성 검색 local first = text:sub( idx, idx ) initialCode = self:getCode( 'initial', text:sub( idx, idx ) ); idx = idx + 1; -- 다음 영타로 중성을 찾아야 한다. if initialCode ~= -1 then -- 두번째 영문으로 중성을 추론한다. -- ㅘ, ㅝ, ㅙ 등 2번의 입력으로 구성된 중성을 우선 검색한다. tempMedialCode = self:getCode( 'medial', text:sub( idx, idx + 1 ) ); if tempMedialCode ~= -1 then -- 중성을 찾았다면 사용한 영타 2자를 스킵한다. medialCode = tempMedialCode; idx = idx + 2; else -- 찾지 못했다면 한번의 입력을 구성된 중성을 검색한다. medialCode = self:getCode( 'medial', text:sub( idx, idx ) ); idx = idx + 1; end -- 마지막으로 종성을 검색한다. -- 않, 값 등 받침이 2번의 입력으로 구성된 종성을 우선 검색한다. tempFinalCode = self:getCode( 'final', text:sub( idx, idx + 1 ) ); if tempFinalCode ~= -1 then finalCode = tempFinalCode; -- 발견했다면 이 문자가 종성인지 아니면 다음 한글의 초성인지를 판단해야 한다. -- 이어지는 영타가 중성에 포함되는지를 확인한다. tempMedialCode = self:getCode( 'medial', text:sub( idx + 2, idx + 2 ) ); if tempMedialCode ~= -1 then -- 이어지는 문자가 중성이라면 2번의 입력 중 뒤에 것은 다음 글자의 초성이 된다. finalCode = self:getCode( 'final', text:sub( idx, idx ) ); else idx = idx + 1; end else -- 또다시 중성이 이어진다면 종성은 존재하지 않는 것이다. tempMedialCode = self:getCode( 'medial', text:sub( idx + 1, idx + 1 ) ); if tempMedialCode ~= -1 then -- 가ㅏ 처럼 중성이 두번 이어지면 종성은 없는 것으로 간주한다. finalCode = 0; idx = idx - 1; else -- 하나의 입력으로 이루어진 종성을 검색한다. finalCode = self:getCode( 'final', text:sub( idx, idx ) ); if finalCode == -1 then finalCode = 0; end end end end -- 초성을 찾지 못했다면 특수 문자로 간주하고 그문자를 그대로 사용한다. if initialCode < 0 then ret = ret .. first else local code = 44032 + initialCode + medialCode + finalCode local ch = self:conv2utf8({code}) ret = ret .. ch end cont = idx; end end return ret endfunction PLUGIN:getCode( tt, char ) -- 초성 리스트 local initial = { 'r','R','s','e','E','f','a','q','Q','t','T','d','w','W','c','z','x','v','g'}; -- 중성 리스트 local medial = { 'k', 'o', 'i', 'O', 'j', 'p', 'u', 'P', 'h', 'hk', 'ho', 'hl', 'y', 'n', 'nj', 'np', 'nl', 'b', 'm', 'ml', 'l' }; -- 종성 리스트 local final = { 'r', 'R', 'rt', 's', 'sw', 'sg', 'e', 'f', 'fr', 'fa', 'fq', 'ft', 'fx', 'fv', 'fg', 'a', 'q', 'qt', 't', 'T', 'd', 'w', 'c', 'z', 'x', 'v', 'g' }; local returnCode = 0; -- 최종 인덱스 local isFind = false; -- 발견 여부 -- 각 리스트에서 인덱스를 검색하기 위한 로컬 함수 local find = function(tb, ch) for i = 1, #tb do if tb[i] == ch then returnCode = i-1; -- Lua는 인덱스가 1부터 시작되기 때문에.. isFind = true; break; end end end if char ~= nil then if tt == 'initial' then find( initial, char ) returnCode = returnCode * 21 * 28 elseif tt == 'medial' then find( medial, char ) returnCode = returnCode * 28 elseif tt == 'final' then find( final, char ) returnCode = returnCode + 1 end end if isFind == false then returnCode = -1; end return returnCode; end
-
korean people never share with other people for their own server.
what a shame.
help me wulffffffffffff -
hi guys is there a working Chat Translator plugin ? got alot off Russian people chatting in the chat . and like it to translate to English
-
Wulf Community Admin