["PARENT_CATEGORY"] = "", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources"
}  
--"This is a tracking category for CS1 citations that use the parameter %s to hold a citation title that uses %s characters and contains the language prefix <code>%s:</code>. Pages in this category should only be added by CS1 templates and Module:Citation/CS1.",
--"",  
-- "This is a tracking category for CS1 citations that use the parameter %s. Pages in this category should only be added by CS1 templates and Module:Citation/CS1.",
-- "to identify a source in %s.",
-- "to hold a citation title that uses %s characters and contains the language prefix <code>%s:</code>.",  
local function non_english_language_cs1_sources_category
local page_title_object = mw.title.getCurrentTitle
local page_title = page_title_object.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 see_also_section = ""
local parameter_doc = :expandTemplate{title = 'para', args = {"language", language_code}}
table.insert(layout, get_top_section)
table.insert(layout, string.format(non_english_language_cs1_text_strings["LINE1"], parameter_doc, language_name, language_name))
local see_also_section = get_see_also_section(page_title, language_name, language_code)
local bottom = get_bottom_section(, language_name, see_also_section, non_english_language_cs1_text_strings["PARENT_CATEGORY"])
return table.concat(layout, "\n\n") .. bottom
end  
-- -------------------------- < T E S T _ C A S E S _ S H A R E D _ C O D E > --------------------------  
local function compare_by_keys2(a, b) -- local function used by table.sort
return a[2] < b[2] -- ascending sort by code
end  
local function compare_by_keys(a, b) -- local function used by table.sort
return a[1] < b[1] -- ascending sort by code
end  
-- Used by testcases_iso_code_to_name
local function get_language_code_table_from_code(args)
local entry = {}
--if args.override_table[args.language_code] then
-- table.insert(entry, args.override_table[args.language_code][1]) -- :gsub(' %b$', '') fails here
--else
table.insert(entry, args.language_code)
-- end
return entry
end  
-- Used by testcases_name_from_tag
local function get_language_code_and_name_table_from_code(args)
local entry = {}
if args.override_table and args.override_table[args.language_code] then
table.insert(entry, args.language_code)
local language_code, _ = args.override_table[args.language_code][1]:gsub(' %b$', '')
table.insert(entry, language_code)
else
table.insert(entry, args.language_code)
table.insert(entry, args.language_table[args.language_code])
end
return entry
end  
-- Used by testcases_category_from_tag
local function get_language_code_and_category_table_from_code(args)
local entry = {}
table.insert(entry, args.language_code)
table.insert(entry, args.test_function({args.language_code}))
return entry
end  
-- Used by testcases_iso_name_to_code and testcases_tag_from_name
local function get_language_name_and_code_table_from_code(args)
local entry = {}
if args.override_table[args.language_code] then
table.insert(entry, args.override_table[args.language_code][1]) -- only the first name when there are multiples
table.insert(entry, args.language_code)
else
table.insert(entry, args.language_names[1]) -- only the first name when there are multiples
table.insert(entry, args.language_code)
end
return entry
end  
local function get_table(table_function, language_table, length, range, iso_number, test_function)
local table_of_language_name_and_code_tables = {}  
local override_table_name = "override"
if iso_number then
override_table_name = "override_" .. iso_number
end
local override_table = require("Module:ISO 639 name/ISO_639_override/sandbox")[override_table_name]  
-- For most ISO 639s.
if range then
for language_code, language_names in pairs(language_table) do
if language_code:find(range) then
table.insert(table_of_language_name_and_code_tables, table_function({
override_table = override_table,
language_code = language_code,
language_names = language_names,
test_function = test_function,
language_table = language_table
}))
end
end
-- For ISO 639-1.
elseif length then
for language_code, language_names in pairs(language_table) do
if language_code:len == 2 then
table.insert(table_of_language_name_and_code_tables, table_function({
override_table = override_table,
language_code = language_code,
language_names = language_names,
test_function = test_function,
language_table = language_table
}))
end
end
-- For general /testcases.
else
for language_code, language_names in pairs(language_table) do
table.insert(table_of_language_name_and_code_tables, table_function({
override_table = override_table,
language_code = language_code,
language_names = language_names,
test_function = test_function,
language_table = language_table
}))
end
end
return table_of_language_name_and_code_tables
end  
local function get_undabbed_table(language_list, length, range)
local undabbed_language_table = {} -- for this test, ISO 639-3 language name disambiguators must be removed; un-dabbed names go here
for language_code, language_names in pairs(language_list) do
-- For most ISO 639s.
if range then
if language_code:find(range) then
undabbed_language_table[language_code] = language_names[1]:gsub(' %b$', '') -- undab and save only the first name; ignore all other names assigned to a code
end
-- For ISO 639-1.
elseif length then
if language_code:len == 2 then
undabbed_language_table[language_code] = language_names[1]:gsub(' %b$', '') -- undab and save only the first name; ignore all other names assigned to a code
end
-- For general /testcases.
else
undabbed_language_table[language_code] = language_names[1]:gsub(' %b$', '')
end
end
return undabbed_language_table
end  
-- -------------------------- < T E S T C A S E S _ C A T E G O R Y _ F R O M _ T A G > --------------------------  
Entry point for the various category_from_tag testcases.  
Build a table of test patterns where each entry in the table is a table with two members:
{"<language_code>", "<category name according to Module:Lang>"}  
- "Expected" column value is the category name according to Module:Lang.
- "Actual" column value is the result of .  
TODO: Currently not working.  
local function testcases_category_from_tag(self, args)
local cat_from_tag_function = require('Module:Lang')._category_from_tag
local language_tables = get_table(get_language_code_and_category_table_from_code, args.language_list, args.length, args.range, args.iso_number, cat_from_tag_function)
table.sort(language_tables, compare_by_keys)  
self:preprocess_equals_preprocess_many(
*, *, '',
language_tables,
{nowiki=false}
end  
-- -------------------------- < T E S T C A S E S _ N A M E _ F R O M _ T A G > --------------------------  
Entry point for the various name_from_tag testcases.  
Build a table of test patterns where each entry in the table is a table with two members:
{"<language_code>", "<language_name>"}  
- "Expected" column value is the <language_name>.
- "Actual" column value is the result of sandbox version .  
local function testcases_name_from_tag(self, args)
local undabbed_language_table = get_undabbed_table(args.language_list, args.length, args.range, nil)
local language_tables = get_table(get_language_code_and_name_table_from_code, undabbed_language_table, args.length, args.range)
table.sort(language_tables, compare_by_keys)  
self:preprocess_equals_preprocess_many(
*, *, '',
language_tables,
{nowiki=false}
end  
-- -------------------------- < T E S T C A S E S _ T A G _ F R O M _ N A M E > --------------------------  
Entry point for the various tag_from_name testcases.  
Build a table of test patterns where each entry in the table is a table with two members:
{"<language_name>", "<language_code>"}  
- "Expected" column value is the <language_code>.