Advertisement
Shuraken007

Untitled

Apr 25th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. function ServTr:CheckColor(text)
  2.     local color, _text = {}, {}
  3.     for _c, _t in string.gfind(text, "(|cff%x%x%x%x%x%x)(.-)|r\10?") do
  4.         color[getn(color)+1] = _c
  5.         _text[getn(_text)+1] = _t
  6.     end
  7.     if getn(color) > 0 and getn(_text) > 0 then
  8.         return _text, color
  9.     else
  10.         return {text}
  11.     end
  12. end
  13.    
  14. function ServTr:GetText(db,text)
  15.     if not text then return nil end
  16.     local color
  17.     text, color = self:CheckColor(text)
  18.     db = _G[self.db.profile.language.."_"..db]
  19.     local result = ""
  20.     local flag = false
  21.     if type(db)=="table" then
  22.         for i = 1, getn(text) do
  23.             local trans_text
  24.             if db[text[i]] then
  25.                 trans_text = db[text[i]]
  26.                 flag = true
  27.             elseif getn(text) > 1 and not db[text[i]] then
  28.                 trans_text = text[i]
  29.             end
  30.             if color and color[i] and trans_text then
  31.                 trans_text = color[i]..trans_text.."|r"
  32.                 if i < getn(text) then
  33.                     trans_text = trans_text.."\10"
  34.                 end
  35.             end
  36.             if trans_text then result = result..trans_text end
  37.         end
  38.     end
  39.     if result ~= "" and flag then return self:prepare(result) end
  40.     return nil
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement