
local L = AceLibrary("AceLocale-2.2"):new("PratAddonMsgs")

L:RegisterTranslations("enUS", function() return {
    ["AddonMsgs"] = true,
    ["AddonMsgs options."] = true,
    ["Toggle"] = true,
    ["Toggle the module on and off."] = true,
    ["Show"] = true,
    ["Toggle showing hidden addon messages for each window."] = true,
    ["Chat%dAddonMsgsShow"] = true,
    ["Toggles showing hidden addon messages on and off for chat window %d."] = true
} end)

L:RegisterTranslations("zhCN", function() return {
    ["AddonMsgs"] = "插件信息",
    ["AddonMsgs options."] = "插件信息设置",
    ["Toggle"] = "选择",
    ["Toggle the module on and off."] = "选择打开或关闭",
    ["Show"] = "显示",
    ["Toggle showing hidden addon messages for each window."] = "选择是否在每个窗口显示插件信息",
    ["Chat%dAddonMsgsShow"] = "在窗口%d显示插件信息",
    ["Toggles showing hidden addon messages on and off for chat window %d."] = "选择是否在聊天窗口%d显示隐藏的插件信息."
} end)

L:RegisterTranslations("koKR", function() return {
    ["AddonMsgs"] = "애드온 메시지",
    ["AddonMsgs options."] = "애드온 메시지 옵션",
    ["Toggle"] = "전환",
    ["Toggle the module on and off."] = "모듈 켜고 끄기를 전환합니다.",
    ["Show"] = "표시",
    ["Toggle showing hidden addon messages for each window."] = "각 창에 대한 애드온 메시지 표시를 전환합니다.",
    ["Chat%dAddonMsgsShow"] = "대화%d 애드온 메시지 표시",
    ["Toggles showing hidden addon messages on and off for chat window %d."] = "대화창%d에 대한 애드온 메시지 켜고 끄기를 전환합니다."
} end)

L:RegisterTranslations("zhTW", function() return {
    ["AddonMsgs"] = "插件訊息",
    ["AddonMsgs options."] = "插件訊息選項",
    ["Toggle"] = "切換",
    ["Toggle the module on and off."] = "切換打開或關閉",
    ["Show"] = "顯示",
    ["Toggle showing hidden addon messages for each window."] = "切換是否在每個視窗顯示插件訊息",
    ["Chat%dAddonMsgsShow"] = "在視窗%d顯示插件訊息",
    ["Toggles showing hidden addon messages on and off for chat window %d."] = "選擇是否在聊天視窗%d顯示隱藏的插件信息。"
} end)

Prat_AddonMsgs = Prat:NewModule("AddonMsgs")

function Prat_AddonMsgs:OnInitialize()
    self.db = Prat:AcquireDBNamespace("AddonMsgs")
    Prat:RegisterDefaults("AddonMsgs", "profile", {
        on = false,
        show = {false, false, false, false, false, false, false},
    })
    Prat.Options.args.AddonMsgs = {
        name = L["AddonMsgs"],
        desc = L["AddonMsgs options."],
        type = "group",
        args = {
            show = {
                name = L["Show"],
                desc = L["Toggle showing hidden addon messages for each window."],
                type = "group",
                order = 110,
                args = {
                    chat1 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 1),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 1),
                        type = "toggle",
                        get = function() return self.db.profile.show[1] end,
                        set = function(v) self.db.profile.show[1] = v;  end
                    },
                    chat2 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 2),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 2),
                        type = "toggle",
                        get = function() return self.db.profile.show[2] end,
                        set = function(v) self.db.profile.show[2] = v; end
                    },
                    chat3 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 3),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 3),
                        type = "toggle",
                        get = function() return self.db.profile.show[3] end,
                        set = function(v) self.db.profile.show[3] = v;  end
                    },
                    chat4 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 4),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 4),
                        type = "toggle",
                        get = function() return self.db.profile.show[4] end,
                        set = function(v) self.db.profile.show[4] = v;  end
                    },
                    chat5 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 5),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 5),
                        type = "toggle",
                        get = function() return self.db.profile.show[5] end,
                        set = function(v) self.db.profile.show[5] = v;  end
                    },
                    chat6 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 6),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 6),
                        type = "toggle",
                        get = function() return self.db.profile.show[6] end,
                        set = function(v) self.db.profile.show[6] = v;  end
                    },
                    chat7 = {
                        name = string.format(L["Chat%dAddonMsgsShow"], 7),
                        desc = string.format(L["Toggles showing hidden addon messages on and off for chat window %d."], 7),
                        type = "toggle",
                        get = function() return self.db.profile.show[7] end,
                        set = function(v) self.db.profile.show[7] = v;  end
                    },
                },
            },
            toggle = {
                name = L["Toggle"],
                desc = L["Toggle the module on and off."],
                type = "toggle",
                order = 200,
                get = function() return self.db.profile.on end,
                set = function() self.db.profile.on = Prat:ToggleModuleActive("AddonMsgs") end
            }
        }
    }
end

function Prat_AddonMsgs:OnEnable()
    self:RegisterEvent("CHAT_MSG_ADDON")
end


--[[------------------------------------------------
	Core Functions
------------------------------------------------]]--

function Prat_AddonMsgs:CHAT_MSG_ADDON()
    for i=1,NUM_CHAT_WINDOWS do
		if self.db.profile.show[i] then 
			getglobal("ChatFrame"..i):AddMessage("[|cffffff00"..arg1.."|r][|cffa0a0a0"..arg2.."|r][|cff00ff00"..arg3.."|r][|cff0000ff"..arg4.."|r]")
		end
    end
end

