If french (frFR) didn't exists then
Code:
tinsert(data, {item.announce[GetLocale()], item.icon, item.name})
would be the same as
Code:
tinsert(data, {item.announce["frFR"], item.icon, item.name})
which in the end would be
Code:
tinsert(data, {nil, item.icon, item.name})
Inserting
nil will cause tinsert to error.
You could use something like the following that will test if the users locale
announce field is in addon.db and if not, default to using the enUS text.
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
This assumes there will be a enUS field in EVERY announce table.
You could of course, if you prefer, default to
.frFR or
.deDE whichever locale oocures in every entry.