Originally Posted by Fizzlemizz
Lua Code:
local locale = GetLocale() -- get the current locale eg. "frFR" local function updateData() wipe(data) for _, item in ipairs(addon.db) do local announceText = item.announce[locale] or item.announce.enUS -- default to enUS if the locale text doesn't exist. tinsert(data, {announceText, item.icon, item.name}) end end
|
Yes, this option is ideal (after all, I don’t know what languages the players who install the addon speak, but many speak English)
Lua Code:
local addonName, addon = ...
addon.db = {
{
name = {
enUS = "Herb-Infused Water",
deDE = "Mit Kräutern aromatisiertes Wasser"
},
questID = 75612,
icon = "interface/icons/inv_mushroom_11",
item = 210399,
item = 210400,
item = 210401,
item = 210402,
item = 210403,
item = 210404,
announce = {
enUS = "Awarded for %ss outstanding service %sss to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald %ssss Dream to receive powerful \nequipment for your efforts",
}
},
{
name = "Emerald Mark of Mastery",
questID = 75624,
icon = "interface/icons/inv_mushroom_11",
item = 20897,
announce = {
enUS = "Awarded for outstanding service to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
}
},
{
name = "Emerald Mark of Mastery",
questID = 74352,
icon = "interface/icons/inv_mushroom_11",
item = 193440,
announce = {
enUS = "Awarded for outstanding service to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
}
}
}
---------------------------------------------------------------------------------------------------
-- Code to replace %s in announce texts with item links. Replaces the GetItemLinkById(...) function
local function LoadItem(item)
for k, v in pairs(addon.db[item.dbID].announce) do -- replace the %s with the itemlink in eal locale in the .announce key
addon.db[item.dbID].announce[k] = format(v, item:GetItemLink())
end
end
for i, v in ipairs(addon.db) do
local item = Item:CreateFromItemID(v.item)
item.dbID = i
item:ContinueOnItemLoad(function() LoadItem(item) end)
end
During the creation of the addon, a question arose. One link to a item in the text is missing; you need to insert 2,3 or more links into one text. As I understand it, you need to set different variables, for example
%ss or
%sss or
%d, so that each one is tied to a specific position of the link to the item.