local _, ns = ...

ns.Locale = ns.Locale or {}
ns.Locale.tables = ns.Locale.tables or {}

function ns.Locale:Register(localeKey, values)
    if type(localeKey) ~= "string" or type(values) ~= "table" then
        return
    end

    self.tables[localeKey] = values
end

function ns.Locale:Build(localeKey)
    local selected = {}
    local base = self.tables.enUS or {}

    for key, value in pairs(base) do
        selected[key] = value
    end

    local localized = self.tables[localeKey]
    if localized and localized ~= base then
        for key, value in pairs(localized) do
            selected[key] = value
        end
    end

    ns.L = selected
    return selected
end
