Wikipedia gvwiki https://gv.wikipedia.org/wiki/Ard-ghuillag MediaWiki 1.47.0-wmf.18 first-letter Meanyn Er lheh Resooney Ymmydeyr Resooney ymmydeyr Wikipedia Resooney Wikipedia Coadan Resooney coadan MediaWiki Resooney MediaWiki Clowan Resooney clowan Cooney Resooney cooney Ronney Resooney ronney TimedText TimedText talk Module Module talk Event Event talk Antonia Freya Lydia 0 28071 392779 392762 2026-09-04T17:02:52Z MacTire02 219 Reverted edit by [[Special:Contributions/Jclaxp|Jclaxp]] ([[User talk:Jclaxp|talk]]) to last revision by [[User:MacTire02|MacTire02]] 345831 wikitext text/x-wiki {{WD Kishtey Fys Dooinney | jalloo = Antonia Freya Lydia1.jpg | boayl_ruggyr = [[Essen]], [[Yn Rhine Hwoaie-Westfalen|y Rhine Hwoaie-Westfalen]], y Ghermaan | yrjid = 1.65 m (5' 5") | trimmid = 54 kg (120 lb) | towshan = 33C-23-34 }} She craishteyder as [[cleayneyder meanyn sheshoil]] Germaanagh ee '''Antonia Freya Lydia''' (ruggit er 25 Jerrey Souree 1997). Haink ard-ghoo urree kyndagh rish e coontyssyn er yn eddyr-voggyl, lheid as [[Instagram]], raad t'ee rheynn fotografyn fassan, cullee snaue, as fo-eaddagh ben. She craishteyder cowrey lesh y colught fassan Lounge Underwear. ==Kianglaghyn magh== {{commonscat}} *{{Instagram}} *{{Twitter}} {{Gurneil eaghtyrys}} {{DEFAULTSORT:Lydia, Antonia Freya}} [[Ronney:Ruggyryn 'sy vlein 1997]] [[Ronney:Feallee vio]] [[Ronney:Feallee ass Essen]] [[Ronney:Craishteyderyn bwoirrin Germaanagh]] [[Ronney:Cleayneyderyn meanyn sheshoil]] b15qydmb42pxvah8jh4hlffnrjh5mjx Module:Lang/documentor tool 828 55822 392766 392755 2026-09-04T12:02:16Z MacTire02 219 prowal 392766 Scribunto text/plain require('strict') local p = {} --[[ -------------------------< P R I V A T E _ T A G S >------------------------------------------------------ {{#invoke:Lang/documentor tool|private_tags}} Reads the override{} table in Module:Lang/data and renders a wiki table of private tags and their associated languages ]] local function private_tags (frame) 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, '{| class="wikitable sortable"') 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 >---------------------------------------------- {{#invoke:Lang/documentor tool|lang_xx_settings|template={{ROOTPAGENAME}}}} Reads the content of the template and extracts the parameters from {{#invoke:Lang|...}} for display on the template's documentation page. ]] local function lang_xx_settings(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+|[^}]+}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+|[^}]+}}') then -- if this template uses [[Module:Lang]] params = content:match('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+(|[^}]+)}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+(|[^}]+)}}') -- 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, '{| class="wikitable" style="text-align: right; float: right;"\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 style="color:#d33">Error: template #invoke calls unknown function</span>' end return table.concat({table.concat(out,'\n|-\n! scope="row" | '), '\n|-\n|colspan="2"|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 > -------------------------- {{#invoke:Lang/documentor tool|uses_module|template={{ROOTPAGENAME}}}} Reads the content of the template to determine if this {{lang-xx}} template uses Module:Lang. Returns the index of the substring '{{#invoke|lang|' in the template page content if true; empty string if false. Used in template documentation {{#if:}} parser functions. ]] local function uses_module(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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 return content:find('{{%s*#invoke:[Ll]ang%s*|') or '' -- return index or empty string end --[[ -------------------------- < S H A R E D _ C O D E > -------------------------- - Tables: -- LANGUAGE_CATEGORIES -- error_messages -- strings - Functions: -- make_error(message, layout, parent_category, nocat) -- get_language_link(language_name, language_code) -- get_see_also_section(page_title, language_name, language_code) -- get_hidden_category_template(frame) -- get_top_section(frame) -- get_bottom_section(frame, language_name, see_also_section, parent_category) ]] local LANGUAGE_CATEGORIES = { ["LANGUAGES_SOURCES"] = "Articles with %s-language sources (%s)", ["LANGUAGES_COLLECTIVE_SOURCES"] = "Articles with %s-collective sources (%s)", ["CS1"] = "CS1 %s-language sources (%s)", ["CS1_SCRIPT"] = "CS1 uses %s-language script (%s)", ["LANGUAGE_TEXT"] = "Articles containing %s-language text", ["LANGUAGES_COLLECTIVE_TEXT"] = "Articles with text in %s", ["ENGLISH"] = "Articles containing explicitly cited %s-language text", ["IPA"] = "Pages with %s IPA" } local error_assistance = " Please see [[Template talk:Lang]] for assistance." local error_messages = { ["ASSISTANCE"] = "Please see [[Template talk:Lang]] for assistance.", ["INCORRECT_CATEGORY_TITLE"] = "[[:%s]] is not the category being populated by the %s template. The correct category is located at: [[:%s]].", ["NO_CATEGORY_TITLE_FOUND"] = "No language category found for '''%s.'''" .. error_assistance, ["NOT_VALID_CATEGORY_FORMAT"] = "'''%s''' is not a a valid category title." .. error_assistance, ["NOT_VALID_LANGUAGE_CODE"] = "[[%s]] is not a valid ISO 639 or IETF language name." .. error_assistance, } local strings = { ["ERROR_CATEGORY"] = "[[Category:Lang and lang-xx template errors]]", ["ERROR_SPAN"] = '<span style="font-size: 100%%; font-style: normal;" class="error">Error: %s </span>', ["PURGE_DIV"] = '<div style="font-size: x-small;">%s</div>', ["SEE_ALSO"] = "\n==See also==", ["SEE_ALSO_ITEM"] = "* [[:%s]]", } --[[ -------------------------- < M A K E _ E R R O R > -------------------------- Create an error message. Does not place page in error category if args.nocat is used. Does not categorize in parent cateogory if used in category namespace (usually for /testcases). ]] local function make_error(message, layout, parent_category, nocat) table.insert(layout, string.format(strings["ERROR_SPAN"], message)) if not nocat then table.insert(layout, strings["ERROR_CATEGORY"]) end if mw.title.getCurrentTitle().nsText == "Category" then table.insert(layout, parent_category) end return table.concat(layout) end --[[ -------------------------- < G E T _ L A N G U A G E _ L I N K > -------------------------- Generates a language link for the correct style. Collective languages use the name_from_tag value, while other languages use a display name of "x-language". ]] local function get_language_link(language_name, language_code) local lang_module = require('Module:Lang') -- Is a language collective? if language_name:find('languages') then return lang_module.name_from_tag({language_code, link = "yes"}) else return lang_module.name_from_tag({language_code, link = "yes", label = lang_module.name_from_tag({language_code}) .. "-language"}) end end --[[ -------------------------- < G E T _ P R I M A R Y _ L A N G U A G E _ C O D E > -------------------------- Returns the primary language for sub-langage variants. ]] local function get_primary_language_code(language_code) -- If no hyphen exists, return nil (for cases like "el") if not language_code:find("-") then return nil end -- Match everything before the first hyphen, but only if a hyphen exists if language_code:match("^-") then return nil -- If the code starts with a hyphen, return nil end -- Look for the first part before any hyphen local primary_code = language_code:match("^[^-]+") return primary_code end --[[ -------------------------- < G E T _ S E E _ A L S O _ S E C T I O N > -------------------------- Generates a consistent style See also section for {{Category articles containing non-English-language text}} and {{Non-English-language source category}}. If {{CS1 language sources}} is converted, it should also use it. ]] local function get_see_also_section(page_title, language_name, language_code) local see_also_section = {} for _, category_name in pairs(LANGUAGE_CATEGORIES) do local category = mw.title.new(string.format(category_name, language_name, language_code), 14) if category and page_title ~= category.text and category.exists then table.insert(see_also_section, string.format(strings["SEE_ALSO_ITEM"], category.prefixedText)) end end table.sort(see_also_section) table.insert(see_also_section, 1, strings["SEE_ALSO"]) if table.getn(see_also_section) == 1 then return "" else return table.concat(see_also_section, "\n") end end --[[ -------------------------- < G E T _ H I D D E N _ C A T E G O R Y _ T E M P L A T E > -------------------------- Generates the Template:Hidden category template. This function is separate from the get_top_section() function as this should be used in both error categories and valid categories. ]] local function get_hidden_category_template(frame) return frame:expandTemplate{title = 'Hidden category'} end --[[ -------------------------- < G E T _ T O P _ S E C T I O N > -------------------------- Generates a consistent top maintenance template section which consists of: -- Template:Possibly empty category -- Template:Purge ]] local function get_top_section(frame) local top_section = {} if mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "all") == 0 then table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category'}) else table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category', args = {hidden=true}}) end local purge_module = require('Module:Purge') table.insert(top_section, string.format(strings["PURGE_DIV"], purge_module._main({"Purge page cache"}))) return table.concat(top_section, "\n\n") end --[[ -------------------------- < G E T _ B O T T O M _ S E C T I O N > -------------------------- Generates a consistent non-text section which consists of: -- Template:Automatic category TOC -- A see also section -- {{DEFAULTSORT}} -- Categorization in parent category ]] local function get_bottom_section(frame, language_name, see_also_section, parent_category, parent_language_category) local bottom_section = {} table.insert(bottom_section, frame:expandTemplate{title = 'Automatic category TOC'}) table.insert(bottom_section, see_also_section) if mw.title.getCurrentTitle().nsText == "Category" then table.insert(bottom_section, frame:preprocess{text = "{{DEFAULTSORT:" .. language_name .. "}}"}) if parent_language_category then table.insert(bottom_section, "[[" .. parent_language_category .. "]]") end table.insert(bottom_section, parent_category) end return table.concat(bottom_section, "\n\n\n") end --[[ -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ T E X T _ C A T E G O R Y > -------------------------- {{#invoke:Lang/documentor tool|non_manx_language_text_category}} This function implements {{Non-Manx-language text category}}. ]] local non_english_language_text_strings = { ["LINE1"] = "This category contains articles with %s%s text. The primary purpose of these categories is to facilitate manual or automated checking of text in other languages.", ["LINE2"] = "This category should only be added with the %s family of templates, never explicitly.", ["LINE3"] = 'For example %s, which wraps the text with %s. Also available is %s which displays as %s.', ["LINE3_SYNTAXHIGHLIGHT"] = "<span lang=\"%s\">", ["IN_SCRIPT"] = " (in %s)", ["EXAMPLE_DEFAULT_TEXT"] = "text in %s language here", ["PARENT_CATEGORY"] = "[[Ronney:Artyn lesh teks neu-Ghaelgagh]]", ["TEMPLATE"] = "Lang", ["TEMPLATE2"] = "Langx", } local function non_manx_language_text_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- args.test is used for /testcases if page.text == 'Lang and lang-xx template errors' then return '' end -- args.test is used for /testcases if args.test then page = mw.title.new(args.test) end -- Naming style: Articles with text from the Berber languages collective local page_title_modified = page.text local split_title = "([^,]+)%%s([^,]*)" local part1 = "" local part2 = "" if page_title_modified:find('Articles with text in') then -- Naming style: Category:Articles with text from Afro-Asiatic languages (as currently implemented in Module:lang) part1, part2 = LANGUAGE_CATEGORIES["LANGUAGES_COLLECTIVE_TEXT"]:match(split_title) elseif page_title_modified:find('explicitly cited') then part1, part2 = LANGUAGE_CATEGORIES["ENGLISH"]:match(split_title) else -- Naming style: Category:Articles containing French-language text part1, part2 = LANGUAGE_CATEGORIES["LANGUAGE_TEXT"]:match(split_title) end page_title_modified = page_title_modified:gsub(part1, "") page_title_modified = page_title_modified:gsub(part2, "") local language_name = page_title_modified local layout = {} table.insert(layout, get_hidden_category_template(frame)) local parent_category = non_english_language_text_strings["PARENT_CATEGORY"] if language_name == page.text then -- Error: Category title format not supported. return make_error(string.format(error_messages["NOT_VALID_CATEGORY_FORMAT"], page.text), layout, parent_category, args.nocat) end local lang_module = require('Module:Lang') local language_code = lang_module._tag_from_name({language_name}) if language_code:find('[Ee]rror') then -- Error: Language code not found in database. return make_error(string.format(error_messages["NOT_VALID_LANGUAGE_CODE"], language_name), layout, parent_category, args.nocat) end local correct_language_category_title = lang_module._category_from_tag({language_code}) if correct_language_category_title:find('[Ee]rror') 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 current_category_title ~= correct_language_category_title then -- Error: The current title used is not in the supported format. TODO: can this still be reached? return make_error( string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, frame:expandTemplate{title = 'Tlx', args = {non_english_language_text_strings["TEMPLATE"]}}, correct_language_category_title), layout, parent_category, args.nocat) end table.insert(layout, get_top_section(frame)) local script_text = "" if args.script then script_text = string.format(non_english_language_text_strings["IN_SCRIPT"], args.script) end local language_link = get_language_link(language_name, language_code) table.insert(layout, string.format(non_english_language_text_strings["LINE1"], language_link, script_text)) local lang_template = frame:expandTemplate{title = 'Tl', args = {non_english_language_text_strings["TEMPLATE"]}} 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 = frame: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 = frame:expandTemplate{title = "Tlx", args = {non_english_language_text_strings["TEMPLATE2"], language_code, example_text}} local langx_template_code = frame: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 = frame: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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_sources_category}} This function implements {{Non-English-language sources category}}. ]] local non_english_language_sources_strings = { ["LINE1"] = "This is a tracking category for articles that use %s to identify %s sources.", ["PARENT_CATEGORY"] = "[[Category:Articles with non-English-language sources]]", ["TEMPLATE"] = "In lang", } local function non_english_language_sources_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- 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(frame)) 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, frame:expandTemplate{title = 'Tlx', args = {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"], frame:expandTemplate{title = 'Tlx', args = {non_english_language_sources_strings["TEMPLATE"], language_code}}, language_link) table.insert(layout, get_top_section(frame)) 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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_cs1_sources_category}} This function implements {{Non-English-language CS1 sources category}}. ]] local non_english_language_cs1_text_strings = { ["LINE1"] = "This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s to identify a source in [[%s language|%s]]. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].", ["PARENT_CATEGORY"] = "[[Category:CS1 foreign language sources]]", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources" } --"This is a tracking category for [[WP:CS1|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]].", --"[[Category:CS1 uses foreign language script]]", -- "This is a tracking category for [[WP:CS1|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 language|%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(frame) 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(frame)) local see_also_section = "" local parameter_doc = frame:expandTemplate{title = 'para', args = {"language", language_code}} table.insert(layout, get_top_section(frame)) 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(frame, 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 {{#invoke:Lang/sandbox|category_from_tag|<language_code>}}. 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( '{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '', 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 {{#invoke:Lang/sandbox|name_from_tag|<language_code>}}. ]] 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( '{{#invoke:Lang/sandbox|name_from_tag|', '}}', '', '', 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>. - "Actual" column value is the result of sandbox version {{#invoke:Lang/sandbox|tag_from_name|<language_name>}}. TODO: Currently not working. ]] local function testcases_tag_from_name(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) local ordered_table = {} table.sort(unordered_table) for _, key in ipairs(unordered_table) do table.insert(ordered_table, {key, reverse_table[key]}) end self:preprocess_equals_preprocess_many( '{{#invoke:Lang/sandbox|tag_from_name|', '}}', '', '', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ C O D E _ T O _ N A M E > -------------------------- Entry point for the various iso_code_to_name testcases. Build a table of test patterns where each entry in the table is a table with one member: {"<language_code>"} - "Expected" column value is the result of the live version of {{#invoke:ISO 639 name|iso_639_name_to_code|<language_code>}}. - "Actual" column value is the result of sandbox version {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_code>}}. ]] local function testcases_iso_code_to_name(self, args) local language_tables = get_table(get_language_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_code_to_name|link=yes|', '}}', '{{#invoke:ISO 639 name|iso_639_code_to_name|link=yes|', '}}', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ N A M E _ T O _ C O D E > -------------------------- Entry point for the various iso_name_to_code 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>. - "Actual" column is value the result of {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_name>}}. ]] local function testcases_iso_name_to_code(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|2=' .. args.iso_number .. "|", '}}', '', '', language_tables, {nowiki=false} ) end --[[--------------------------< S E E _ A L S O >-------------------------------------------------------------- adds items to the list of items in §See also section of Template:Lang-x/doc; Evaluates single positional parameter which is a comma-separated list of items including list markup. {{#invoke:Lang/documentor tool|see_also|*{{tl|Lang-tt-Cyrl}}, *{{tl|Lang-tt-Latn}}, *{{tl|Lang-tt-Arab}}}} ]] local function see_also (frame) if nil == frame.args[1] or '' == frame.args[1] then -- if empty, ... return -- ... return nothing end return frame:preprocess (frame.args[1]:gsub ('%s*,%s', '\n')) -- preprocess so any templates are rendered before saving and done end --[[ -------------------------< E X P O R T E D _ F U N C T I O N S > ----------------------------------------- ]] return { lang_xx_settings = lang_xx_settings, uses_module = uses_module, see_also = see_also, non_manx_language_text_category = non_manx_language_text_category, non_english_language_sources_category = non_english_language_sources_category, non_english_language_cs1_sources_category = non_english_language_cs1_sources_category, private_tags = private_tags, -- Module:Lang testcases testcases_category_from_tag = testcases_category_from_tag, testcases_name_from_tag = testcases_name_from_tag, testcases_tag_from_name = testcases_tag_from_name, -- Module:ISO 639 name testcases testcases_iso_code_to_name = testcases_iso_code_to_name, testcases_iso_name_to_code = testcases_iso_name_to_code, } qchebgpfsukzcmt10m35kik9awrl2lp 392767 392766 2026-09-04T12:06:02Z MacTire02 219 ++ 392767 Scribunto text/plain require('strict') local p = {} --[[ -------------------------< P R I V A T E _ T A G S >------------------------------------------------------ {{#invoke:Lang/documentor tool|private_tags}} Reads the override{} table in Module:Lang/data and renders a wiki table of private tags and their associated languages ]] local function private_tags (frame) 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, '{| class="wikitable sortable"') 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 >---------------------------------------------- {{#invoke:Lang/documentor tool|lang_xx_settings|template={{ROOTPAGENAME}}}} Reads the content of the template and extracts the parameters from {{#invoke:Lang|...}} for display on the template's documentation page. ]] local function lang_xx_settings(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+|[^}]+}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+|[^}]+}}') then -- if this template uses [[Module:Lang]] params = content:match('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+(|[^}]+)}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+(|[^}]+)}}') -- 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, '{| class="wikitable" style="text-align: right; float: right;"\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 style="color:#d33">Error: template #invoke calls unknown function</span>' end return table.concat({table.concat(out,'\n|-\n! scope="row" | '), '\n|-\n|colspan="2"|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 > -------------------------- {{#invoke:Lang/documentor tool|uses_module|template={{ROOTPAGENAME}}}} Reads the content of the template to determine if this {{lang-xx}} template uses Module:Lang. Returns the index of the substring '{{#invoke|lang|' in the template page content if true; empty string if false. Used in template documentation {{#if:}} parser functions. ]] local function uses_module(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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 return content:find('{{%s*#invoke:[Ll]ang%s*|') or '' -- return index or empty string end --[[ -------------------------- < S H A R E D _ C O D E > -------------------------- - Tables: -- LANGUAGE_CATEGORIES -- error_messages -- strings - Functions: -- make_error(message, layout, parent_category, nocat) -- get_language_link(language_name, language_code) -- get_see_also_section(page_title, language_name, language_code) -- get_hidden_category_template(frame) -- get_top_section(frame) -- get_bottom_section(frame, language_name, see_also_section, parent_category) ]] local LANGUAGE_CATEGORIES = { ["LANGUAGES_SOURCES"] = "Artyn as geillyn ayns %s (%s)", ["LANGUAGES_COLLECTIVE_SOURCES"] = "Artyn as geillyn ayns %s (%s)", ["CS1"] = "Geillyn CS1 ayns %s (%s)", ["CS1_SCRIPT"] = "CS1 uses %s-language script (%s)", ["LANGUAGE_TEXT"] = "Artyn lesh teks ayns %s", ["LANGUAGES_COLLECTIVE_TEXT"] = "Artyn lesh teks ayns %s", ["ENGLISH"] = "Articles containing explicitly cited %s-language text", ["IPA"] = "Pages with %s IPA" } local error_assistance = " Please see [[Template talk:Lang]] for assistance." local error_messages = { ["ASSISTANCE"] = "Please see [[Template talk:Lang]] for assistance.", ["INCORRECT_CATEGORY_TITLE"] = "[[:%s]] is not the category being populated by the %s template. The correct category is located at: [[:%s]].", ["NO_CATEGORY_TITLE_FOUND"] = "No language category found for '''%s.'''" .. error_assistance, ["NOT_VALID_CATEGORY_FORMAT"] = "'''%s''' is not a a valid category title." .. error_assistance, ["NOT_VALID_LANGUAGE_CODE"] = "[[%s]] is not a valid ISO 639 or IETF language name." .. error_assistance, } local strings = { ["ERROR_CATEGORY"] = "[[Category:Lang and lang-xx template errors]]", ["ERROR_SPAN"] = '<span style="font-size: 100%%; font-style: normal;" class="error">Error: %s </span>', ["PURGE_DIV"] = '<div style="font-size: x-small;">%s</div>', ["SEE_ALSO"] = "\n==See also==", ["SEE_ALSO_ITEM"] = "* [[:%s]]", } --[[ -------------------------- < M A K E _ E R R O R > -------------------------- Create an error message. Does not place page in error category if args.nocat is used. Does not categorize in parent cateogory if used in category namespace (usually for /testcases). ]] local function make_error(message, layout, parent_category, nocat) table.insert(layout, string.format(strings["ERROR_SPAN"], message)) if not nocat then table.insert(layout, strings["ERROR_CATEGORY"]) end if mw.title.getCurrentTitle().nsText == "Category" then table.insert(layout, parent_category) end return table.concat(layout) end --[[ -------------------------- < G E T _ L A N G U A G E _ L I N K > -------------------------- Generates a language link for the correct style. Collective languages use the name_from_tag value, while other languages use a display name of "x-language". ]] local function get_language_link(language_name, language_code) local lang_module = require('Module:Lang') -- Is a language collective? if language_name:find('languages') then return lang_module.name_from_tag({language_code, link = "yes"}) else return lang_module.name_from_tag({language_code, link = "yes", label = lang_module.name_from_tag({language_code}) .. "-language"}) end end --[[ -------------------------- < G E T _ P R I M A R Y _ L A N G U A G E _ C O D E > -------------------------- Returns the primary language for sub-langage variants. ]] local function get_primary_language_code(language_code) -- If no hyphen exists, return nil (for cases like "el") if not language_code:find("-") then return nil end -- Match everything before the first hyphen, but only if a hyphen exists if language_code:match("^-") then return nil -- If the code starts with a hyphen, return nil end -- Look for the first part before any hyphen local primary_code = language_code:match("^[^-]+") return primary_code end --[[ -------------------------- < G E T _ S E E _ A L S O _ S E C T I O N > -------------------------- Generates a consistent style See also section for {{Category articles containing non-English-language text}} and {{Non-English-language source category}}. If {{CS1 language sources}} is converted, it should also use it. ]] local function get_see_also_section(page_title, language_name, language_code) local see_also_section = {} for _, category_name in pairs(LANGUAGE_CATEGORIES) do local category = mw.title.new(string.format(category_name, language_name, language_code), 14) if category and page_title ~= category.text and category.exists then table.insert(see_also_section, string.format(strings["SEE_ALSO_ITEM"], category.prefixedText)) end end table.sort(see_also_section) table.insert(see_also_section, 1, strings["SEE_ALSO"]) if table.getn(see_also_section) == 1 then return "" else return table.concat(see_also_section, "\n") end end --[[ -------------------------- < G E T _ H I D D E N _ C A T E G O R Y _ T E M P L A T E > -------------------------- Generates the Template:Hidden category template. This function is separate from the get_top_section() function as this should be used in both error categories and valid categories. ]] local function get_hidden_category_template(frame) return frame:expandTemplate{title = 'Hidden category'} end --[[ -------------------------- < G E T _ T O P _ S E C T I O N > -------------------------- Generates a consistent top maintenance template section which consists of: -- Template:Possibly empty category -- Template:Purge ]] local function get_top_section(frame) local top_section = {} if mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "all") == 0 then table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category'}) else table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category', args = {hidden=true}}) end local purge_module = require('Module:Purge') table.insert(top_section, string.format(strings["PURGE_DIV"], purge_module._main({"Purge page cache"}))) return table.concat(top_section, "\n\n") end --[[ -------------------------- < G E T _ B O T T O M _ S E C T I O N > -------------------------- Generates a consistent non-text section which consists of: -- Template:Automatic category TOC -- A see also section -- {{DEFAULTSORT}} -- Categorization in parent category ]] local function get_bottom_section(frame, language_name, see_also_section, parent_category, parent_language_category) local bottom_section = {} table.insert(bottom_section, frame:expandTemplate{title = 'Automatic category TOC'}) table.insert(bottom_section, see_also_section) if mw.title.getCurrentTitle().nsText == "Category" then table.insert(bottom_section, frame:preprocess{text = "{{DEFAULTSORT:" .. language_name .. "}}"}) if parent_language_category then table.insert(bottom_section, "[[" .. parent_language_category .. "]]") end table.insert(bottom_section, parent_category) end return table.concat(bottom_section, "\n\n\n") end --[[ -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ T E X T _ C A T E G O R Y > -------------------------- {{#invoke:Lang/documentor tool|non_manx_language_text_category}} This function implements {{Non-Manx-language text category}}. ]] local non_english_language_text_strings = { ["LINE1"] = "This category contains articles with %s%s text. The primary purpose of these categories is to facilitate manual or automated checking of text in other languages.", ["LINE2"] = "This category should only be added with the %s family of templates, never explicitly.", ["LINE3"] = 'For example %s, which wraps the text with %s. Also available is %s which displays as %s.', ["LINE3_SYNTAXHIGHLIGHT"] = "<span lang=\"%s\">", ["IN_SCRIPT"] = " (in %s)", ["EXAMPLE_DEFAULT_TEXT"] = "text in %s language here", ["PARENT_CATEGORY"] = "[[Ronney:Artyn lesh teks neu-Ghaelgagh]]", ["TEMPLATE"] = "Lang", ["TEMPLATE2"] = "Langx", } local function non_manx_language_text_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- args.test is used for /testcases if page.text == 'Lang and lang-xx template errors' then return '' end -- args.test is used for /testcases if args.test then page = mw.title.new(args.test) end -- Naming style: Articles with text from the Berber languages collective local page_title_modified = page.text local split_title = "([^,]+)%%s([^,]*)" local part1 = "" local part2 = "" if page_title_modified:find('Articles with text in') then -- Naming style: Category:Articles with text from Afro-Asiatic languages (as currently implemented in Module:lang) part1, part2 = LANGUAGE_CATEGORIES["LANGUAGES_COLLECTIVE_TEXT"]:match(split_title) elseif page_title_modified:find('explicitly cited') then part1, part2 = LANGUAGE_CATEGORIES["ENGLISH"]:match(split_title) else -- Naming style: Category:Articles containing French-language text part1, part2 = LANGUAGE_CATEGORIES["LANGUAGE_TEXT"]:match(split_title) end page_title_modified = page_title_modified:gsub(part1, "") page_title_modified = page_title_modified:gsub(part2, "") local language_name = page_title_modified local layout = {} table.insert(layout, get_hidden_category_template(frame)) local parent_category = non_english_language_text_strings["PARENT_CATEGORY"] if language_name == page.text then -- Error: Category title format not supported. return make_error(string.format(error_messages["NOT_VALID_CATEGORY_FORMAT"], page.text), layout, parent_category, args.nocat) end local lang_module = require('Module:Lang') local language_code = lang_module._tag_from_name({language_name}) if language_code:find('[Ee]rror') then -- Error: Language code not found in database. return make_error(string.format(error_messages["NOT_VALID_LANGUAGE_CODE"], language_name), layout, parent_category, args.nocat) end local correct_language_category_title = lang_module._category_from_tag({language_code}) if correct_language_category_title:find('[Ee]rror') 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 current_category_title ~= correct_language_category_title then -- Error: The current title used is not in the supported format. TODO: can this still be reached? return make_error( string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, frame:expandTemplate{title = 'Tlx', args = {non_english_language_text_strings["TEMPLATE"]}}, correct_language_category_title), layout, parent_category, args.nocat) end table.insert(layout, get_top_section(frame)) local script_text = "" if args.script then script_text = string.format(non_english_language_text_strings["IN_SCRIPT"], args.script) end local language_link = get_language_link(language_name, language_code) table.insert(layout, string.format(non_english_language_text_strings["LINE1"], language_link, script_text)) local lang_template = frame:expandTemplate{title = 'Tl', args = {non_english_language_text_strings["TEMPLATE"]}} 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 = frame: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 = frame:expandTemplate{title = "Tlx", args = {non_english_language_text_strings["TEMPLATE2"], language_code, example_text}} local langx_template_code = frame: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 = frame: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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_sources_category}} This function implements {{Non-English-language sources category}}. ]] local non_english_language_sources_strings = { ["LINE1"] = "This is a tracking category for articles that use %s to identify %s sources.", ["PARENT_CATEGORY"] = "[[Category:Articles with non-English-language sources]]", ["TEMPLATE"] = "In lang", } local function non_english_language_sources_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- 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(frame)) 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, frame:expandTemplate{title = 'Tlx', args = {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"], frame:expandTemplate{title = 'Tlx', args = {non_english_language_sources_strings["TEMPLATE"], language_code}}, language_link) table.insert(layout, get_top_section(frame)) 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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_cs1_sources_category}} This function implements {{Non-English-language CS1 sources category}}. ]] local non_english_language_cs1_text_strings = { ["LINE1"] = "This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s to identify a source in [[%s language|%s]]. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].", ["PARENT_CATEGORY"] = "[[Category:CS1 foreign language sources]]", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources" } --"This is a tracking category for [[WP:CS1|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]].", --"[[Category:CS1 uses foreign language script]]", -- "This is a tracking category for [[WP:CS1|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 language|%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(frame) 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(frame)) local see_also_section = "" local parameter_doc = frame:expandTemplate{title = 'para', args = {"language", language_code}} table.insert(layout, get_top_section(frame)) 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(frame, 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 {{#invoke:Lang/sandbox|category_from_tag|<language_code>}}. 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( '{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '', 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 {{#invoke:Lang/sandbox|name_from_tag|<language_code>}}. ]] 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( '{{#invoke:Lang/sandbox|name_from_tag|', '}}', '', '', 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>. - "Actual" column value is the result of sandbox version {{#invoke:Lang/sandbox|tag_from_name|<language_name>}}. TODO: Currently not working. ]] local function testcases_tag_from_name(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) local ordered_table = {} table.sort(unordered_table) for _, key in ipairs(unordered_table) do table.insert(ordered_table, {key, reverse_table[key]}) end self:preprocess_equals_preprocess_many( '{{#invoke:Lang/sandbox|tag_from_name|', '}}', '', '', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ C O D E _ T O _ N A M E > -------------------------- Entry point for the various iso_code_to_name testcases. Build a table of test patterns where each entry in the table is a table with one member: {"<language_code>"} - "Expected" column value is the result of the live version of {{#invoke:ISO 639 name|iso_639_name_to_code|<language_code>}}. - "Actual" column value is the result of sandbox version {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_code>}}. ]] local function testcases_iso_code_to_name(self, args) local language_tables = get_table(get_language_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_code_to_name|link=yes|', '}}', '{{#invoke:ISO 639 name|iso_639_code_to_name|link=yes|', '}}', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ N A M E _ T O _ C O D E > -------------------------- Entry point for the various iso_name_to_code 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>. - "Actual" column is value the result of {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_name>}}. ]] local function testcases_iso_name_to_code(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|2=' .. args.iso_number .. "|", '}}', '', '', language_tables, {nowiki=false} ) end --[[--------------------------< S E E _ A L S O >-------------------------------------------------------------- adds items to the list of items in §See also section of Template:Lang-x/doc; Evaluates single positional parameter which is a comma-separated list of items including list markup. {{#invoke:Lang/documentor tool|see_also|*{{tl|Lang-tt-Cyrl}}, *{{tl|Lang-tt-Latn}}, *{{tl|Lang-tt-Arab}}}} ]] local function see_also (frame) if nil == frame.args[1] or '' == frame.args[1] then -- if empty, ... return -- ... return nothing end return frame:preprocess (frame.args[1]:gsub ('%s*,%s', '\n')) -- preprocess so any templates are rendered before saving and done end --[[ -------------------------< E X P O R T E D _ F U N C T I O N S > ----------------------------------------- ]] return { lang_xx_settings = lang_xx_settings, uses_module = uses_module, see_also = see_also, non_manx_language_text_category = non_manx_language_text_category, non_english_language_sources_category = non_english_language_sources_category, non_english_language_cs1_sources_category = non_english_language_cs1_sources_category, private_tags = private_tags, -- Module:Lang testcases testcases_category_from_tag = testcases_category_from_tag, testcases_name_from_tag = testcases_name_from_tag, testcases_tag_from_name = testcases_tag_from_name, -- Module:ISO 639 name testcases testcases_iso_code_to_name = testcases_iso_code_to_name, testcases_iso_name_to_code = testcases_iso_name_to_code, } lbidmxjufk9r7lx4ffvmst0229bln2f 392769 392767 2026-09-04T12:21:18Z MacTire02 219 prowal dy gheddyn magh y marranys - shallidagh 392769 Scribunto text/plain require('strict') local p = {} --[[ -------------------------< P R I V A T E _ T A G S >------------------------------------------------------ {{#invoke:Lang/documentor tool|private_tags}} Reads the override{} table in Module:Lang/data and renders a wiki table of private tags and their associated languages ]] local function private_tags (frame) 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, '{| class="wikitable sortable"') 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 >---------------------------------------------- {{#invoke:Lang/documentor tool|lang_xx_settings|template={{ROOTPAGENAME}}}} Reads the content of the template and extracts the parameters from {{#invoke:Lang|...}} for display on the template's documentation page. ]] local function lang_xx_settings(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+|[^}]+}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+|[^}]+}}') then -- if this template uses [[Module:Lang]] params = content:match('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+(|[^}]+)}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+(|[^}]+)}}') -- 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, '{| class="wikitable" style="text-align: right; float: right;"\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 style="color:#d33">Error: template #invoke calls unknown function</span>' end return table.concat({table.concat(out,'\n|-\n! scope="row" | '), '\n|-\n|colspan="2"|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 > -------------------------- {{#invoke:Lang/documentor tool|uses_module|template={{ROOTPAGENAME}}}} Reads the content of the template to determine if this {{lang-xx}} template uses Module:Lang. Returns the index of the substring '{{#invoke|lang|' in the template page content if true; empty string if false. Used in template documentation {{#if:}} parser functions. ]] local function uses_module(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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 return content:find('{{%s*#invoke:[Ll]ang%s*|') or '' -- return index or empty string end --[[ -------------------------- < S H A R E D _ C O D E > -------------------------- - Tables: -- LANGUAGE_CATEGORIES -- error_messages -- strings - Functions: -- make_error(message, layout, parent_category, nocat) -- get_language_link(language_name, language_code) -- get_see_also_section(page_title, language_name, language_code) -- get_hidden_category_template(frame) -- get_top_section(frame) -- get_bottom_section(frame, language_name, see_also_section, parent_category) ]] local LANGUAGE_CATEGORIES = { ["LANGUAGES_SOURCES"] = "Artyn as geillyn ayns %s (%s)", ["LANGUAGES_COLLECTIVE_SOURCES"] = "Artyn as geillyn ayns %s (%s)", ["CS1"] = "Geillyn CS1 ayns %s (%s)", ["CS1_SCRIPT"] = "CS1 uses %s-language script (%s)", ["LANGUAGE_TEXT"] = "Artyn lesh teks ayns %s", ["LANGUAGES_COLLECTIVE_TEXT"] = "Artyn lesh teks ayns %s", ["ENGLISH"] = "Articles containing explicitly cited %s-language text", ["IPA"] = "Pages with %s IPA" } local error_assistance = " Please see [[Template talk:Lang]] for assistance." local error_messages = { ["ASSISTANCE"] = "Please see [[Template talk:Lang]] for assistance.", ["INCORRECT_CATEGORY_TITLE"] = "[[:%s]] is not the category being populated by the %s template. The correct category is located at: [[:%s]].", ["NO_CATEGORY_TITLE_FOUND"] = "No language category found for '''%s.'''" .. error_assistance, ["NOT_VALID_CATEGORY_FORMAT"] = "'''%s''' is not a a valid category title." .. error_assistance, ["NOT_VALID_LANGUAGE_CODE"] = "[[%s]] is not a valid ISO 639 or IETF language name." .. error_assistance, } local strings = { ["ERROR_CATEGORY"] = "[[Category:Lang and lang-xx template errors]]", ["ERROR_SPAN"] = '<span style="font-size: 100%%; font-style: normal;" class="error">Error: %s </span>', ["PURGE_DIV"] = '<div style="font-size: x-small;">%s</div>', ["SEE_ALSO"] = "\n==See also==", ["SEE_ALSO_ITEM"] = "* [[:%s]]", } --[[ -------------------------- < M A K E _ E R R O R > -------------------------- Create an error message. Does not place page in error category if args.nocat is used. Does not categorize in parent cateogory if used in category namespace (usually for /testcases). ]] local function make_error(message, layout, parent_category, nocat) table.insert(layout, string.format(strings["ERROR_SPAN"], message)) if not nocat then table.insert(layout, strings["ERROR_CATEGORY"]) end if mw.title.getCurrentTitle().nsText == "Category" then table.insert(layout, parent_category) end return table.concat(layout) end --[[ -------------------------- < G E T _ L A N G U A G E _ L I N K > -------------------------- Generates a language link for the correct style. Collective languages use the name_from_tag value, while other languages use a display name of "x-language". ]] local function get_language_link(language_name, language_code) local lang_module = require('Module:Lang') -- Is a language collective? if language_name:find('languages') then return lang_module.name_from_tag({language_code, link = "yes"}) else return lang_module.name_from_tag({language_code, link = "yes", label = lang_module.name_from_tag({language_code}) .. "-language"}) end end --[[ -------------------------- < G E T _ P R I M A R Y _ L A N G U A G E _ C O D E > -------------------------- Returns the primary language for sub-langage variants. ]] local function get_primary_language_code(language_code) -- If no hyphen exists, return nil (for cases like "el") if not language_code:find("-") then return nil end -- Match everything before the first hyphen, but only if a hyphen exists if language_code:match("^-") then return nil -- If the code starts with a hyphen, return nil end -- Look for the first part before any hyphen local primary_code = language_code:match("^[^-]+") return primary_code end --[[ -------------------------- < G E T _ S E E _ A L S O _ S E C T I O N > -------------------------- Generates a consistent style See also section for {{Category articles containing non-English-language text}} and {{Non-English-language source category}}. If {{CS1 language sources}} is converted, it should also use it. ]] local function get_see_also_section(page_title, language_name, language_code) local see_also_section = {} for _, category_name in pairs(LANGUAGE_CATEGORIES) do local category = mw.title.new(string.format(category_name, language_name, language_code), 14) if category and page_title ~= category.text and category.exists then table.insert(see_also_section, string.format(strings["SEE_ALSO_ITEM"], category.prefixedText)) end end table.sort(see_also_section) table.insert(see_also_section, 1, strings["SEE_ALSO"]) if table.getn(see_also_section) == 1 then return "" else return table.concat(see_also_section, "\n") end end --[[ -------------------------- < G E T _ H I D D E N _ C A T E G O R Y _ T E M P L A T E > -------------------------- Generates the Template:Hidden category template. This function is separate from the get_top_section() function as this should be used in both error categories and valid categories. ]] local function get_hidden_category_template(frame) return frame:expandTemplate{title = 'Hidden category'} end --[[ -------------------------- < G E T _ T O P _ S E C T I O N > -------------------------- Generates a consistent top maintenance template section which consists of: -- Template:Possibly empty category -- Template:Purge ]] local function get_top_section(frame) local top_section = {} if mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "all") == 0 then table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category'}) else table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category', args = {hidden=true}}) end local purge_module = require('Module:Purge') table.insert(top_section, string.format(strings["PURGE_DIV"], purge_module._main({"Purge page cache"}))) return table.concat(top_section, "\n\n") end --[[ -------------------------- < G E T _ B O T T O M _ S E C T I O N > -------------------------- Generates a consistent non-text section which consists of: -- Template:Automatic category TOC -- A see also section -- {{DEFAULTSORT}} -- Categorization in parent category ]] local function get_bottom_section(frame, language_name, see_also_section, parent_category, parent_language_category) local bottom_section = {} table.insert(bottom_section, frame:expandTemplate{title = 'Automatic category TOC'}) table.insert(bottom_section, see_also_section) if mw.title.getCurrentTitle().nsText == "Category" then table.insert(bottom_section, frame:preprocess{text = "{{DEFAULTSORT:" .. language_name .. "}}"}) if parent_language_category then table.insert(bottom_section, "[[" .. parent_language_category .. "]]") end table.insert(bottom_section, parent_category) end return table.concat(bottom_section, "\n\n\n") end --[[ -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ T E X T _ C A T E G O R Y > -------------------------- {{#invoke:Lang/documentor tool|non_manx_language_text_category}} This function implements {{Non-Manx-language text category}}. ]] local non_english_language_text_strings = { ["LINE1"] = "This category contains articles with %s%s text. The primary purpose of these categories is to facilitate manual or automated checking of text in other languages.", ["LINE2"] = "This category should only be added with the %s family of templates, never explicitly.", ["LINE3"] = 'For example %s, which wraps the text with %s. Also available is %s which displays as %s.', ["LINE3_SYNTAXHIGHLIGHT"] = "<span lang=\"%s\">", ["IN_SCRIPT"] = " (in %s)", ["EXAMPLE_DEFAULT_TEXT"] = "text in %s language here", ["PARENT_CATEGORY"] = "[[Ronney:Artyn lesh teks neu-Ghaelgagh]]", ["TEMPLATE"] = "Lang", ["TEMPLATE2"] = "Langx", } local function non_manx_language_text_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- args.test is used for /testcases if page.text == 'Lang and lang-xx template errors' then return '' end -- args.test is used for /testcases if args.test then page = mw.title.new(args.test) end -- Naming style: Articles with text from the Berber languages collective local page_title_modified = page.text local split_title = "([^,]+)%%s([^,]*)" local part1 = "" local part2 = "" if page_title_modified:find('Articles with text in') then -- Naming style: Category:Articles with text from Afro-Asiatic languages (as currently implemented in Module:lang) part1, part2 = LANGUAGE_CATEGORIES["LANGUAGES_COLLECTIVE_TEXT"]:match(split_title) elseif page_title_modified:find('explicitly cited') then part1, part2 = LANGUAGE_CATEGORIES["ENGLISH"]:match(split_title) else -- Naming style: Category:Articles containing French-language text part1, part2 = LANGUAGE_CATEGORIES["LANGUAGE_TEXT"]:match(split_title) end page_title_modified = page_title_modified:gsub(part1, "") page_title_modified = page_title_modified:gsub(part2, "") local language_name = page_title_modified local layout = {} table.insert(layout, get_hidden_category_template(frame)) local parent_category = non_english_language_text_strings["PARENT_CATEGORY"] if language_name == page.text then -- Error: Category title format not supported. return make_error(string.format(error_messages["NOT_VALID_CATEGORY_FORMAT"], page.text), layout, parent_category, args.nocat) end local lang_module = require('Module:Lang') local language_code = 'en' if language_code:find('[Ee]rror') then -- Error: Language code not found in database. return make_error(string.format(error_messages["NOT_VALID_LANGUAGE_CODE"], language_name), layout, parent_category, args.nocat) end local correct_language_category_title = lang_module._category_from_tag({language_code}) if correct_language_category_title:find('[Ee]rror') 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 current_category_title ~= correct_language_category_title then -- Error: The current title used is not in the supported format. TODO: can this still be reached? return make_error( string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, frame:expandTemplate{title = 'Tlx', args = {non_english_language_text_strings["TEMPLATE"]}}, correct_language_category_title), layout, parent_category, args.nocat) end table.insert(layout, get_top_section(frame)) local script_text = "" if args.script then script_text = string.format(non_english_language_text_strings["IN_SCRIPT"], args.script) end local language_link = get_language_link(language_name, language_code) table.insert(layout, string.format(non_english_language_text_strings["LINE1"], language_link, script_text)) local lang_template = frame:expandTemplate{title = 'Tl', args = {non_english_language_text_strings["TEMPLATE"]}} 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 = frame: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 = frame:expandTemplate{title = "Tlx", args = {non_english_language_text_strings["TEMPLATE2"], language_code, example_text}} local langx_template_code = frame: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 = frame: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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_sources_category}} This function implements {{Non-English-language sources category}}. ]] local non_english_language_sources_strings = { ["LINE1"] = "This is a tracking category for articles that use %s to identify %s sources.", ["PARENT_CATEGORY"] = "[[Category:Articles with non-English-language sources]]", ["TEMPLATE"] = "In lang", } local function non_english_language_sources_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- 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(frame)) 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, frame:expandTemplate{title = 'Tlx', args = {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"], frame:expandTemplate{title = 'Tlx', args = {non_english_language_sources_strings["TEMPLATE"], language_code}}, language_link) table.insert(layout, get_top_section(frame)) 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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_cs1_sources_category}} This function implements {{Non-English-language CS1 sources category}}. ]] local non_english_language_cs1_text_strings = { ["LINE1"] = "This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s to identify a source in [[%s language|%s]]. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].", ["PARENT_CATEGORY"] = "[[Category:CS1 foreign language sources]]", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources" } --"This is a tracking category for [[WP:CS1|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]].", --"[[Category:CS1 uses foreign language script]]", -- "This is a tracking category for [[WP:CS1|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 language|%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(frame) 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(frame)) local see_also_section = "" local parameter_doc = frame:expandTemplate{title = 'para', args = {"language", language_code}} table.insert(layout, get_top_section(frame)) 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(frame, 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 {{#invoke:Lang/sandbox|category_from_tag|<language_code>}}. 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( '{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '', 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 {{#invoke:Lang/sandbox|name_from_tag|<language_code>}}. ]] 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( '{{#invoke:Lang/sandbox|name_from_tag|', '}}', '', '', 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>. - "Actual" column value is the result of sandbox version {{#invoke:Lang/sandbox|tag_from_name|<language_name>}}. TODO: Currently not working. ]] local function testcases_tag_from_name(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) local ordered_table = {} table.sort(unordered_table) for _, key in ipairs(unordered_table) do table.insert(ordered_table, {key, reverse_table[key]}) end self:preprocess_equals_preprocess_many( '{{#invoke:Lang/sandbox|tag_from_name|', '}}', '', '', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ C O D E _ T O _ N A M E > -------------------------- Entry point for the various iso_code_to_name testcases. Build a table of test patterns where each entry in the table is a table with one member: {"<language_code>"} - "Expected" column value is the result of the live version of {{#invoke:ISO 639 name|iso_639_name_to_code|<language_code>}}. - "Actual" column value is the result of sandbox version {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_code>}}. ]] local function testcases_iso_code_to_name(self, args) local language_tables = get_table(get_language_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_code_to_name|link=yes|', '}}', '{{#invoke:ISO 639 name|iso_639_code_to_name|link=yes|', '}}', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ N A M E _ T O _ C O D E > -------------------------- Entry point for the various iso_name_to_code 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>. - "Actual" column is value the result of {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_name>}}. ]] local function testcases_iso_name_to_code(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|2=' .. args.iso_number .. "|", '}}', '', '', language_tables, {nowiki=false} ) end --[[--------------------------< S E E _ A L S O >-------------------------------------------------------------- adds items to the list of items in §See also section of Template:Lang-x/doc; Evaluates single positional parameter which is a comma-separated list of items including list markup. {{#invoke:Lang/documentor tool|see_also|*{{tl|Lang-tt-Cyrl}}, *{{tl|Lang-tt-Latn}}, *{{tl|Lang-tt-Arab}}}} ]] local function see_also (frame) if nil == frame.args[1] or '' == frame.args[1] then -- if empty, ... return -- ... return nothing end return frame:preprocess (frame.args[1]:gsub ('%s*,%s', '\n')) -- preprocess so any templates are rendered before saving and done end --[[ -------------------------< E X P O R T E D _ F U N C T I O N S > ----------------------------------------- ]] return { lang_xx_settings = lang_xx_settings, uses_module = uses_module, see_also = see_also, non_manx_language_text_category = non_manx_language_text_category, non_english_language_sources_category = non_english_language_sources_category, non_english_language_cs1_sources_category = non_english_language_cs1_sources_category, private_tags = private_tags, -- Module:Lang testcases testcases_category_from_tag = testcases_category_from_tag, testcases_name_from_tag = testcases_name_from_tag, testcases_tag_from_name = testcases_tag_from_name, -- Module:ISO 639 name testcases testcases_iso_code_to_name = testcases_iso_code_to_name, testcases_iso_name_to_code = testcases_iso_name_to_code, } 40h60dhgi26kr92wagzko07d9gq56g2 392771 392769 2026-09-04T12:22:45Z MacTire02 219 Undid revision [[Special:Diff/392769|392769]] by [[Special:Contributions/MacTire02|MacTire02]] ([[User talk:MacTire02|talk]]) 392771 Scribunto text/plain require('strict') local p = {} --[[ -------------------------< P R I V A T E _ T A G S >------------------------------------------------------ {{#invoke:Lang/documentor tool|private_tags}} Reads the override{} table in Module:Lang/data and renders a wiki table of private tags and their associated languages ]] local function private_tags (frame) 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, '{| class="wikitable sortable"') 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 >---------------------------------------------- {{#invoke:Lang/documentor tool|lang_xx_settings|template={{ROOTPAGENAME}}}} Reads the content of the template and extracts the parameters from {{#invoke:Lang|...}} for display on the template's documentation page. ]] local function lang_xx_settings(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+|[^}]+}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+|[^}]+}}') then -- if this template uses [[Module:Lang]] params = content:match('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+(|[^}]+)}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+(|[^}]+)}}') -- 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, '{| class="wikitable" style="text-align: right; float: right;"\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 style="color:#d33">Error: template #invoke calls unknown function</span>' end return table.concat({table.concat(out,'\n|-\n! scope="row" | '), '\n|-\n|colspan="2"|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 > -------------------------- {{#invoke:Lang/documentor tool|uses_module|template={{ROOTPAGENAME}}}} Reads the content of the template to determine if this {{lang-xx}} template uses Module:Lang. Returns the index of the substring '{{#invoke|lang|' in the template page content if true; empty string if false. Used in template documentation {{#if:}} parser functions. ]] local function uses_module(frame) local page = mw.title.makeTitle('Template', frame.args['template'] or frame.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 return content:find('{{%s*#invoke:[Ll]ang%s*|') or '' -- return index or empty string end --[[ -------------------------- < S H A R E D _ C O D E > -------------------------- - Tables: -- LANGUAGE_CATEGORIES -- error_messages -- strings - Functions: -- make_error(message, layout, parent_category, nocat) -- get_language_link(language_name, language_code) -- get_see_also_section(page_title, language_name, language_code) -- get_hidden_category_template(frame) -- get_top_section(frame) -- get_bottom_section(frame, language_name, see_also_section, parent_category) ]] local LANGUAGE_CATEGORIES = { ["LANGUAGES_SOURCES"] = "Artyn as geillyn ayns %s (%s)", ["LANGUAGES_COLLECTIVE_SOURCES"] = "Artyn as geillyn ayns %s (%s)", ["CS1"] = "Geillyn CS1 ayns %s (%s)", ["CS1_SCRIPT"] = "CS1 uses %s-language script (%s)", ["LANGUAGE_TEXT"] = "Artyn lesh teks ayns %s", ["LANGUAGES_COLLECTIVE_TEXT"] = "Artyn lesh teks ayns %s", ["ENGLISH"] = "Articles containing explicitly cited %s-language text", ["IPA"] = "Pages with %s IPA" } local error_assistance = " Please see [[Template talk:Lang]] for assistance." local error_messages = { ["ASSISTANCE"] = "Please see [[Template talk:Lang]] for assistance.", ["INCORRECT_CATEGORY_TITLE"] = "[[:%s]] is not the category being populated by the %s template. The correct category is located at: [[:%s]].", ["NO_CATEGORY_TITLE_FOUND"] = "No language category found for '''%s.'''" .. error_assistance, ["NOT_VALID_CATEGORY_FORMAT"] = "'''%s''' is not a a valid category title." .. error_assistance, ["NOT_VALID_LANGUAGE_CODE"] = "[[%s]] is not a valid ISO 639 or IETF language name." .. error_assistance, } local strings = { ["ERROR_CATEGORY"] = "[[Category:Lang and lang-xx template errors]]", ["ERROR_SPAN"] = '<span style="font-size: 100%%; font-style: normal;" class="error">Error: %s </span>', ["PURGE_DIV"] = '<div style="font-size: x-small;">%s</div>', ["SEE_ALSO"] = "\n==See also==", ["SEE_ALSO_ITEM"] = "* [[:%s]]", } --[[ -------------------------- < M A K E _ E R R O R > -------------------------- Create an error message. Does not place page in error category if args.nocat is used. Does not categorize in parent cateogory if used in category namespace (usually for /testcases). ]] local function make_error(message, layout, parent_category, nocat) table.insert(layout, string.format(strings["ERROR_SPAN"], message)) if not nocat then table.insert(layout, strings["ERROR_CATEGORY"]) end if mw.title.getCurrentTitle().nsText == "Category" then table.insert(layout, parent_category) end return table.concat(layout) end --[[ -------------------------- < G E T _ L A N G U A G E _ L I N K > -------------------------- Generates a language link for the correct style. Collective languages use the name_from_tag value, while other languages use a display name of "x-language". ]] local function get_language_link(language_name, language_code) local lang_module = require('Module:Lang') -- Is a language collective? if language_name:find('languages') then return lang_module.name_from_tag({language_code, link = "yes"}) else return lang_module.name_from_tag({language_code, link = "yes", label = lang_module.name_from_tag({language_code}) .. "-language"}) end end --[[ -------------------------- < G E T _ P R I M A R Y _ L A N G U A G E _ C O D E > -------------------------- Returns the primary language for sub-langage variants. ]] local function get_primary_language_code(language_code) -- If no hyphen exists, return nil (for cases like "el") if not language_code:find("-") then return nil end -- Match everything before the first hyphen, but only if a hyphen exists if language_code:match("^-") then return nil -- If the code starts with a hyphen, return nil end -- Look for the first part before any hyphen local primary_code = language_code:match("^[^-]+") return primary_code end --[[ -------------------------- < G E T _ S E E _ A L S O _ S E C T I O N > -------------------------- Generates a consistent style See also section for {{Category articles containing non-English-language text}} and {{Non-English-language source category}}. If {{CS1 language sources}} is converted, it should also use it. ]] local function get_see_also_section(page_title, language_name, language_code) local see_also_section = {} for _, category_name in pairs(LANGUAGE_CATEGORIES) do local category = mw.title.new(string.format(category_name, language_name, language_code), 14) if category and page_title ~= category.text and category.exists then table.insert(see_also_section, string.format(strings["SEE_ALSO_ITEM"], category.prefixedText)) end end table.sort(see_also_section) table.insert(see_also_section, 1, strings["SEE_ALSO"]) if table.getn(see_also_section) == 1 then return "" else return table.concat(see_also_section, "\n") end end --[[ -------------------------- < G E T _ H I D D E N _ C A T E G O R Y _ T E M P L A T E > -------------------------- Generates the Template:Hidden category template. This function is separate from the get_top_section() function as this should be used in both error categories and valid categories. ]] local function get_hidden_category_template(frame) return frame:expandTemplate{title = 'Hidden category'} end --[[ -------------------------- < G E T _ T O P _ S E C T I O N > -------------------------- Generates a consistent top maintenance template section which consists of: -- Template:Possibly empty category -- Template:Purge ]] local function get_top_section(frame) local top_section = {} if mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "all") == 0 then table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category'}) else table.insert(top_section, frame:expandTemplate{title = 'Possibly empty category', args = {hidden=true}}) end local purge_module = require('Module:Purge') table.insert(top_section, string.format(strings["PURGE_DIV"], purge_module._main({"Purge page cache"}))) return table.concat(top_section, "\n\n") end --[[ -------------------------- < G E T _ B O T T O M _ S E C T I O N > -------------------------- Generates a consistent non-text section which consists of: -- Template:Automatic category TOC -- A see also section -- {{DEFAULTSORT}} -- Categorization in parent category ]] local function get_bottom_section(frame, language_name, see_also_section, parent_category, parent_language_category) local bottom_section = {} table.insert(bottom_section, frame:expandTemplate{title = 'Automatic category TOC'}) table.insert(bottom_section, see_also_section) if mw.title.getCurrentTitle().nsText == "Category" then table.insert(bottom_section, frame:preprocess{text = "{{DEFAULTSORT:" .. language_name .. "}}"}) if parent_language_category then table.insert(bottom_section, "[[" .. parent_language_category .. "]]") end table.insert(bottom_section, parent_category) end return table.concat(bottom_section, "\n\n\n") end --[[ -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ T E X T _ C A T E G O R Y > -------------------------- {{#invoke:Lang/documentor tool|non_manx_language_text_category}} This function implements {{Non-Manx-language text category}}. ]] local non_english_language_text_strings = { ["LINE1"] = "This category contains articles with %s%s text. The primary purpose of these categories is to facilitate manual or automated checking of text in other languages.", ["LINE2"] = "This category should only be added with the %s family of templates, never explicitly.", ["LINE3"] = 'For example %s, which wraps the text with %s. Also available is %s which displays as %s.', ["LINE3_SYNTAXHIGHLIGHT"] = "<span lang=\"%s\">", ["IN_SCRIPT"] = " (in %s)", ["EXAMPLE_DEFAULT_TEXT"] = "text in %s language here", ["PARENT_CATEGORY"] = "[[Ronney:Artyn lesh teks neu-Ghaelgagh]]", ["TEMPLATE"] = "Lang", ["TEMPLATE2"] = "Langx", } local function non_manx_language_text_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- args.test is used for /testcases if page.text == 'Lang and lang-xx template errors' then return '' end -- args.test is used for /testcases if args.test then page = mw.title.new(args.test) end -- Naming style: Articles with text from the Berber languages collective local page_title_modified = page.text local split_title = "([^,]+)%%s([^,]*)" local part1 = "" local part2 = "" if page_title_modified:find('Articles with text in') then -- Naming style: Category:Articles with text from Afro-Asiatic languages (as currently implemented in Module:lang) part1, part2 = LANGUAGE_CATEGORIES["LANGUAGES_COLLECTIVE_TEXT"]:match(split_title) elseif page_title_modified:find('explicitly cited') then part1, part2 = LANGUAGE_CATEGORIES["ENGLISH"]:match(split_title) else -- Naming style: Category:Articles containing French-language text part1, part2 = LANGUAGE_CATEGORIES["LANGUAGE_TEXT"]:match(split_title) end page_title_modified = page_title_modified:gsub(part1, "") page_title_modified = page_title_modified:gsub(part2, "") local language_name = page_title_modified local layout = {} table.insert(layout, get_hidden_category_template(frame)) local parent_category = non_english_language_text_strings["PARENT_CATEGORY"] if language_name == page.text then -- Error: Category title format not supported. return make_error(string.format(error_messages["NOT_VALID_CATEGORY_FORMAT"], page.text), layout, parent_category, args.nocat) end local lang_module = require('Module:Lang') local language_code = lang_module._tag_from_name({language_name}) if language_code:find('[Ee]rror') then -- Error: Language code not found in database. return make_error(string.format(error_messages["NOT_VALID_LANGUAGE_CODE"], language_name), layout, parent_category, args.nocat) end local correct_language_category_title = lang_module._category_from_tag({language_code}) if correct_language_category_title:find('[Ee]rror') 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 current_category_title ~= correct_language_category_title then -- Error: The current title used is not in the supported format. TODO: can this still be reached? return make_error( string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, frame:expandTemplate{title = 'Tlx', args = {non_english_language_text_strings["TEMPLATE"]}}, correct_language_category_title), layout, parent_category, args.nocat) end table.insert(layout, get_top_section(frame)) local script_text = "" if args.script then script_text = string.format(non_english_language_text_strings["IN_SCRIPT"], args.script) end local language_link = get_language_link(language_name, language_code) table.insert(layout, string.format(non_english_language_text_strings["LINE1"], language_link, script_text)) local lang_template = frame:expandTemplate{title = 'Tl', args = {non_english_language_text_strings["TEMPLATE"]}} 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 = frame: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 = frame:expandTemplate{title = "Tlx", args = {non_english_language_text_strings["TEMPLATE2"], language_code, example_text}} local langx_template_code = frame: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 = frame: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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_sources_category}} This function implements {{Non-English-language sources category}}. ]] local non_english_language_sources_strings = { ["LINE1"] = "This is a tracking category for articles that use %s to identify %s sources.", ["PARENT_CATEGORY"] = "[[Category:Articles with non-English-language sources]]", ["TEMPLATE"] = "In lang", } local function non_english_language_sources_category(frame) local page = mw.title.getCurrentTitle() local args = require('Module:Arguments').getArgs(frame) -- 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(frame)) 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, frame:expandTemplate{title = 'Tlx', args = {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"], frame:expandTemplate{title = 'Tlx', args = {non_english_language_sources_strings["TEMPLATE"], language_code}}, language_link) table.insert(layout, get_top_section(frame)) 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(frame, 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 > -------------------------- {{#invoke:Lang/documentor tool|non_english_language_cs1_sources_category}} This function implements {{Non-English-language CS1 sources category}}. ]] local non_english_language_cs1_text_strings = { ["LINE1"] = "This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s to identify a source in [[%s language|%s]]. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].", ["PARENT_CATEGORY"] = "[[Category:CS1 foreign language sources]]", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources" } --"This is a tracking category for [[WP:CS1|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]].", --"[[Category:CS1 uses foreign language script]]", -- "This is a tracking category for [[WP:CS1|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 language|%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(frame) 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(frame)) local see_also_section = "" local parameter_doc = frame:expandTemplate{title = 'para', args = {"language", language_code}} table.insert(layout, get_top_section(frame)) 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(frame, 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 {{#invoke:Lang/sandbox|category_from_tag|<language_code>}}. 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( '{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '', 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 {{#invoke:Lang/sandbox|name_from_tag|<language_code>}}. ]] 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( '{{#invoke:Lang/sandbox|name_from_tag|', '}}', '', '', 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>. - "Actual" column value is the result of sandbox version {{#invoke:Lang/sandbox|tag_from_name|<language_name>}}. TODO: Currently not working. ]] local function testcases_tag_from_name(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) local ordered_table = {} table.sort(unordered_table) for _, key in ipairs(unordered_table) do table.insert(ordered_table, {key, reverse_table[key]}) end self:preprocess_equals_preprocess_many( '{{#invoke:Lang/sandbox|tag_from_name|', '}}', '', '', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ C O D E _ T O _ N A M E > -------------------------- Entry point for the various iso_code_to_name testcases. Build a table of test patterns where each entry in the table is a table with one member: {"<language_code>"} - "Expected" column value is the result of the live version of {{#invoke:ISO 639 name|iso_639_name_to_code|<language_code>}}. - "Actual" column value is the result of sandbox version {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_code>}}. ]] local function testcases_iso_code_to_name(self, args) local language_tables = get_table(get_language_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_code_to_name|link=yes|', '}}', '{{#invoke:ISO 639 name|iso_639_code_to_name|link=yes|', '}}', language_tables, {nowiki=false} ) end --[[ -------------------------- < T E S T C A S E S _ I S O _ N A M E _ T O _ C O D E > -------------------------- Entry point for the various iso_name_to_code 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>. - "Actual" column is value the result of {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_name>}}. ]] local function testcases_iso_name_to_code(self, args) local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil) table.sort(language_tables, compare_by_keys2) self:preprocess_equals_preprocess_many( '{{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|2=' .. args.iso_number .. "|", '}}', '', '', language_tables, {nowiki=false} ) end --[[--------------------------< S E E _ A L S O >-------------------------------------------------------------- adds items to the list of items in §See also section of Template:Lang-x/doc; Evaluates single positional parameter which is a comma-separated list of items including list markup. {{#invoke:Lang/documentor tool|see_also|*{{tl|Lang-tt-Cyrl}}, *{{tl|Lang-tt-Latn}}, *{{tl|Lang-tt-Arab}}}} ]] local function see_also (frame) if nil == frame.args[1] or '' == frame.args[1] then -- if empty, ... return -- ... return nothing end return frame:preprocess (frame.args[1]:gsub ('%s*,%s', '\n')) -- preprocess so any templates are rendered before saving and done end --[[ -------------------------< E X P O R T E D _ F U N C T I O N S > ----------------------------------------- ]] return { lang_xx_settings = lang_xx_settings, uses_module = uses_module, see_also = see_also, non_manx_language_text_category = non_manx_language_text_category, non_english_language_sources_category = non_english_language_sources_category, non_english_language_cs1_sources_category = non_english_language_cs1_sources_category, private_tags = private_tags, -- Module:Lang testcases testcases_category_from_tag = testcases_category_from_tag, testcases_name_from_tag = testcases_name_from_tag, testcases_tag_from_name = testcases_tag_from_name, -- Module:ISO 639 name testcases testcases_iso_code_to_name = testcases_iso_code_to_name, testcases_iso_name_to_code = testcases_iso_name_to_code, } lbidmxjufk9r7lx4ffvmst0229bln2f Module:Lang/tag from name 828 55824 392768 2026-09-04T12:10:47Z MacTire02 219 Duillag crooit lesh: local lang_data = mw.loadData ('Module:Lang/data'); -- language name override and transliteration tool-tip tables local lang_name_table = lang_data.lang_name_table; -- language codes, names, regions, scripts, suppressed scripts local lang_table = lang_name_table.lang; -- language codes, names local lang_dep_table = lang_name_table.lang_dep; -- deprecated language codes, names local override_table = lang_data.override; local rev_lang_table... 392768 Scribunto text/plain local lang_data = mw.loadData ('Module:Lang/data'); -- language name override and transliteration tool-tip tables local lang_name_table = lang_data.lang_name_table; -- language codes, names, regions, scripts, suppressed scripts local lang_table = lang_name_table.lang; -- language codes, names local lang_dep_table = lang_name_table.lang_dep; -- deprecated language codes, names local override_table = lang_data.override; local rev_lang_table = {}; -- same as lang_table reversed so language name is key and language tag is value local rev_lang_dep_table = {}; -- same as lang_dep_table reversed so language name is key and language tag is value local rev_override_table = {}; -- same as override_table except reversed local dedabbed_names_list = {}; -- holds a list of dedabbed name and tags --[[--------------------------< R E V _ L I S T _ A D D >------------------------------------------------------ local function to add <name> (key) and <tag> (value) pair to <rev_list> <name>/<tag> pairs where <tag> is ISO 639-1, overwrite all other <name>/<tag> pairs. When creating overrides, take care that the <name> is properly disambiguated to avoid improper masking ]] local function rev_list_add (rev_list, name, tag) if rev_list[name] then -- if already in <rev_list> if 2 == tag:len() then -- is this is a 2-characater code? rev_list[name] = tag; -- yes, overwrite 3-characater language <name> and <tag> pair in <rev_list> end else -- here when not yet in <rev_list> rev_list[name] = tag; -- add language <name> and <tag> (value) pair to <rev_list> end end --[[--------------------------< D E D A B B E D _ N A M E S _ L I S T _ A D D >-------------------------------- adds <name>/<tag> pairs to the dedabbed_names_list when <name> not already present. When <name> is present in the list, unsets the listed <tag> to empty string; cannot have different <name>/<tag> pairs where the table key (<name>) is shared with another <name>/<tag> pair. ]] local function dedabbed_names_list_add (dab, name, tag) if 0 ~= dab then -- if dab was removed if dedabbed_names_list[name] then -- if this dedabbed name is in the table then there are more than one name with different dabs dedabbed_names_list[name] = ''; -- unset but not too unset else dedabbed_names_list[name] = tag; -- add name / tag pair in case this the only dedabbed name end end end --[[--------------------------< D E D A B B E D _ T O _ R E V _ L I S T _ A D D >------------------------------ adds <name>/<tag> pairs to specified <rev_list> when <tag> is not empty string ]] local function dedabbed_to_rev_list_add (rev_list, name, tag) for name, tag in pairs (dedabbed_names_list) do -- add dedabbed <name>/<tag> pairs to the reversed table if '' ~= tag then -- when <name>/<tag> has not been unset because of multiple dabs rev_list_add (rev_list, name, tag); -- add end end end --[[--------------------------< T A G - F R O M - N A M E D A T A >------------------------------------------ Creates tag-from-name tables from the data in Module:Lang/data so that templates can get language tags from the same names as the {{lang}} templates get from those tags. The conversion prefers ISO 639-1 codes. Data in these tables are used by tag_from_name() in Module:Lang When <name> is disambiguated, will create an additional <name> entry without the dab as long as that action won't conflict with actual undabbed names in the source. <name> without dab is always added to the list; this rule arises because of the three Marwari language code/name pairs: mwr: Marwari -– not dabbed these will not have dedabbed entries because of mwr rwr: Marwari (India) mve: Marwari (Pakistan) These all share the same base name so there will not not be an dedabbed entry: ["yaka"] = "axk", -- this would be wrong for two of these languages ["yaka (central african republic)"] = "axk", ["yaka (congo)"] = "iyx", ["yaka (democratic republic of congo)"] = "yaf", Say that we find "axk". It has a dab so we add the dabbed form to rev_lang_table{}. Then we look in dedabbed_names_list{} to see if ["yaka"] is already there. It's not, so we add this: ["yaka"] = "axk", Later we find "yaf". It has a dab so we add the dabbed form to rev_lang_table{}. Then we look in dedabbed_names_list{} to see if ["yaka"] is already there. It is, so that means that more than one language code could create an dedabbed language name key; there can be only one. Because ["yaka"] is already in the dedabbed_names_list{} table we unset the ["yaka"] entry to empty string: ["yaka"] = '', later we find "iyx" and add it to rev_lang_table{}. We look in dedabbed_names_list{} and find ["yaka"] has been unset to empty string so do nothing. When done adding names/codes to rev_lang_table{}, spin through dedabbed_names_list{} and add all non-empty-string name/code pairs to rev_lang_table{}. This does not catch things like overrides ["pa"] = "Punjabi" and ["pnb"] = "Punjabi". "pa" and "pnb" are not synonyms but because the names are the same, will be treated like synonyms ("pnb" promotes to "pa"). To avoid this, disambiguate the override: ["pnb"] = {"Punjabi"} -> ["pnb"] = {"Punjabi (Western)"} ]] for tag, name_table in pairs (lang_table) do if not override_table[tag] then -- only add names/tags from name_table when tag not present in override table local name_raw = name_table:lower(); local name, dab = name_raw:gsub ('%s+%b()', ''); -- remove parenthetical disambiguators or qualifiers from names that have them; <dab> non-zero when disambiguation removed rev_list_add (rev_lang_table, name_raw, tag); -- add no-dab-names and names-with-dab here dedabbed_names_list_add (dab, name, tag); -- add to dedabbed_names_list if dabbed end end dedabbed_to_rev_list_add (rev_lang_table, name, tag); -- add dedabbed name/tag pairs to the reversed table dedabbed_names_list = {}; -- reset list of dedabbed names for tag, name_table in pairs (lang_dep_table) do if not override_table[tag] then -- only add names/tags from name_table when tag not present in override table local name_raw = name_table:lower(); local name, dab = name_raw:gsub ('%s+%b()', ''); -- remove parenthetical disambiguators or qualifiers from names that have them; <dab> non-zero when disambiguation removed rev_list_add (rev_lang_dep_table, name_raw, tag); -- add no-dab-names and names-with-dab here dedabbed_names_list_add (dab, name, tag); -- add to dedabbed_names_list if dabbed end end dedabbed_to_rev_list_add (rev_lang_dep_table, name, tag); -- add dedabbed name/tag pairs to the reversed table dedabbed_names_list = {}; -- reset list of dedabbed names for tag, name_table in pairs (override_table) do local name_raw = name_table:lower(); local name, dab = name_raw:gsub ('%s+%b()', ''); -- remove parenthetical disambiguators or qualifiers from names that have them rev_list_add (rev_override_table, name_raw, tag); dedabbed_names_list_add (dab, name, tag); -- add to dedabbed_names_list if dabbed end dedabbed_to_rev_list_add (rev_override_table, name, tag); -- add dedabbed name/tag pairs to the reversed table dedabbed_names_list = {}; -- reset list --[[--------------------------< E X P O R T E D T A B L E S >------------------------------------------------ ]] return { rev_lang_table = rev_lang_table, rev_lang_dep_table = rev_lang_dep_table, rev_override_table = rev_override_table, } j3mfsv6vl3rrvzdingbsgsmtlpxmpvq Module:Purge 828 55825 392770 2026-09-04T12:22:09Z MacTire02 219 Duillag crooit lesh: -- This module implements [[Template:Purge]]. local p = {} local function makeUrlLink(url, display) return string.format('[%s %s]', url, display) end function p._main(args) -- Make the URL local url do local title if args.page then title = mw.title.new(args.page) if not title then error(string.format( "'%s' is not a valid page name", args.page ), 2) end else title = mw.title.getCurrentTitle() end if args.anchor then titl... 392770 Scribunto text/plain -- This module implements [[Template:Purge]]. local p = {} local function makeUrlLink(url, display) return string.format('[%s %s]', url, display) end function p._main(args) -- Make the URL local url do local title if args.page then title = mw.title.new(args.page) if not title then error(string.format( "'%s' is not a valid page name", args.page ), 2) end else title = mw.title.getCurrentTitle() end if args.anchor then title.fragment = args.anchor end url = title:fullUrl{action = 'purge'} end -- Make the display local display if args.page then display = args[1] or 'Purge' else display = mw.html.create('span') display :attr('title', 'Purge this page') :wikitext(args[1] or 'Purge') display = tostring(display) end -- Output the HTML local root = mw.html.create('span') root :addClass('noprint') :addClass('plainlinks') :addClass('purgelink') :wikitext(makeUrlLink(url, display)) return tostring(root) end function p.main(frame) local args = frame:getParent().args return p._main(args) end return p 7zn4wpraqp0o2q6ovvb2j9zno19p3zp Clowan:Kishtey fys çheer/noa 10 55826 392772 2026-09-04T14:37:39Z MacTire02 219 Duillag crooit lesh: <includeonly> {{Infobox | bodyclass = geography vcard | above = {{#if:{{{ennym_dooghyssagh|}}} |{{{ennym_dooghyssagh}}} }} {{#if:{{{ennym_foddey_cadjincliaghtagh|}}}{{{ennym|}}} |<div style="padding-top:0.25em;">{{{ennym_foddey_cadjincliaghtagh|}}}{{{ennym|}}}</div> }} | image = {{#if:{{{jalloo_brattagh|}}}{{{jalloo_cleinney|}}}{{{jalloo_cowrey|}}} | {{#if:{{{jalloo_brattagh|}}} |File:{{{jalloo_brattagh}}}|125px|bor... 392772 wikitext text/x-wiki <includeonly> {{Infobox | bodyclass = geography vcard | above = {{#if:{{{ennym_dooghyssagh|}}} |{{{ennym_dooghyssagh}}} }} {{#if:{{{ennym_foddey_cadjincliaghtagh|}}}{{{ennym|}}} |<div style="padding-top:0.25em;">{{{ennym_foddey_cadjincliaghtagh|}}}{{{ennym|}}}</div> }} | image = {{#if:{{{jalloo_brattagh|}}}{{{jalloo_cleinney|}}}{{{jalloo_cowrey|}}} | {{#if:{{{jalloo_brattagh|}}} |[[File:{{{jalloo_brattagh}}}|125px|border|alt=Brattagh {{{ennym|{{PAGENAME}}}}}]] }} {{#if:{{{jalloo_cleinney|}}}{{{jalloo_cowrey|}}} |{{#if:{{{jalloo_brattagh|}}}|&nbsp;&nbsp;}} [[File:{{{jalloo_cleinney|{{{jalloo_cowrey|}}}}}|{{{lheead_cowrey|85px}}}|alt={{Nobold|{{{sorçh_cowrey|Cowrey cleinney}}}}} {{{ennym|{{PAGENAME}}}}}]] }} }} | caption = {{#if:{{{jalloo_brattagh|}}} |[[Brattagh {{{ennym_gienneydagh|{{{ennym|{{PAGENAME}}}}}}}}}|{{{fo-heidyl_brattagh|Brattagh}}}]] }} {{#if:{{{jalloo_cleinney|}}}{{{jalloo_cowrey|}}} |{{#if:{{{jalloo_brattagh|}}}|&nbsp;&nbsp;}} [[{{{art_sorçh_cowrey|{{{sorçh_cowrey|Armys}}}}} {{{ennym_gienneydagh|{{{ennym|{{PAGENAME}}}}}}}}}|{{{sorçh_cowrey|Armys}}}]] }} | header1 = {{#if:{{{jarroo-raa_ashoonagh|}}}{{{jarroo-raa|}}}|Jarroo-raa}} | data1 = {{#if:{{{jarroo-raa_ashoonagh|}}}{{{jarroo-raa|}}} |'''[[Jarroo-raa]]:&nbsp;'''{{{jarroo-raa_ashoonagh|}}}{{{jarroo-raa|}}} }} | header2 = {{#if:{{{arrane_ashoonagh|}}}{{{arrane_reeoil|}}}{{{arrane|}}}|Arrane(yn) ashoonagh}} | data2 = {{#if:{{{arrane_ashoonagh|}}} |'''[[Arrane ashoonagh]]:&nbsp;'''{{{arrane_ashoonagh}}}<br/> }} {{#if:{{{arrane|}}} |'''[[Arrane]]:&nbsp;'''{{{arrane}}}<br/> }} {{#if:{{{arrane_reeoil|}}} |'''[[Arrane reeoil]]:&nbsp;'''{{{arrane_reeoil}}} }} }} </includeonly> <noinclude> {{docamadys}} </noinclude> ois91xwsvdtqt70jdn54stbv5tmqhc8 392773 392772 2026-09-04T14:46:53Z MacTire02 219 ->Lua 392773 wikitext text/x-wiki <includeonly> {{Infobox | above = {{{ennym|{{PAGENAME}}}}} | image = {{#invoke:Kishtey fys çheer|images}} | caption = {{#invoke:Kishtey fys çheer|captions}} }} </includeonly> nuju11inepead62nkfyvnra3qgfsas4 392781 392773 2026-09-04T17:08:34Z MacTire02 219 +enmyn 392781 wikitext text/x-wiki <includeonly> {{Infobox | above = {{#invoke:Kishtey fys çheer|title}} | image = {{#invoke:Kishtey fys çheer|images}} | caption = {{#invoke:Kishtey fys çheer|captions}} }} </includeonly> qtl18lrr5y55u7y76qvdvtg9679lmls Module:Kishtey fys çheer 828 55827 392774 2026-09-04T14:47:15Z MacTire02 219 Duillag crooit lesh: local p = {} local function getArgs(frame) local args = frame:getParent().args return args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(p... 392774 Scribunto text/plain local p = {} local function getArgs(frame) local args = frame:getParent().args return args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do if statement.mainsnak and statement.mainsnak.snaktype == "value" and statement.mainsnak.datavalue and statement.mainsnak.datavalue.type == "string" then local value = statement.mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end local function getFlag(args) local manual = getManual(args, { "jalloo_brattagh" }) if manual then return manual end return getWikidataImage("P41") end local function getArms(args) local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end return getWikidataImage("P94") end function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) if not flag and not arms then return "" end if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[File:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[File:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end if flag then return string.format( '<div style="text-align:center;">[[File:%s|125px|border|alt=Brattagh]]</div>', flag ) end return string.format( '<div style="text-align:center;">[[File:%s|%s|alt=Armys]]</div>', arms, args.lheead_cowrey or "85px" ) end function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) if not flag and not arms then return "" end local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>%s</small>' .. '</td>' .. '</tr></table>', args.ennym_gienneydagh or args.ennym or mw.title.getCurrentTitle().text, flagCaption, armsCaption ) end if flag then return string.format( '<div style="text-align:center;"><small>[[Brattagh %s|%s]]</small></div>', args.ennym_gienneydagh or args.ennym or mw.title.getCurrentTitle().text, flagCaption ) end return string.format( '<div style="text-align:center;"><small>%s</small></div>', armsCaption ) end return p 1o0ypqek62j1bkl44mdo715fphftqvw 392775 392774 2026-09-04T14:57:08Z MacTire02 219 armys -> kiangley 392775 Scribunto text/plain local p = {} local function getArgs(frame) local args = frame:getParent().args return args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do if statement.mainsnak and statement.mainsnak.snaktype == "value" and statement.mainsnak.datavalue and statement.mainsnak.datavalue.type == "string" then local value = statement.mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end local function getFlag(args) local manual = getManual(args, { "jalloo_brattagh" }) if manual then return manual end return getWikidataImage("P41") end local function getArms(args) local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end return getWikidataImage("P94") end local function getFlagLinkName(args) local name = args.ennym or mw.title.getCurrentTitle().text -- Manx genitive forms for country names. local genitive = { ["Mannin"] = "Vannin", ["Yn Rank"] = "y Rank" } return genitive[name] or name end function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) if not flag and not arms then return "" end if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[File:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[File:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end if flag then return string.format( '<div style="text-align:center;">[[File:%s|125px|border|alt=Brattagh]]</div>', flag ) end return string.format( '<div style="text-align:center;">[[File:%s|%s|alt=Armys]]</div>', arms, args.lheead_cowrey or "85px" ) end function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) if not flag and not arms then return "" end local flagName = getFlagLinkName(args) local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>[[%s|%s]]</small>' .. '</td>' .. '</tr></table>', flagName, flagCaption, "Armys " .. (args.ennym or mw.title.getCurrentTitle().text), armsCaption ) end if flag then return string.format( '<div style="text-align:center;"><small>[[Brattagh %s|%s]]</small></div>', flagName, flagCaption ) end return string.format( '<div style="text-align:center;"><small>[[Armys %s|%s]]</small></div>', args.ennym or mw.title.getCurrentTitle().text, armsCaption ) end return p 1yxokohlu0l9mt1qett7ojl4wyx9md5 392777 392775 2026-09-04T15:13:35Z MacTire02 219 ++ 392777 Scribunto text/plain local p = {} local enmynCheerey = require("Module:Enmyn çheerey") local function getArgs(frame) return frame:getParent().args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then local value = mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end ------------------------------------------------------------ -- Flag ------------------------------------------------------------ local function getFlag(args) -- Manual value takes precedence over Wikidata. local manual = getManual(args, { "jalloo_brattagh" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P41 = flag image. return getWikidataImage("P41") end ------------------------------------------------------------ -- Coat of arms ------------------------------------------------------------ local function getArms(args) -- Manual value takes precedence over Wikidata. -- jalloo_armys is the preferred new parameter. -- jalloo_cleinney and jalloo_cowrey remain supported -- for compatibility with existing articles. local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then -- Explicitly suppress Wikidata. if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P94 = coat of arms image. return getWikidataImage("P94") end ------------------------------------------------------------ -- Country name ------------------------------------------------------------ local function getCountryName(args) return args.ennym_gienneydagh or args.kianglaghey_ennym or args.ennym or mw.title.getCurrentTitle().text end local function getGenitiveName(args) local name = getCountryName(args) return enmynCheerey.genitive(name) end ------------------------------------------------------------ -- Images ------------------------------------------------------------ function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[File:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[File:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '[[File:%s|125px|border|alt=Brattagh]]' .. '</div>', flag ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '[[File:%s|%s|alt=Armys]]' .. '</div>', arms, args.lheead_cowrey or "85px" ) end ------------------------------------------------------------ -- Captions ------------------------------------------------------------ function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end local countryName = getCountryName(args) local genitiveName = getGenitiveName(args) local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" local armsArticle = args["art_sorçh_cowrey"] or "Armys" -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</td>' .. '</tr></table>', genitiveName, flagCaption, armsArticle, genitiveName, armsCaption ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</div>', genitiveName, flagCaption ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</div>', armsArticle, genitiveName, armsCaption ) end return p 4uaeyz4hre3th46szfnwq9tsaq1ku7z 392780 392777 2026-09-04T17:07:24Z MacTire02 219 ++ 392780 Scribunto text/plain local p = {} local enmynCheerey = require("Module:Enmyn çheerey") local langData = mw.loadData("Module:Lang/data") local langNameTable = langData.lang_name_table local function getArgs(frame) return frame:getParent().args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then local value = mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end ------------------------------------------------------------ -- Flag ------------------------------------------------------------ local function getFlag(args) -- Manual value takes precedence over Wikidata. local manual = getManual(args, { "jalloo_brattagh" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P41 = flag image. return getWikidataImage("P41") end ------------------------------------------------------------ -- Coat of arms ------------------------------------------------------------ local function getArms(args) -- Manual value takes precedence over Wikidata. -- jalloo_armys is the preferred new parameter. -- jalloo_cleinney and jalloo_cowrey remain supported -- for compatibility with existing articles. local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then -- Explicitly suppress Wikidata. if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P94 = coat of arms image. return getWikidataImage("P94") end ------------------------------------------------------------ -- Country name ------------------------------------------------------------ local function getCountryName(args) return args.ennym_gienneydagh or args.kianglaghey_ennym or args.ennym or mw.title.getCurrentTitle().text end local function getGenitiveName(args) local name = getCountryName(args) return enmynCheerey.genitive(name) end ------------------------------------------------------------ -- Official name (Wikidata P1448) ------------------------------------------------------------ local function getOfficialNames() local entity = mw.wikibase.getEntityObject() if not entity then return {} end local statements = entity:getBestStatements("P1448") if not statements or #statements == 0 then return {} end local names = {} for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "monolingualtext" then local value = mainsnak.datavalue.value if value and value.text and value.text ~= "" and value.language and value.language ~= "" then table.insert(names, { text = value.text, lang = mw.ustring.lower(value.language) }) end end end return names end ------------------------------------------------------------ -- Language name ------------------------------------------------------------ local function getLanguageName(code) if not code or code == "" then return code end local data = langNameTable[code] if type(data) == "string" then return data end if type(data) == "table" then return data.name or data[1] or code end return code end ------------------------------------------------------------ -- Language label ------------------------------------------------------------ local function makeLanguageLabel(code) local languageName = getLanguageName(code) if not languageName or languageName == "" then return "" end -- The language name is deliberately NOT italicised. return mw.text.tag( "small", "[[" .. languageName .. "|" .. languageName .. "]]" ) end ------------------------------------------------------------ -- Country title ------------------------------------------------------------ function p.title(frame) local args = getArgs(frame) local countryName = getCountryName(args) local officialNames = getOfficialNames() local manxName = nil local otherNames = {} -- Find the Manx official name first. for _, item in ipairs(officialNames) do if item.lang == "gv" then manxName = item.text break end end -- If Wikidata has no Manx P1448, fall back to the -- supplied country name. if not manxName then manxName = countryName end local output = {} -- Manx official name: bold. table.insert( output, "<b>" .. manxName .. "</b>" ) -- Other official-language names. for _, item in ipairs(officialNames) do if item.lang ~= "gv" then local languageLabel = makeLanguageLabel(item.lang) if languageLabel ~= "" then table.insert( output, item.text .. " " .. languageLabel ) else table.insert( output, item.text ) end end end return table.concat(output, "<br>") end ------------------------------------------------------------ -- Images ------------------------------------------------------------ function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</div>', flag ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</div>', arms, args.lheead_cowrey or "85px" ) end ------------------------------------------------------------ -- Captions ------------------------------------------------------------ function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end local countryName = getCountryName(args) local genitiveName = getGenitiveName(args) local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" local armsArticle = args["art_sorçh_cowrey"] or "Armys" -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</td>' .. '</tr></table>', genitiveName, flagCaption, armsArticle, genitiveName, armsCaption ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</div>', genitiveName, flagCaption ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</div>', armsArticle, genitiveName, armsCaption ) end return p owttti18x8fr20eyqvyfjdb8jechn2y 392782 392780 2026-09-04T17:14:15Z MacTire02 219 ++ 392782 Scribunto text/plain local p = {} local enmynCheerey = require("Module:Enmyn çheerey") local langData = mw.loadData("Module:Lang/data") local langNameTable = langData.lang_name_table local function getArgs(frame) return frame:getParent().args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then local value = mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end ------------------------------------------------------------ -- Flag ------------------------------------------------------------ local function getFlag(args) -- Manual value takes precedence over Wikidata. local manual = getManual(args, { "jalloo_brattagh" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P41 = flag image. return getWikidataImage("P41") end ------------------------------------------------------------ -- Coat of arms ------------------------------------------------------------ local function getArms(args) -- Manual value takes precedence over Wikidata. -- jalloo_armys is the preferred new parameter. -- jalloo_cleinney and jalloo_cowrey remain supported -- for compatibility with existing articles. local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then -- Explicitly suppress Wikidata. if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P94 = coat of arms image. return getWikidataImage("P94") end ------------------------------------------------------------ -- Country name ------------------------------------------------------------ local function getCountryName(args) return args.ennym_gienneydagh or args.kianglaghey_ennym or args.ennym or mw.title.getCurrentTitle().text end local function getGenitiveName(args) local name = getCountryName(args) return enmynCheerey.genitive(name) end ------------------------------------------------------------ -- Official name (Wikidata P1448) ------------------------------------------------------------ local function getOfficialNames() local entity = mw.wikibase.getEntityObject() if not entity then return {} end local statements = entity:getBestStatements("P1448") if not statements or #statements == 0 then return {} end local names = {} for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "monolingualtext" then local value = mainsnak.datavalue.value if value and value.text and value.text ~= "" and value.language and value.language ~= "" then table.insert(names, { text = value.text, lang = mw.ustring.lower(value.language) }) end end end return names end ------------------------------------------------------------ -- Language name ------------------------------------------------------------ local function getLanguageName(code) if not code or code == "" then return code end local data = langNameTable[code] if type(data) == "string" then return data end if type(data) == "table" then return data.name or data[1] or code end return code end ------------------------------------------------------------ -- Language label ------------------------------------------------------------ local function makeLanguageLabel(code) local languageName = getLanguageName(code) if not languageName or languageName == "" then return "" end -- The language name is deliberately NOT italicised. return mw.text.tag( "small", {}, "[[" .. languageName .. "|" .. languageName .. "]]" ) end ------------------------------------------------------------ -- Country title ------------------------------------------------------------ function p.title(frame) local args = getArgs(frame) local countryName = getCountryName(args) local officialNames = getOfficialNames() local manxName = nil local otherNames = {} -- Find the Manx official name first. for _, item in ipairs(officialNames) do if item.lang == "gv" then manxName = item.text break end end -- If Wikidata has no Manx P1448, fall back to the -- supplied country name. if not manxName then manxName = countryName end local output = {} -- Manx official name: bold. table.insert( output, "<b>" .. manxName .. "</b>" ) -- Other official-language names. for _, item in ipairs(officialNames) do if item.lang ~= "gv" then local languageLabel = makeLanguageLabel(item.lang) if languageLabel ~= "" then table.insert( output, item.text .. " " .. languageLabel ) else table.insert( output, item.text ) end end end return table.concat(output, "<br>") end ------------------------------------------------------------ -- Images ------------------------------------------------------------ function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</div>', flag ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</div>', arms, args.lheead_cowrey or "85px" ) end ------------------------------------------------------------ -- Captions ------------------------------------------------------------ function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end local countryName = getCountryName(args) local genitiveName = getGenitiveName(args) local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" local armsArticle = args["art_sorçh_cowrey"] or "Armys" -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</td>' .. '</tr></table>', genitiveName, flagCaption, armsArticle, genitiveName, armsCaption ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</div>', genitiveName, flagCaption ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</div>', armsArticle, genitiveName, armsCaption ) end return p c3cqh8n8w6a5j0nto7w9vip6ikpyud2 392783 392782 2026-09-04T17:22:14Z MacTire02 219 chengey, kiangley ennym 392783 Scribunto text/plain local p = {} local enmynCheerey = require("Module:Enmyn çheerey") local langData = mw.loadData("Module:Lang/data") local langNameTable = langData.lang_name_table.lang local langOverrideTable = langData.override local function getArgs(frame) return frame:getParent().args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then local value = mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end ------------------------------------------------------------ -- Flag ------------------------------------------------------------ local function getFlag(args) -- Manual value takes precedence over Wikidata. local manual = getManual(args, { "jalloo_brattagh" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P41 = flag image. return getWikidataImage("P41") end ------------------------------------------------------------ -- Coat of arms ------------------------------------------------------------ local function getArms(args) -- Manual value takes precedence over Wikidata. -- jalloo_armys is the preferred new parameter. -- jalloo_cleinney and jalloo_cowrey remain supported -- for compatibility with existing articles. local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then -- Explicitly suppress Wikidata. if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P94 = coat of arms image. return getWikidataImage("P94") end ------------------------------------------------------------ -- Country name ------------------------------------------------------------ local function getCountryName(args) return args.ennym_gienneydagh or args.kianglaghey_ennym or args.ennym or mw.title.getCurrentTitle().text end local function getGenitiveName(args) local name = getCountryName(args) return enmynCheerey.genitive(name) end ------------------------------------------------------------ -- Official name (Wikidata P1448) ------------------------------------------------------------ local function getOfficialNames() local entity = mw.wikibase.getEntityObject() if not entity then return {} end local statements = entity:getBestStatements("P1448") if not statements or #statements == 0 then return {} end local names = {} for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "monolingualtext" then local value = mainsnak.datavalue.value if value and value.text and value.text ~= "" and value.language and value.language ~= "" then table.insert(names, { text = value.text, lang = mw.ustring.lower(value.language) }) end end end return names end ------------------------------------------------------------ -- Language name ------------------------------------------------------------ local function getLanguageName(code) if not code or code == "" then return code end code = mw.ustring.lower(code) -- Manx Wikipedia language-name override. if langOverrideTable and langOverrideTable[code] then local name = langOverrideTable[code] if type(name) == "table" then return name[1] end return name end -- Standard language-name table. if langNameTable and langNameTable[code] then local name = langNameTable[code] if type(name) == "table" then return name[1] end return name end return code end ------------------------------------------------------------ -- Language label ------------------------------------------------------------ local function makeLanguageLabel(code) local languageName = getLanguageName(code) if not languageName or languageName == "" then return "" end -- The language name is deliberately NOT italicised. return mw.text.tag( "small", {}, "([[" .. languageName .. "|" .. languageName .. "]])" ) end ------------------------------------------------------------ -- Country title ------------------------------------------------------------ function p.title(frame) local args = getArgs(frame) local countryName = getCountryName(args) local officialNames = getOfficialNames() local manxName = nil local otherNames = {} -- Find the Manx official name first. for _, item in ipairs(officialNames) do if item.lang == "gv" then manxName = item.text break end end -- If Wikidata has no Manx P1448, fall back to the -- supplied country name. if not manxName then manxName = countryName end local output = {} -- Manx official name: bold. table.insert( output, "<b>" .. manxName .. "</b>" ) -- Other official-language names. for _, item in ipairs(officialNames) do if item.lang ~= "gv" then local languageLabel = makeLanguageLabel(item.lang) if languageLabel ~= "" then table.insert( output, item.text .. " " .. languageLabel ) else table.insert( output, item.text ) end end end return table.concat(output, "<br>") end ------------------------------------------------------------ -- Images ------------------------------------------------------------ function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</div>', flag ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</div>', arms, args.lheead_cowrey or "85px" ) end ------------------------------------------------------------ -- Captions ------------------------------------------------------------ function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end local countryName = getCountryName(args) local genitiveName = getGenitiveName(args) local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" local armsArticle = args["art_sorçh_cowrey"] or "Armys" -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</td>' .. '</tr></table>', genitiveName, flagCaption, armsArticle, genitiveName, armsCaption ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</div>', genitiveName, flagCaption ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</div>', armsArticle, genitiveName, armsCaption ) end return p 2o9umb4fs4nmjsexydxmt7119be4jrs 392784 392783 2026-09-04T17:24:20Z MacTire02 219 enmys ceaghlit 392784 Scribunto text/plain local p = {} local enmynCheerey = require("Module:Enmyn çheerey") local langData = mw.loadData("Module:Lang/data") local langNameTable = langData.lang_name_table.lang local langOverrideTable = langData.override local function getArgs(frame) return frame:getParent().args end local function getManual(args, names) for _, name in ipairs(names) do local value = args[name] if value and mw.text.trim(value) ~= "" then return mw.text.trim(value) end end return nil end local function getWikidataImage(property) local entity = mw.wikibase.getEntityObject() if not entity then return nil end local statements = entity:getBestStatements(property) if not statements or #statements == 0 then return nil end for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "string" then local value = mainsnak.datavalue.value if value and value ~= "" then return value end end end return nil end ------------------------------------------------------------ -- Flag ------------------------------------------------------------ local function getFlag(args) -- Manual value takes precedence over Wikidata. local manual = getManual(args, { "jalloo_brattagh" }) if manual then if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P41 = flag image. return getWikidataImage("P41") end ------------------------------------------------------------ -- Coat of arms ------------------------------------------------------------ local function getArms(args) -- Manual value takes precedence over Wikidata. -- jalloo_armys is the preferred new parameter. -- jalloo_cleinney and jalloo_cowrey remain supported -- for compatibility with existing articles. local manual = getManual(args, { "jalloo_armys", "jalloo_cleinney", "jalloo_cowrey" }) if manual then -- Explicitly suppress Wikidata. if mw.ustring.lower(manual) == "none" then return false end return manual end -- Wikidata P94 = coat of arms image. return getWikidataImage("P94") end ------------------------------------------------------------ -- Country name ------------------------------------------------------------ local function getCountryName(args) return args.ennym_gienneydagh or args.kianglaghey_ennym or args.ennym or mw.title.getCurrentTitle().text end local function getGenitiveName(args) local name = getCountryName(args) return enmynCheerey.genitive(name) end ------------------------------------------------------------ -- Official name (Wikidata P1448) ------------------------------------------------------------ local function getOfficialNames() local entity = mw.wikibase.getEntityObject() if not entity then return {} end local statements = entity:getBestStatements("P1448") if not statements or #statements == 0 then return {} end local names = {} for _, statement in ipairs(statements) do local mainsnak = statement.mainsnak if mainsnak and mainsnak.snaktype == "value" and mainsnak.datavalue and mainsnak.datavalue.type == "monolingualtext" then local value = mainsnak.datavalue.value if value and value.text and value.text ~= "" and value.language and value.language ~= "" then table.insert(names, { text = value.text, lang = mw.ustring.lower(value.language) }) end end end return names end ------------------------------------------------------------ -- Language name ------------------------------------------------------------ local function getLanguageName(code) if not code or code == "" then return code end code = mw.ustring.lower(code) -- Manx Wikipedia language-name override. if langOverrideTable and langOverrideTable[code] then local name = langOverrideTable[code] if type(name) == "table" then return name[1] end return name end -- Standard language-name table. if langNameTable and langNameTable[code] then local name = langNameTable[code] if type(name) == "table" then return name[1] end return name end return code end ------------------------------------------------------------ -- Language label ------------------------------------------------------------ local function makeLanguageLabel(code) local languageName = getLanguageName(code) if not languageName or languageName == "" then return "" end -- The language name is deliberately NOT italicised. return mw.text.tag( "small", {}, "([[" .. languageName .. "|" .. languageName .. "]])" ) end ------------------------------------------------------------ -- Country title ------------------------------------------------------------ function p.title(frame) local args = getArgs(frame) local countryName = getCountryName(args) local officialNames = getOfficialNames() local manxName = nil local otherNames = {} -- Find the Manx official name first. for _, item in ipairs(officialNames) do if item.lang == "gv" then manxName = item.text break end end -- If Wikidata has no Manx P1448, use the short Manx country name. if not manxName then manxName = countryName end local output = {} -- Manx country name. -- Explicitly set the font and weight rather than inheriting -- the styling of the Infobox "above" field. table.insert( output, '<span style="font-family:inherit; font-weight:bold;">' .. manxName .. '</span>' ) -- Other official-language names. -- These must explicitly be normal weight. for _, item in ipairs(officialNames) do if item.lang ~= "gv" then local languageLabel = makeLanguageLabel(item.lang) local line = '<span style="font-weight:normal;">' .. item.text if languageLabel ~= "" then line = line .. " " .. languageLabel end line = line .. "</span>" table.insert(output, line) end end return table.concat(output, "<br>") end ------------------------------------------------------------ -- Images ------------------------------------------------------------ function p.images(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</td>' .. '<td style="width:42%%; text-align:center; vertical-align:middle;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</td>' .. '</tr></table>', flag, arms, args.lheead_cowrey or "85px" ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|125px|border|alt=Brattagh]]' .. '</div>', flag ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '[[Coadan:%s|%s|alt=Armys]]' .. '</div>', arms, args.lheead_cowrey or "85px" ) end ------------------------------------------------------------ -- Captions ------------------------------------------------------------ function p.captions(frame) local args = getArgs(frame) local flag = getFlag(args) local arms = getArms(args) -- No flag and no coat of arms. if not flag and not arms then return "" end local countryName = getCountryName(args) local genitiveName = getGenitiveName(args) local flagCaption = args["fo-heidyl_brattagh"] or "Brattagh" local armsCaption = args["sorçh_cowrey"] or "Armys" local armsArticle = args["art_sorçh_cowrey"] or "Armys" -- Both flag and coat of arms. if flag and arms then return string.format( '<table style="width:100%%; background:none; border:0;"><tr>' .. '<td style="width:58%%; text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</td>' .. '<td style="width:42%%; text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</td>' .. '</tr></table>', genitiveName, flagCaption, armsArticle, genitiveName, armsCaption ) end -- Flag only. if flag then return string.format( '<div style="text-align:center;">' .. '<small>[[Brattagh %s|%s]]</small>' .. '</div>', genitiveName, flagCaption ) end -- Coat of arms only. return string.format( '<div style="text-align:center;">' .. '<small>[[%s %s|%s]]</small>' .. '</div>', armsArticle, genitiveName, armsCaption ) end return p 46fo26biufexkge72slx1u6bzsw5jup Module:Enmyn çheerey 828 55828 392776 2026-09-04T15:12:21Z MacTire02 219 Duillag crooit lesh: local p = {} -- Enmyn çheerey as ny lhiegganyn gienneydagh oc. -- Cur lhimmaghyn ayns shoh my vel feme orroo. local genitive = { ["Bretyn"] = "Vretyn", ["Yn Chanadey"] = "y Chanadey", ["Finnlynn"] = "Innlynn", ["Yn Ghermaan"] = "y Ghermaan", ["Greenlynn"] = "Ghreenlynn", ["Yn Iddaal"] = "yn Iddaal", ["Jersee"] = "Jersee", ["Nalbin"] = "ny h-Albey", ["Nerin"] = "Nerin", ["Mannin"] = "Vannin", ["Meksico"] = "Veksico", ["Yn Ookraan"] = "yn Ookraan", ["Yn Pho... 392776 Scribunto text/plain local p = {} -- Enmyn çheerey as ny lhiegganyn gienneydagh oc. -- Cur lhimmaghyn ayns shoh my vel feme orroo. local genitive = { ["Bretyn"] = "Vretyn", ["Yn Chanadey"] = "y Chanadey", ["Finnlynn"] = "Innlynn", ["Yn Ghermaan"] = "y Ghermaan", ["Greenlynn"] = "Ghreenlynn", ["Yn Iddaal"] = "yn Iddaal", ["Jersee"] = "Jersee", ["Nalbin"] = "ny h-Albey", ["Nerin"] = "Nerin", ["Mannin"] = "Vannin", ["Meksico"] = "Veksico", ["Yn Ookraan"] = "yn Ookraan", ["Yn Pholynn"] = "y Pholynn", ["Yn Phortiugal"] = "y Phortiugal", ["Yn Rank"] = "y Rank", ["Yn Reeriaght Unnaneysit"] = "y Reeriaght Unnaneysit", ["Yn Serb"] = "y Terb", ["Sostyn"] = "Hostyn", ["Yn Spaainey"] = "y Spaainey", ["Ny Steatyn Unnaneysit"] = "ny Steatyn Unnaneysit", } function p.genitive(name) if not name or name == "" then return name end return genitive[name] or name end function p.name(name) return name end return p jvo7mufm30o3d3zg5csnnlywx2idzsb 392778 392776 2026-09-04T16:13:50Z MacTire02 219 ++ 392778 Scribunto text/plain local p = {} -- Enmyn çheerey as ny lhiegganyn gienneydagh oc. -- Cur lhimmaghyn ayns shoh my vel feme orroo. local country_names = { ["Bretyn"] = "Bretyn", ["Yn Chanadey"] = "Yn Chanadey", ["Finnlynn"] = "Finnlynn", ["Yn Ghermaan"] = "Yn Ghermaan", ["Greenlynn"] = "Greenlynn", ["Yn Iddaal"] = "Yn Iddaal", ["Jersee"] = "Jersee", ["Nalbin"] = "Nalbin", ["Nerin"] = "Nerin", ["Mannin"] = "Mannin", ["Meksico"] = "Meksico", ["Yn Ookraan"] = "Yn Ookraan", ["Yn Pholynn"] = "Yn Pholynn", ["Yn Phortiugal"] = "Yn Phortiugal", ["Yn Rank"] = "Yn Rank", ["Yn Reeriaght Unnaneysit"] = "Yn Reeriaght Unnaneysit", ["Yn Serb"] = "Yn Serb", ["Sostyn"] = "Sostyn", ["Yn Spaainey"] = "Yn Spaainey", ["Ny Steatyn Unnaneysit"] = "Ny Steatyn Unnaneysit", } local genitive = { ["Bretyn"] = "Vretyn", ["Yn Chanadey"] = "y Chanadey", ["Finnlynn"] = "Innlynn", ["Yn Ghermaan"] = "y Ghermaan", ["Greenlynn"] = "Ghreenlynn", ["Yn Iddaal"] = "yn Iddaal", ["Jersee"] = "Jersee", ["Nalbin"] = "ny h-Albey", ["Nerin"] = "Nerin", ["Mannin"] = "Vannin", ["Meksico"] = "Veksico", ["Yn Ookraan"] = "yn Ookraan", ["Yn Pholynn"] = "y Pholynn", ["Yn Phortiugal"] = "y Phortiugal", ["Yn Rank"] = "y Rank", ["Yn Reeriaght Unnaneysit"] = "y Reeriaght Unnaneysit", ["Yn Serb"] = "y Terb", ["Sostyn"] = "Hostyn", ["Yn Spaainey"] = "y Spaainey", ["Ny Steatyn Unnaneysit"] = "ny Steatyn Unnaneysit", } function p.name(name) if not name or name == "" then return name end return country_names[name] or name end function p.genitive(name) if not name or name == "" then return name end return genitive[name] or name end return p g3lpwvh1u41o3ajrlpz19rwph6gu19a