Module:number list: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 194: Line 194:
local alt_pagename = args[3] or false
local alt_pagename = args[3] or false
local remove_suffix = args[4] or false
local remove_suffix = args[4] or false
lang = "av"
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
-- Get the data from the data module.
-- Get the data from the data module.
-- [[Module:number list/data/en]] has to be loaded with require because its
-- [[Module:number list/data/en]] has to be loaded with require because its
-- exported numbers table has a metatable.
-- exported numbers table has a metatable.
local module_name = "Module:number list/data/av"
local module_name = "Module:number list/data/" .. lang:getCode()
local m_data = require(module_name)
local m_data = require(module_name)
Line 231: Line 231:
end
end
for _, form_type in ipairs(export.get_number_types("av")) do
for _, form_type in ipairs(export.get_number_types(lang:getCode())) do
local numeral = cur_data[form_type.key]
local numeral = cur_data[form_type.key]
if numeral then
if numeral then
Line 244: Line 244:
for _, numeral in ipairs(numerals) do
for _, numeral in ipairs(numerals) do
-- If this number is the current page, then store the key for later use
-- If this number is the current page, then store the key for later use
if not cur_type == full_pagename then
if not cur_type and lang:makeEntryName(numeral) == full_pagename then
cur_type = form_type.key
cur_type = form_type.key
end
end
Line 383: Line 383:
end
end
local canonical_name = "Avendonian"
local canonical_name = lang:getCanonicalName()
local appendix1 = canonical_name .. ' numerals'
local appendix1 = canonical_name .. ' numerals'
local appendix2 = canonical_name .. ' numbers'
local appendix2 = canonical_name .. ' numbers'
Line 455: Line 455:
local lang = args[1] or (mw.title.getCurrentTitle().nsText == "Template" and "und") or error("Language code has not been specified. Please pass parameter 1 to the template.")
local lang = args[1] or (mw.title.getCurrentTitle().nsText == "Template" and "und") or error("Language code has not been specified. Please pass parameter 1 to the template.")
local sc = args["sc"];
local headlink = args["headlink"]
local headlink = args["headlink"]
local wplink = args["wplink"]
local wplink = args["wplink"]
Line 488: Line 489:


