require('strict')
local p = {}  
-- -------------------------< P R I V A T E _ T A G S >------------------------------------------------------  
Reads the override{} table in Module:Lang/data and renders a wiki table of private tags and their associated languages  
local function private_tags
local override_t = mw.loadData ('Module:Lang/data').override -- get the override table  
local private_t = {}  
for tag, lang in pairs (override_t) do
if tag:find ('%-x%-') then
table.insert (private_t, table.concat ({'\n|-\n|', lang, '||', tag}))
end
end
table.sort (private_t)  
table.insert (private_t, 1, '{|')
table.insert (private_t, 2, '\n|+ Supported private-use IETF language tags')
table.insert (private_t, 3, '\n! Language !! Private-use tag')  
return table.concat (private_t) .. '\n|}'
-- return '<pre>' .. table.concat (private_t) .. '\n|}' .. '</pre>'
--error (mw.dumpObject (private_t))
end  
-- -------------------------< L A N G - X X _ S E T T I N G S >----------------------------------------------  
Reads the content of the template and extracts the parameters from for display on the template's
documentation page.  
local function lang_xx_settings
local page = mw.title.makeTitle('Template', .args['template'] or .args[1]) -- get a page object for this page in 'Template:' namespace
if not page then
return '' -- TODO: error message?
end  
local content = page:getContent -- get unparsed content
if not page then
return '' -- TODO: error message?
end  
local out = {}  
local params
local style  
if content:match(*) or content:match(*) then -- if this template uses Module:Lang
params = content:match(*) or content:match(*) -- extract the #invoke:'s parameters
if not params then
return '' -- there should be at least one or the template/module won't work TODO: error message?
end
table.insert(out, '{|\n|+settings') -- start a wikitable
for k, v in params:gmatch('%s*|%s*([^%s=]+)%s*=%s*([^%s|]+)') do -- get the parameter names (k) and values (v)
if 'label' == k then -- special case for labels because spaces and pipes
v = params:match('label%s*=%s*(%[%^%+%]%])') or params:match('label%s*=%s*([^|\n]+)') or 'missing label'
end
table.insert(out, table.concat({k, '\n|', v})) -- make rudimentary wikitable entries
end  
style = content:match('lang_xx_([^|]+)')
if not style or ('italic' ~= mw.text.trim (style) and 'inherit' ~= mw.text.trim (style)) then
return '<span>Error: template #invoke calls unknown function</span>'
end
return table.concat({table.concat(out,'\n|-\n! scope="row" | '), '\n|-\n||style: ', style, '\n|-\n|}'}) -- add inter-row markup and close the wikitable and done
else
return '' -- does not use Module:Lang so abandon quietly
end
end  
--[[ -------------------------- < U S E S _ M O D U L E > --------------------------  
Reads the content of the template to determine if this template uses Module:Lang.
Returns the index of the substring '
table.insert(layout, string.format(non_english_language_text_strings["LINE2"], lang_template))  
local language_code_link = lang_module._name_from_tag({language_code, link="yes", label=language_code})
local example_default_text = string.format(non_english_language_text_strings["EXAMPLE_DEFAULT_TEXT"], language_name)
local example_text = args.example or example_default_text
local lang_template_example = :expandTemplate{title = "Tlx", args = {non_english_language_text_strings["TEMPLATE"], language_code_link, example_text}}
local langx_args = {non_english_language_text_strings["TEMPLATE2"], language_code_link, example_text}
local langx_template_example = :expandTemplate{title = "Tlx", args = {non_english_language_text_strings["TEMPLATE2"], language_code, example_text}}
local langx_template_code = :expandTemplate{title = non_english_language_text_strings["TEMPLATE2"], args = {language_code, example_text}}  
-- Strip private use subtag from code tag because this is what Module:Lang does.
local language_code_without_private_use = language_code:gsub("%-x%-.*", "")  
-- Wrap in syntaxhighlight.
local syntaxhighlight = :extensionTag(
"syntaxhighlight",
string.format(non_english_language_text_strings["LINE3_SYNTAXHIGHLIGHT"], language_code_without_private_use),
{lang = "html", inline = true}  
table.insert(layout, string.format(non_english_language_text_strings["LINE3"], lang_template_example, syntaxhighlight, langx_template_example, langx_template_code))
local see_also_section = get_see_also_section(page.text, language_name, language_code)  
local parent_language_code = get_primary_language_code(language_code)
local parent_language_category
if parent_language_code then
parent_language_category = lang_module._category_from_tag({parent_language_code})
end  
local bottom = get_bottom_section(, language_name, see_also_section, non_english_language_text_strings["PARENT_CATEGORY"], parent_language_category)
return table.concat(layout, "\n\n") .. bottom
end  
-- -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ S O U R C E S _ C A T E G O R Y > --------------------------  
This function implements .  
local non_english_language_sources_strings = {
["LINE1"] = "This is a tracking category for articles that use %s to identify %s sources.",
["PARENT_CATEGORY"] = "",
["TEMPLATE"] = "In lang",
}  
local function non_english_language_sources_category
local page = mw.title.getCurrentTitle
local args = require('Module:Arguments').getArgs
-- args.test is used for /testcases
if args.test then
page = mw.title.new(args.test)
end  
local page_title = page.text
local language_code = page_title:match('%(([%a%-]+)%)')
local language_name = require('Module:Lang')._name_from_tag({language_code})  
local layout = {}
table.insert(layout, get_hidden_category_template)
local parent_category = non_english_language_sources_strings["PARENT_CATEGORY"]  
local in_lang_module = require('Module:In lang')
local correct_language_category_title = in_lang_module._in_lang({language_code, ["list-cats"]="yes"})
if correct_language_category_title == "" then
-- Error: No category title found for language code.
return make_error(string.format(error_messages["NO_CATEGORY_TITLE_FOUND"], language_code), layout, parent_category, args.nocat)
end  
local current_category_title = page.prefixedText
if correct_language_category_title ~= current_category_title then
-- Error: The current title used is not in the supported format.
return make_error(
string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, non_english_language_sources_strings["TEMPLATE"], correct_language_category_title),
layout, parent_category, args.nocat)
end  
local language_link = get_language_link(language_name, language_code)
local text = string.format(non_english_language_sources_strings["LINE1"], :expandTemplate{title = 'Tlx', args = {non_english_language_sources_strings["TEMPLATE"], language_code}}, language_link)  
table.insert(layout, get_top_section)
table.insert(layout, text)
local see_also_section = get_see_also_section(page_title, language_name, language_code)  
local parent_language_code = get_primary_language_code(language_code)
local parent_language_category
if parent_language_code then
parent_language_category = in_lang_module._in_lang({parent_language_code, ["list-cats"]="yes"})
end  
local bottom = get_bottom_section(, language_name, see_also_section, parent_category, parent_language_category)
return table.concat(layout, "\n\n") .. bottom
end  
-- -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ C S 1 _ S O U R C E S _ C A T E G O R Y > --------------------------  
This function implements .  
local non_english_language_cs1_text_strings = {
["LINE1"] = "This is a tracking category for CS1 citations that use the parameter %s to identify a source in %s. Pages in this category should only be added by CS1 templates and Module:Citation/CS1.",
["PARENT_CATEGORY"] = "", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources"
}