Module:Region: Difference between revisions
From Zelda Wiki, the Zelda encyclopedia
no edit summary
PhantomCaleb (talk | contribs) (Created page with "local p = {} local Data = mw.loadData("Module:Region/Data") local CATEGORY_INVALID_ARGS = "Category:"..require("Module:Constants/category/invalidArgs").."" local CLASS_TOOLTIP = require("Module:Constants/class/tooltip") function p.flag(code, size) size = size or Data.defaultFlagSize local region = Data.regions[code] if not region then return nil, CATEGORY_INVALID_ARGS elseif region.flag then local name = region.official or region.name local flagFile = reg...") |
PhantomCaleb (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
local Data = mw.loadData("Module:Region/Data") | local Data = mw.loadData("Module:Region/Data") | ||
local DEFAULT_FLAG_SIZE = "20px" | |||
local CATEGORY_INVALID_ARGS = "[[Category:"..require("Module:Constants/category/invalidArgs").."]]" | local CATEGORY_INVALID_ARGS = "[[Category:"..require("Module:Constants/category/invalidArgs").."]]" | ||
local CLASS_TOOLTIP = require("Module:Constants/class/tooltip") | local CLASS_TOOLTIP = require("Module:Constants/class/tooltip") | ||
function p.flag(code, size) | function p.flag(code, size) | ||
size = size or | size = size or DEFAULT_FLAG_SIZE | ||
local region = Data.regions[code] | local region = Data.regions[code] | ||
if not region then | if not region then | ||
Line 22: | Line 23: | ||
return flags, nil | return flags, nil | ||
else | else | ||
return "", nil | |||
end | end | ||
end | |||
function p.Schemas(frame) | |||
return { | |||
Data = { | |||
type = "record", | |||
required = true, | |||
properties = { | |||
{ | |||
name = "regions", | |||
required = true, | |||
type = "map", | |||
desc = "A list of regions that Nintendo (or other Zelda-related companies) markets to.", | |||
keyPlaceholder = "code", | |||
keys = { | |||
type = "string", | |||
desc = "An {{Wp|ISO 3166-1 alpha-2}} country code, or a 3+ character code denoting a multi-country region forming a single market segment.", | |||
}, | |||
values = { | |||
type = "record", | |||
properties = { | |||
{ | |||
name = "name", | |||
required = true, | |||
type = "string", | |||
desc = "The name of the country or region.", | |||
}, | |||
{ | |||
name = "official", | |||
type = "string", | |||
desc = "The official state name of the country. Defaults to <code>name</code>.", | |||
}, | |||
{ | |||
name = "flag", | |||
type = "string", | |||
desc = "The file name of the region's flag", | |||
}, | |||
{ | |||
name = "countries", | |||
type = "array", | |||
items = { type = "string" }, | |||
desc = "For multi-country regions, a list of country codes that comprise the region.", | |||
}, | |||
}, | |||
}, | |||
}, | |||
}, | |||
} | |||
} | |||
end | end | ||