lang = "av"
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
require("Module:debug").track("number list/" .. lang)
require("Module:debug").track("number list/" .. lang:getCode())
if sc then
require("Module:debug").track("number list/sc")
end
if headlink then
if headlink then
Line 508: Line 514:
end
end
local lang_type = lang:getType()
local subpage = mw.title.getCurrentTitle().subpageText
local subpage = mw.title.getCurrentTitle().subpageText
local is_reconstructed = lang_type == "reconstructed" or mw.title.getCurrentTitle().nsText == "Reconstruction"
local is_reconstructed = lang_type == "reconstructed" or mw.title.getCurrentTitle().nsText == "Reconstruction"
Line 522: Line 529:
end
end
local header = Avendonian .. " " .. num_type .. " numbers"
local header = lang:getCanonicalName() .. " " .. num_type .. " numbers"
if headlink then
if headlink then
Line 531: Line 538:
if prev_term or prev_symbol then
if prev_term or prev_symbol then
previous = m_links.full_link({lang = lang, term = prev_term, alt = " <  " .. prev_symbol, tr = "-"})
previous = m_links.full_link({lang = lang, sc = sc, term = prev_term, alt = " <  " .. prev_symbol, tr = "-"})
end
end
local current = m_links.full_link({lang = lang, alt = cur_symbol, tr = "-"})
local current = m_links.full_link({lang = lang, sc = sc, alt = cur_symbol, tr = "-"})
local next = ""
local next = ""
if next_term or next_symbol then
if next_term or next_symbol then
next = m_links.full_link({lang = lang, term = next_term, alt = next_symbol .. "  > ", tr = "-"})
next = m_links.full_link({lang = lang, sc = sc, term = next_term, alt = next_symbol .. "  > ", tr = "-"})
end
end
Line 545: Line 552:
if cardinal_term then
if cardinal_term then
table.insert(forms, "     ''[[cardinal number|Cardinal]]'' : " .. m_links.full_link({lang = lang, term = cardinal_term, alt = cardinal_alt, tr = cardinal_tr}))
table.insert(forms, "     ''[[cardinal number|Cardinal]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = cardinal_term, alt = cardinal_alt, tr = cardinal_tr}))
end
end
if ordinal_term then
if ordinal_term then
table.insert(forms, "     ''[[ordinal number|Ordinal]]'' : " .. m_links.full_link({lang = lang, term = ordinal_term, alt = ordinal_alt, tr = ordinal_tr}))
table.insert(forms, "     ''[[ordinal number|Ordinal]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = ordinal_term, alt = ordinal_alt, tr = ordinal_tr}))
end
end
if adverbial_term then
if adverbial_term then
table.insert(forms, "     ''[[adverbial number|Adverbial]]'' : " .. m_links.full_link({lang = lang, term = adverbial_term, alt = adverbial_alt, tr = adverbial_tr}))
table.insert(forms, "     ''[[adverbial number|Adverbial]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = adverbial_term, alt = adverbial_alt, tr = adverbial_tr}))
end
end
if multiplier_term then
if multiplier_term then
table.insert(forms, "     ''[[multiplier|Multiplier]]'' : " .. m_links.full_link({lang = lang, term = multiplier_term, alt = multiplier_alt, tr = multiplier_tr}))
table.insert(forms, "     ''[[multiplier|Multiplier]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = multiplier_term, alt = multiplier_alt, tr = multiplier_tr}))
end
end
if distributive_term then
if distributive_term then
table.insert(forms, "     ''[[distributive number|Distributive]]'' : " .. m_links.full_link({lang = lang, term = distributive_term, alt = distributive_alt, tr = distributive_tr}))
table.insert(forms, "     ''[[distributive number|Distributive]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = distributive_term, alt = distributive_alt, tr = distributive_tr}))
end
end
if collective_term then
if collective_term then
table.insert(forms, "     ''[[collective number|Collective]]'' : " .. m_links.full_link({lang = lang, term = collective_term, alt = collective_alt, tr = collective_tr}))
table.insert(forms, "     ''[[collective number|Collective]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = collective_term, alt = collective_alt, tr = collective_tr}))
end
end
if fractional_term then
if fractional_term then
table.insert(forms, "     ''[[fractional|Fractional]]'' : " .. m_links.full_link({lang = lang, term = fractional_term, alt = fractional_alt, tr = fractional_tr}))
table.insert(forms, "     ''[[fractional|Fractional]]'' : " .. m_links.full_link({lang = lang, sc = sc, term = fractional_term, alt = fractional_alt, tr = fractional_tr}))
end
end
if optional1_title then
if optional1_title then
table.insert(forms, "     ''" .. optional1_title .. "'' : " .. m_links.full_link({lang = lang, term = optional1_term, alt = optional1_alt, tr = optional1_tr}))
table.insert(forms, "     ''" .. optional1_title .. "'' : " .. m_links.full_link({lang = lang, sc = sc, term = optional1_term, alt = optional1_alt, tr = optional1_tr}))
end
end
if optional2_title then
if optional2_title then
table.insert(forms, "     ''" .. optional2_title .. "'' : " .. m_links.full_link({lang = lang, term = optional2_term, alt = optional2_alt, tr = optional2_tr}))
table.insert(forms, "     ''" .. optional2_title .. "'' : " .. m_links.full_link({lang = lang, sc = sc, term = optional2_term, alt = optional2_alt, tr = optional2_tr}))
end
end
Line 584: Line 591:
if wplink then
if wplink then
footer =
footer =
"[[w:" .. "av" .. ":Main Page|" .. "Avendonian" .. " Wikipedia]] article on " ..
"[[w:" .. lang:getCode() .. ":Main Page|" .. lang:getCanonicalName() .. " Wikipedia]] article on " ..
m_links.full_link({lang = lang, term = "w:" .. "av" .. ":" .. wplink, alt = alt, tr = tr})
m_links.full_link({lang = lang, sc = sc, term = "w:" .. lang:getCode() .. ":" .. wplink, alt = alt, tr = tr})
end
end

Navigation menu