View Single Post
11/02/15, 07:04 AM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
Originally Posted by merlight View Post
No, in French it's in the middle: Glyphe Fort Vital
You could get away with splitting it into words and removing those found in the 0-level name. Seems a bit too complicated (and error-prone) for something that can be done with one table per language.
True, but where is the fun in that :P

Lua Code:
  1. local allowedItemType = {
  2.     [ITEMTYPE_GLYPH_WEAPON] = true,
  3.     [ITEMTYPE_GLYPH_ARMOR] = true,
  4.     [ITEMTYPE_GLYPH_JEWELRY] = true,
  5. }
  6. local function GetItemLinkGlyphStrengthLabel(link)
  7.     if(not allowedItemType[GetItemLinkItemType(link)]) then return end
  8.     -- get the base name of the glyph
  9.     local data = {zo_strsplit(":", link)}
  10.     data[4], data[5] = 0, 0 -- at quality and level 0 there is no prefix
  11.     local baseName = zo_strformat("<<t:1>>", GetItemLinkName(table.concat(data, ":")))
  12.     -- generate a lookup table of all words in the name
  13.     local baseTokens = {}
  14.     baseName:gsub("(%a+)%s*", function(token) baseTokens[token] = true end)
  15.     -- remove the base name from the link
  16.     local name = zo_strformat("<<t:1>>", GetItemLinkName(link))
  17.     return name:gsub("(%a+)%s*", function(token)
  18.         if(baseTokens[token]) then return "" end
  19.     end):gsub("^%s*(.-)%s*$", "%1")
  20. end
  21.  
  22. local prefix = GetItemLinkGlyphStrengthLabel("|H1:item:5364:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h")
  23. df("'%s'", prefix)
  Reply With Quote