Hey all, I'm having a localization issue with one of my addons. It's a simple addon that counts all the gems you have equipped and which color they are. The problem is the api I'm using to determine the color of the gem uses localized strings: GetItemInfo(gemItemID) returns localized itemSubType ie. "Red" for a red gem, "Blue" for a blue.
local testGem = (select(7, GetItemInfo(gem)))
if testGem == "Red" then
redGems = redGems + 1
elseif testGem == "Blue" then
blueGems = blueGems + 1
---- and so on
Is there any easy way to make this to work on other clients or do I have to create a localization file for all the languages? :(
You need to localize it for each language or use a gemID table that has the color information for each gem. For an up-to-date gemID table with color information you can take a look at CharScanner, there is a file with all current ingame gemIDs...but I don't know if this is useful for your needs, maybe simply localize is better.
Sure, it's easier to get data from your unit than from other units, but:
First: GetItemInfo()/GetItemGem() fails if you do not have that item in your local cache.
Second: What do you do with eg. green, purple or orange gems? A green gem (eg: 52237 ) is blue/yellow, but there is no global loca string for 'Green'/... available...
What you get for sure (if you use a good method) is the complete itemLink from any item and unit ("Inspect" or "Character"), regardless if your local cache is empty or not. A complete itemLink contains all gemIDs. The fastest, securest, precisest, resource-efficient and sadly maintenance-intensive method is currently a gemID table OR (with local cache failure possibility) a localization table for _all_ languages and all possible return values (blue/red/yellow/green/orange/purple/prismatic/meta/hydraulic/cogwheel).