View Single Post
02/15/19, 06:10 AM   #3
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Klingo View Post
1) List professions, respectively re-use the different tabs from the Craft Bag. Getting the name from Filter Types seems still safe.
Yes, this is relatively safe, as long as the filters remain available. But don't hardcode the enum value, these are not so unlikely to change sometimes.
Lua Code:
  1. -- SI_ITEMFILTERTYPE17 = "Enchanting"
  2. GetString("SI_ITEMFILTERTYPE", ITEMFILTERTYPE_ENCHANTING)


Originally Posted by Klingo View Post
4) Group the different repair kits under one common name. Reading a hook point and cut off the colon at the end, because there is no native string for "Repair Kit(s)".
Lua Code:
  1. -- SI_HOOK_POINT_STORE_REPAIR_KIT_HEADER = "Repair Kits:"
  2. string.sub(GetString(SI_HOOK_POINT_STORE_REPAIR_KIT_HEADER),0,-2) -- "Repair Kit"
I wouldn't do this. You can't be sure that there will be a colon in other languages. There might be some multi-byte character (like an innocent non-breaking space), and this would make the string ill-formed UTF-8.

edit: oh, you're cutting not just the colon, but the "s", too. Well that is plain wrong, different languages form plurals in different ways
edit 2: no you're not, I got confused by the comment "Repair Kit". sub(s, 1, -2) cuts one byte.

Last edited by merlight : 02/15/19 at 06:16 AM.
  Reply With Quote