Rework localization in spotter
This commit is contained in:
@@ -136,16 +136,11 @@ function shared.Spotter.Init()
|
|||||||
local class = UnitClass(unit)
|
local class = UnitClass(unit)
|
||||||
if not class then return string.format("Could not find class for unit %s", tostring(unit)) end
|
if not class then return string.format("Could not find class for unit %s", tostring(unit)) end
|
||||||
|
|
||||||
local location = Heimdall_Data.config.spotter.zoneOverride
|
---@type string, string
|
||||||
if not location or location == "" then
|
local zone, subzone = GetZoneText() or "Unknown", GetSubZoneText() or "Unknown"
|
||||||
local zone = GetZoneText()
|
if Heimdall_Data.config.spotter.zoneOverride then
|
||||||
if not zone then return string.format("Could not find zone for unit %s", tostring(unit)) end
|
zone = Heimdall_Data.config.spotter.zoneOverride or ""
|
||||||
local subzone = GetSubZoneText()
|
subzone = ""
|
||||||
if not subzone then subzone = "" end
|
|
||||||
if Heimdall_Data.config.spotter.debug then
|
|
||||||
print(string.format("[%s] Player %s location: %s (%s)", ModuleName, name, zone, subzone))
|
|
||||||
end
|
|
||||||
location = string.format("%s (%s)", zone, subzone)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local x, y = GetPlayerMapPosition("player")
|
local x, y = GetPlayerMapPosition("player")
|
||||||
@@ -157,80 +152,38 @@ function shared.Spotter.Init()
|
|||||||
local stinky = shared.IsStinky(name) or false
|
local stinky = shared.IsStinky(name) or false
|
||||||
SetMapToCurrentZone()
|
SetMapToCurrentZone()
|
||||||
SetMapByID(GetCurrentMapAreaID())
|
SetMapByID(GetCurrentMapAreaID())
|
||||||
local text = string.format(shared.L.en.spotterSpotted,
|
local areaId = tostring(GetCurrentMapAreaID())
|
||||||
hostile and shared.L.en.tidbits.hostile or shared.L.en.tidbits.friendly,
|
|
||||||
name,
|
|
||||||
class,
|
|
||||||
stinky and string.format("(%s)", "!!!!") or "",
|
|
||||||
race,
|
|
||||||
faction,
|
|
||||||
pvpOn and shared.L.en.tidbits.pvpOn or shared.L.en.tidbits.pvpOff,
|
|
||||||
string.gsub(FormatHP(hp), "M", "kk"),
|
|
||||||
string.gsub(FormatHP(maxHp), "M", "kk"),
|
|
||||||
location,
|
|
||||||
tostring(GetCurrentMapAreaID()),
|
|
||||||
x * 100, y * 100)
|
|
||||||
|
|
||||||
if Heimdall_Data.config.spotter.debug then
|
for _, channel in pairs(Heimdall_Data.config.spotter.channels) do
|
||||||
print(string.format("[%s] Sending notification: %s", ModuleName, text))
|
if Heimdall_Data.config.spotter.debug then
|
||||||
end
|
print(string.format("[%s] Processing channel: %s", ModuleName, channel))
|
||||||
|
end
|
||||||
|
local locale = shared.GetLocaleForChannel(channel)
|
||||||
|
local text = string.format(shared._L("spotterSpotted", locale),
|
||||||
|
hostile and shared._L("hostile", locale) or shared._L("friendly", locale),
|
||||||
|
name,
|
||||||
|
shared._L(class, locale),
|
||||||
|
stinky and string.format("(%s)", "!!!!") or "",
|
||||||
|
shared._L(race, locale),
|
||||||
|
shared._L(faction, locale),
|
||||||
|
pvpOn and shared._L("pvpOn", locale) or shared._L("pvpOff", locale),
|
||||||
|
string.gsub(FormatHP(hp), "M", "kk"),
|
||||||
|
string.gsub(FormatHP(maxHp), "M", "kk"),
|
||||||
|
shared._L(zone, locale), shared._L(subzone, locale),
|
||||||
|
areaId,
|
||||||
|
x * 100, y * 100)
|
||||||
|
|
||||||
---@type Message
|
---@type Message
|
||||||
local msg = {
|
local msg = {
|
||||||
channel = "C",
|
|
||||||
data = Heimdall_Data.config.spotter.notifyChannel,
|
|
||||||
message = text
|
|
||||||
}
|
|
||||||
table.insert(shared.messenger.queue, msg)
|
|
||||||
|
|
||||||
local ruClass = shared.L.ru.classes[class]
|
|
||||||
if not ruClass then
|
|
||||||
print(string.format("[%s] Class %s not found in ru.classes", ModuleName, class))
|
|
||||||
end
|
|
||||||
local ruRace = shared.L.ru.races[race]
|
|
||||||
if not ruRace then
|
|
||||||
print(string.format("[%s] Race %s not found in ru.races", ModuleName, race))
|
|
||||||
end
|
|
||||||
local ruFaction = shared.L.ru.factions[faction]
|
|
||||||
if not ruFaction then
|
|
||||||
print(string.format("[%s] Faction %s not found in ru.factions", ModuleName, faction))
|
|
||||||
end
|
|
||||||
local zone, subzone = GetZoneText(), GetSubZoneText()
|
|
||||||
local ruZone = shared.L.ru.zones[zone]
|
|
||||||
if not ruZone then
|
|
||||||
print(string.format("[%s] Zone %s not found in ru.zones", ModuleName, zone))
|
|
||||||
end
|
|
||||||
local ruSubzone = shared.L.ru.zones[subzone]
|
|
||||||
if not ruSubzone then
|
|
||||||
print(string.format("[%s] Subzone %s not found in ru.zones", ModuleName, subzone))
|
|
||||||
end
|
|
||||||
|
|
||||||
text = string.format(shared.L.ru.spotterSpotted,
|
|
||||||
hostile and shared.L.ru.tidbits.hostile or shared.L.ru.tidbits.friendly,
|
|
||||||
name,
|
|
||||||
ruClass or class,
|
|
||||||
stinky and string.format("(%s)", "!!!!") or "",
|
|
||||||
ruRace or race,
|
|
||||||
ruFaction or faction,
|
|
||||||
pvpOn and shared.L.ru.tidbits.pvpOn or shared.L.ru.tidbits.pvpOff,
|
|
||||||
string.gsub(FormatHP(hp), "M", "kk"),
|
|
||||||
string.gsub(FormatHP(maxHp), "M", "kk"),
|
|
||||||
string.format("%s (%s)", ruZone or zone, ruSubzone or subzone),
|
|
||||||
tostring(GetCurrentMapAreaID()),
|
|
||||||
x * 100, y * 100)
|
|
||||||
|
|
||||||
if Heimdall_Data.config.spotter.debug then
|
|
||||||
print(string.format("[%s] Sending notification: %s", ModuleName, text))
|
|
||||||
end
|
|
||||||
|
|
||||||
if Heimdall_Data.config.echoToRussian then
|
|
||||||
-- Russian message
|
|
||||||
local ruMsg = {
|
|
||||||
channel = "C",
|
channel = "C",
|
||||||
data = Heimdall_Data.config.spotter.notifyChannel .. "ru",
|
data = channel,
|
||||||
message = text
|
message = text
|
||||||
}
|
}
|
||||||
table.insert(shared.messenger.queue, ruMsg)
|
if Heimdall_Data.config.spotter.debug then
|
||||||
|
print(string.format("[%s] Queuing spotter message", ModuleName))
|
||||||
|
shared.dumpTable(msg)
|
||||||
|
end
|
||||||
|
table.insert(shared.messenger.queue, msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user