Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ServTr:CheckColor(text)
- local color, _text = {}, {}
- for _c, _t in string.gfind(text, "(|cff%x%x%x%x%x%x)(.-)|r\10?") do
- color[getn(color)+1] = _c
- _text[getn(_text)+1] = _t
- end
- if getn(color) > 0 and getn(_text) > 0 then
- return _text, color
- else
- return {text}
- end
- end
- function ServTr:GetText(db,text)
- if not text then return nil end
- local color
- text, color = self:CheckColor(text)
- db = _G[self.db.profile.language.."_"..db]
- local result = ""
- local flag = false
- if type(db)=="table" then
- for i = 1, getn(text) do
- local trans_text
- if db[text[i]] then
- trans_text = db[text[i]]
- flag = true
- elseif getn(text) > 1 and not db[text[i]] then
- trans_text = text[i]
- end
- if color and color[i] and trans_text then
- trans_text = color[i]..trans_text.."|r"
- if i < getn(text) then
- trans_text = trans_text.."\10"
- end
- end
- if trans_text then result = result..trans_text end
- end
- end
- if result ~= "" and flag then return self:prepare(result) end
- return nil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement