Wiktionary siwiktionary https://si.wiktionary.org/wiki/%E0%B7%80%E0%B7%92%E0%B6%9A%E0%B7%8A%E0%B7%82%E0%B6%B1%E0%B6%BB%E0%B7%92:%E0%B6%B8%E0%B7%94%E0%B6%BD%E0%B7%8A_%E0%B6%B4%E0%B7%92%E0%B6%A7%E0%B7%94%E0%B7%80 MediaWiki 1.48.0-wmf.5 case-sensitive මාධ්‍යය විශේෂ සාකච්ඡාව පරිශීලක පරිශීලක සාකච්ඡාව වික්ෂනරි වික්ෂනරි සාකච්ඡාව ගොනුව ගොනුව සාකච්ඡාව මාධ්‍යවිකි මාධ්‍යවිකි සාකච්ඡාව සැකිල්ල සැකිලි සාකච්ඡාව උදවු උදවු සාකච්ඡාව ප්‍රවර්ගය ප්‍රවර්ග සාකච්ඡාව TimedText TimedText talk Module Module talk Event Event talk Module:category tree/entry maintenance 828 6010 239378 234097 2026-09-08T20:13:55Z en>Benwing2 0 add a couple of missing taxonomic types 239378 Scribunto text/plain local labels = {} local raw_categories = {} local raw_handlers = {} local functions_module = "Module:fun" local languages_module = "Module:languages" local scripts_module = "Module:scripts" local string_pattern_escape_module = "Module:string/patternEscape" local string_replacement_escape_module = "Module:string/replacementEscape" local table_module = "Module:table" local extend = require(table_module).extend local is_callable = require(functions_module).is_callable local pattern_escape = require(string_pattern_escape_module) local replacement_escape = require(string_replacement_escape_module) local unpack = unpack or table.unpack -- Lua 5.2 compatibility ----------------------------------------------------------------------------- -- -- -- LABELS -- -- -- ----------------------------------------------------------------------------- labels["entry maintenance"] = { description = "{{{langname}}} entries, or entries in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {{name = "{{{langcat}}}", raw = true}}, breadcrumb_base = "entry maintenance", -- so the word 'maintenance' doesn't get chopped off umbrella_parents = {name = "Entry maintenance", sort = " "}, } labels["etymology maintenance"] = { description = "{{{langname}}} etymology sections, or etymology sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"entry maintenance"}, umbrella_parents = {name = "Etymology maintenance", sort = " "}, } labels["link maintenance"] = { description = "{{{langname}}} entries with internal links, or entries in other languages containing internal links to {{{langname}}} terms, that are being tracked for attention and improvement.", additional = "Internal links are those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"entry maintenance"}, umbrella_parents = {name = "Link maintenance", sort = " "}, } labels["pronunciation maintenance"] = { description = "{{{langname}}} pronunciation sections, or pronunciation sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"entry maintenance"}, umbrella_parents = {name = "Pronunciation maintenance", sort = " "}, } labels["entries with incorrect language header"] = { description = "{{{langname}}} entries that have been placed under the wrong language header.", additional = "This can happen for several reasons:\n" .. "* Typos.\n" .. "* Vandalism.\n" .. "* Using the wrong language code.\n" .. "* Using an alternative name for the language.\n" .. "* Using special characters which haven't been used in the name given in the language data modules.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["entries without References header"] = { description = "{{{langname}}} entries without a References header.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["entries without References or Further reading header"] = { description = "{{{langname}}} entries without a References or Further reading header.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["entries that don't exist"] = { description = "{{{langname}}} terms that do not meet the [[Wiktionary:Criteria for inclusion|criteria for inclusion]] (CFI). They are added to the category with the template {{tl|no entry|{{{langcode}}}}}.", parents = {"entry maintenance"}, umbrella_parents = "Fundamental", } labels["entries with etymology trees"] = { description = "{{{langname}}} entries that display an etymology tree generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology texts"] = { description = "{{{langname}}} entries that display an etymology generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymon"] = { description = "{{{langname}}} entries that use the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology text stop language not in chain"] = { description = "{{{langname}}} entries where {{tl|etymon}} is used with {{para|text}} set to stop at a language but that language never appears in the rendered etymology chain.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon that cannot be found, either because the target page does not exist (redlink) or because it has no {{tl|etymon}} template.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing ambiguous etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon without the ID, when the target page contains multiple {{tl|etymon}} templates, and an ID is therefore required to select the correct {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons with mismatched IDs"] = { description = "Entries which use the {{tl|etymon}} template with a mismatched ID. For example, {{code|lang:entry<id:mismatched ID>}}", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with multiple etymons missing IDs"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one {{tl|etymon}} template for the same language, where at least one of those templates has no {{para|id}}. When several {{tl|etymon}} templates share a language section, each must have a distinct {{para|id}} so that links and descendants logic can tell them apart.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with etymology sections missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one etymology section for the same language, where at least one section contains a {{tl|etymon}} template for that language and at least one other etymology section does not.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has no Descendants section.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without this term in Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has a Descendants section, but does not list the current term there.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with language name categories using raw markup"] = { description = "{{{langname}}} entries that have been placed in a language name category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langname}}} ...]]}}). They should be added using {{tl|cln|{{{langcode}}}|...}} instead.", parents = {"entry maintenance"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["entries with topic categories using raw markup"] = { description = "{{{langname}}} entries that have been placed in a topic category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langcode}}}:...]]}}). They should be added using {{tl|C|{{{langcode}}}|...}} instead.", parents = {"entry maintenance"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["entries with outdated source"] = { description = "{{{langname}}} entries that have been partly or fully imported from an outdated source.", parents = {"entry maintenance"}, } labels["entries with inflection not matching pagename"] = { description = "{{{langname}}} entries which have an inflection table whose lemma form does not match the page name.", additional = "This is usually the result of incorrect or missing parameters.", parents = {"entry maintenance"}, hidden = true, can_be_empty = true, } labels["undefined derivations"] = { description = "{{{langname}}} etymologies using {{tl|undefined derivation}}, where a more specific template such as {{tl|borrowed}} or {{tl|inherited}} should be used instead.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["descendants to be fixed in desctree"] = { description = "Entries that use {{tl|desctree}} to link to {{{langname}}} entries with no Descendants section.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["term requests"] = { description = "Entries with {{tl|der}}, {{tl|inh}}, {{tl|m}} and similar templates lacking the parameter for linking to {{{langname}}} terms.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["redlinks"] = { description = "Links to {{{langname}}} entries that have not been created yet.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", catfix = false, can_be_empty = true, hidden = true, } labels["terms with IPA pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of IPA.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with enPR pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of enPR.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with Indic pronunciation"] = { description = "{{langname}} terms that include the pronunciation in the form of ISO 15919.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["IPA pronunciations with invalid separators"] = { description = "{{{langname}}} terms with IPA using invalid separators such as /.ˈ/, /.ˌ/, a dot followed by primary or secondary stress; or /ˈ / or /ˌ /, primary or secondary stress followed by a space.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["terms with hyphenation"] = { description = "{{{langname}}} terms that include hyphenation.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with audio pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of an audio file.", additional = "For requests related to this category, see [[:Category:Requests for audio pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with nonstandard or incorrect audio pronunciations"] = { description = "{{{langname}}} terms which have been tagged as having audio pronunciations which are nonstandard or incorrect.", parents = {"terms with audio pronunciation"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["entries missing Template:reconstructed"] = { description = "Reconstructed {{{langname}}} entries which do not have the {{tl|reconstructed}} template.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } local function add_manual_param_category(label, desc, addl_intro, include_addl_continuation) local breadcrumb_base, parents, umbrella_parents if label:find("^links") then parents = {"link maintenance"} umbrella_parents = "Link maintenance" breadcrumb_base = label:gsub("^links with ", "") else parents = {"entry maintenance"} -- the call to finalize_labels() farther down will set the right breadcrumb, sortkey and umbrella_parents. end labels[label] = { description = desc or "Pages containing {{{langname}}} " .. label .. ".", additional = addl_intro .. (not include_addl_continuation and "" or "\n\n" .. "Note that the pages in this category are not necessarily the same as the actual term in question. This " .. "frequently happens, for example, with English pages with translation sections, where the term that " .. "triggers the addition of the category is one of the translations."), parents = parents, breadcrumb_base = breadcrumb_base, umbrella_parents = umbrella_parents, -- Set catfix = false because the page will have a mixture of native-language and -- non-native-language pages, but include the normal native-language table of contents headers -- because most pages are in the native language. catfix = false, toc_template = "{{{langcode}}}-categoryTOC", toc_template_full = "{{{langcode}}}-categoryTOC/full", can_be_empty = true, hidden = true, } end add_manual_param_category("terms in nonstandard scripts", nil, "Pages are placed here if they contain terms written in a script that isn't in the language's " .. "list of scripts in the language data. This may mean the script should be added to the list, or that the wrong language code has been used.", true) add_manual_param_category("terms with non-redundant manual transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is different from the transliteration which is automatically generated.", true) add_manual_param_category("terms with redundant transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is the same as the transliteration which is automatically generated.", true) add_manual_param_category("terms with non-redundant manual script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is different from the script code which is automatically generated.", true) add_manual_param_category("terms with redundant script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is the same as the script code which is automatically generated.", true) add_manual_param_category("terms with non-redundant non-automated sortkeys", "{{{langname}}} terms with non-redundant non-automated sortkeys.", "Terms are placed here if they have been sorted using a sortkey other than the one which is automatically " .. "generated. This can happen for two reasons:\n# A different sortkey has been specified using the {{para|sort}} " .. "parameter.\n# One or more categories have been added using raw wikitext, which means the page's default " .. "sortkey is used for that category. If that default sortkey is different from the automatic sortkey, then the " .. "page will also be added here.") add_manual_param_category("terms with redundant sortkeys", "{{{langname}}} terms with redundant sortkeys.", "Terms are placed here if their sortkey has been specified using the {{para|sort}} parameter, and it the same " .. "as the one which is automatically generated.") add_manual_param_category("links with redundant target parameters", "Pages containing {{{langname}}} links where the alt text could replace the link target, instead of being given " .. "separately.", "This occurs when the only difference between the link target and the alt text is that the alt text contains " .. "diacritics (or other characters) which would have been ignored anyway had they been included in the link " .. "target. For example, {{tl|l|la|amo|amō}} ({{l|la|amo|amō}}) is exactly the same as {{tl|l|la|amō}} " .. "({{l|la|amō}}), because macrons are automatically stripped from Latin link targets, even though they're still " .. "displayed.") add_manual_param_category("links with ignored alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("links with redundant alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter is redundant.", "This occurs when the alt text makes no difference to the output. For example, {{tl|l|en|foo|foo}} " .. "({{l|en|foo|foo}}) is exactly the same as {{tl|l|en|foo}} ({{l|en|foo}}).") add_manual_param_category("links with ignored id parameters", "Pages containing {{{langname}}} links where the {{para|id}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("links with redundant wikilinks", "Pages containing {{{langname}}} links which contain a redundant wikilink.", "This occurs if link target consists of a single wikilink, which should instead be entered in the " .. "conventional manner without link brackets. For example, {{tl|l|en|<nowiki>[[foo]]</nowiki>}} " .. "is the same as {{tl|l|en|foo}}, and {{tl|l|en|<nowiki>[[foo|bar]]</nowiki>}} is the same as " .. "{{tl|l|en|foo|bar}}.\n\nThis also occurs when link templates are nested inside each other " .. "unnecessarily: e.g. {{tl|l|en|{{tl|l|en|foo}}}}") add_manual_param_category("links with manual fragments", "Pages containing {{{langname}}} links where a manual link fragment has been given.", "This occurs when the link fragment has been specified using {{code|#}} after the term, " .. "which overrides the normal fragment generated by link templates that points to the relevant " .. "language section.\n\nLink fragments are used to point to a specific section on a target page, and " .. "it is preferable to use the {{para|id}} parameter to do this, since it is less likely to break if " .. "additional content is added to the target page: for example, the fragment {{code|#Adjective}} " .. "will start pointing to the wrong section if another language with an adjective section is added above " .. "the intended language.") labels["descendant hubs"] = { description = "{{{langname}}} terms that do not mean more than the sum of their parts but exist for listing two or more inclusion-worthy descendants.", parents = {"entry maintenance"}, } labels["terms needing to be assigned to a sense"] = { description = "{{{langname}}} entries that have terms under headers such as \"Synonyms\" or \"Antonyms\" not assigned to a specific sense of the entry in which they appear. Use [[Template:syn]] or [[Template:ant]] to fix these.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } --[=[ labels["terms with inflection tables"] = { description = "{{{langname}}} entries that contain inflection tables.". additional = "For requests related to this category," see [[:Category:Requests for inflections in {{{langname}}} entries]].", parents = {"entry maintenance"}, } ]=] local function generate_category_with_illustrations(typ, link, example_templates, other_types_in_group) local function make_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss in {{{langname}}}]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end local function make_umbrella_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss by language]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end labels[("terms with %ss"):format(typ)] = { description = ("{{{langname}}} entries that contain %s that were added using templates such as %s."):format(link, example_templates), additional = ("For requests related to this category, see [[:Category:Requests for %ss in {{{langname}}}]]. See also %s."):format( typ, make_other_request_cats()), parents = {"entry maintenance"}, umbrella = { additional = ("For requests related to this category, see [[:Category:Requests for %ss by language]]. See also %s."):format( typ, make_umbrella_other_request_cats()), }, umbrella_parents = ("%s maintenance"):format(mw.getContentLanguage():ucfirst(typ)), } end local function generate_related_categories_with_illustrations(info) for typ, spec in pairs(info) do local other_types = {} for other_type, _ in pairs(info) do if other_type ~= typ then table.insert(other_types, other_type) end end table.sort(other_types) generate_category_with_illustrations(typ, spec.link, spec.example_templates, other_types) end end generate_related_categories_with_illustrations { collocation = { link = "[[collocation]]s", example_templates = "{{tl|co}}", }, ["usage example"] = { link = "[[usage]] [[example]]s", example_templates = "{{tl|ux}}", }, quotation = { link = "[[quotation]]s", example_templates = "{{tl|quote}}, {{tl|quote-book}}, {{tl|quote-journal}}, etc", }, } labels["terms with interlinear glossed text"] = { description = "{{{langname}}} entries that contain interlinear glossed text added using {{tl|interlinear}}.", parents = {"entry maintenance"}, } labels["terms with redundant head parameter"] = { description = "{{{langname}}} terms that contain a redundant head= parameter in their headword (called using {{tl|head}} or a language-specific equivalent).", additional = "Individual languages can prevent terms from being added to this category by setting `data.no_redundant_head_cat`.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["terms with red links in their headword lines"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"redlinks"}, breadcrumb_base = "headword lines", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["terms with red links in their inflection tables"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"redlinks"}, breadcrumb_base = "inflection tables", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } for _, quot_type in ipairs { "quotations", "usage examples" } do local umbrella_parent = quot_type == "quotations" and "Quotation maintenance" or "Usage example maintenance" labels[quot_type .. " with omitted translation"] = { description = "{{{langname}}} " .. quot_type .. " where a translation would normally be required but the translation has explicitly been omitted by specifying {{code|-}}. The translation should be supplied instead.", parents = {"entry maintenance"}, umbrella = { parents = {name = umbrella_parent, sort = "omitted translation"}, breadcrumb = "with omitted translation", }, can_be_empty = true, hidden = true, } end for _, pos in ipairs({"nouns", "proper nouns", "verbs", "adjectives", "adverbs", "participles", "determiners", "pronouns", "numerals", "suffixes", "contractions"}) do labels[pos .. " with red links in their headword lines"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"terms with red links in their headword lines"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels[pos .. " with red links in their inflection tables"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"terms with red links in their inflection tables"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } end for _, pos in ipairs { "nouns", "proper nouns", "pronouns" } do local label = pos .. " with unknown or uncertain plurals" labels[label] = { description = "{{{langname}}} " .. label .. ".", additional = "Terms are usually added to this category by specifying {{code|?}} as the plural. As much " .. "is possible, a plural should be added or, if the noun is uncountable, indicated appropriately (usually " .. "using {{code|-}} in place of the plural). Some languages support the value {{code|!}} to indicate " .. "that a plural cannot be attested but the noun is theoretically countable.", parents = {pos, "entry maintenance"}, } end -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_labels(labels, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in"}, default_umbrella_parents = "Entry maintenance subcategories by language", }) ----------------------------------------------------------------------------- -- -- -- RAW CATEGORIES -- -- -- ----------------------------------------------------------------------------- raw_categories["Entry maintenance subcategories by language"] = { description = "Umbrella categories covering topics related to entry maintenance.", additional = "{{{umbrella_meta_msg}}}", parents = { "Umbrella metacategories", {name = "entry maintenance", is_label = true, sort = " "}, {name = "Entry maintenance", sort = " "}, }, } raw_categories["Citation maintenance"] = { description = "Categories for maintaining citations specified using {{tl|cite-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Collocation maintenance"] = { description = "Categories for maintaining collocations specified using {{tl|co}}, {{tl|coi}} or {{tl|coa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Link maintenance"] = { description = "Categories for maintaining internal links, such as those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Pronunciation maintenance"] = { description = "Categories for maintaining pronunciations specified in pronunciation sections.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Quotation maintenance"] = { description = "Categories for maintaining quotations specified using {{tl|quote-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Usage example maintenance"] = { description = "Categories for maintaining usage examples specified using {{tl|ux}}, {{tl|uxi}} or {{tl|uxa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Citations using nocat parameter"] = { description = "Instances of {{tl|cite-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Citation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotation templates to be cleaned"] = { description = "Instances of quotations using {{tl|quote-text}}.", additional = "They should be converted to other '''[[:Category:Citation templates|quotation templates]]''' if relevant.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using nocat parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using quoted-in parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|quoted_in}} parameter.", additional = "It is recommended to restructure these template calls using the {{para|newversion}} parameter along with associated parameters {{para|2ndauthor}}, {{para|title2}}, {{para|year2}}, {{para|publisher2}} and the like, as described in the documentation for {{tl|quote-book}}.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Requests"] = { topright = "{{shortcut|WT:CR|WT:RQ}}", description = "A parent category for the various request categories.", parents = {"Category:Wiktionary"}, } raw_categories["Requests by language"] = { description = "Categories with requests in various specific languages.", additional = "{{{umbrella_msg}}}", parents = { {name = "Request subcategories by language", sort = " "}, {name = "Requests", sort = " "}, }, breadcrumb = "by language", } raw_categories["Request subcategories by language"] = { description = "Umbrella categories covering topics related to requests.", additional = "{{{umbrella_meta_msg}}}", parents = { "Umbrella metacategories", {name = "Requests", sort = " "}, }, } raw_categories["Requests for quotations by source"] = { description = "Categories with requests for quotation, broken out by the source of the quotation.", additional = "Some abbreviated names of sources are explained at [[Wiktionary:Abbreviated Authorities in Webster]].", parents = {"Requests for quotations"}, } raw_categories["Requests for quotations"] = { -- FIXME description = "Words are added to this category by the inclusion in their entries of {{tl|rfv-quote}}.", parents = {"Requests", "Quotation maintenance"}, } raw_categories["Requests for date"] = { description = "Requests for a date to be added to a quotation.", additional = "To add an article to this category, use {{tl|rfdate}} or {{tl|rfdatek}} to include the author. " .. "Please remove the template from the article once the date has been provided.", parents = {"Requests", "Quotation maintenance"}, } raw_categories["Requests for translations in user-competency categories by number of users"] = { description = "Requests for translations to be added to user-competency categories, sorted by number of users with that competency.", parents = {"Requests"}, } raw_categories["Requests for translations in user-competency categories by language"] = { description = "Requests for translations to be added to user-competency categories, sorted by language.", parents = {"Requests"}, hidden = true, } raw_categories["Terms with translations by language"] = { description = "Terms with translations, sorted by language.", parents = {"Entry maintenance subcategories by language"}, breadcrumb_base = "translations", } raw_categories["Entries using missing taxonomic names"] = { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name." .. "\n\nSee [[:Category:mul:Taxonomic names]].", parents = {{name = "entry maintenance", is_label = true, lang = "mul"}}, breadcrumb_base = "missing taxonomic names", hidden = true, } raw_categories["Entries with collapsible category lists for nonexistent categories"] = { description = "Entries where [[Module:collapsible category list]] is used, but the requested category does not exist.", additional = "Normally the culprit is a template like {{tl|prefixsee}} or {{tl|suffixsee}}.", parents = {"Entry maintenance", "Category maintenance"}, hidden = true, } -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_raw_categories(raw_categories, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "requests for", "citations", "quotations", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in", "by", "using"}, }) ----------------------------------------------------------------------------- -- -- -- RAW HANDLERS -- -- -- ----------------------------------------------------------------------------- local function script_name_to_code(name) local sc = require(scripts_module).getByCanonicalName(name) if not sc then error("Unrecognized script name '" .. name .. "'") end return sc:getCode() end --[=[ This array consists of category match specs. Each spec contains one or more properties, whose values are (a) strings that may contain references to other properties using the {{{PROPERTY}}} syntax; (b) functions of one argument, an `items` table of the same properties that are accessible using the {{{PROPERTY}} syntax. Each such spec should have at least a `regex` property that matches the name of the category. Capturing groups in this regex can be referenced in other properties using {{{1}}} for the first group, {{{2}}} for the second group, etc. (or using keys "1", "2", etc. in functions). Property expansion happens recursively if needed (i.e. a property can reference another property, which in turn references a third property). If there is a `language_name` propery, it specifies the language name (and will typically be a reference to a capturing group from the `regex` property); if not specified, it defaults to "{{{1}}}" unless the `nolang` property is set, in which case there is no language name associated with the category name. The language name must be the canonical name of a recognized full language, or an error is thrown; however, if the `allow_etym_lang` property is set, the language name may also be the canonical name of an etymology-only language. Based on the language name, the `language_code` and `language_object` properties are automatically filled in. If `language_name` is an etymology-only language, additional properties `parent_language_name`, `parent_language_code` and `parent_language_object` are set for the parent full language of the etymology-only language. If the `regex` values of multiple category specs match, the first one takes precedence. Recognized or predefined properties: `pagename`: Current pagename. `regex`: See above. `1`, `2`, `3`, ...: See above. `language_name`, `language_code`, `language_object`: See above. `parent_language_name`, `parent_language_code`, `parent_language_object`: See above. `nolang`: See above. `allow_etym_lang`: Language names may be etymology-only languages. See above. `description`: Override the description (normally taken directly from the pagename). `template_name`: Name of template which generates this category. `template_sample_call`: Syntax for calling the template. Defaults to "{{{template_name}}}|{{{language_code}}}". Used to display an example template call and the output of this call. `template_actual_sample_call`: Syntax for calling the template. Takes precedence over `template_sample_call` when generating example template output (but not when displaying an example template call) and is intended for a template call that uses the |nocat=1 parameter. `template_example_output`: Override the text that displays example template output (see `template_sample_call`). `additional_template_description`: Extra text to be displayed after the example template output. `parents`: Parent categories. Should be a list of elements, each of which is an object containing at least a name= and sort= field (same format as parents= for regular raw categories, except that the name= and sort= field will have {{{PROPERTY}}} references expanded). If no parents are specified, and the pagename is of the form "Requests for FOO by language", the parents will be "Request subcategories by language" with FOO as the sort key, along with any parents specified in `additional_umbrella_parents`. Otherwise, the `language_name` property must exist, and the parent will be "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key, along with any parents specified in `additional_parents`. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_parents` is used instead. `additional_parents`: Additional parents to add to the per-language category along with "Requests concerning LANGNAME". `etym_parents`: Parent categories for categories with associated etymology-only languages. The format is the same as `parents`. If omitted, there are two parents by default: (1) The pagename (i.e. category name) with the language name replaced by the corresponding parent language name, with the value of `language_name` as the sort key; (2) "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key. `umbrella`: Parent all-language category. Sort key is based on the language name. This applies *ONLY* if a full language is associated with the category name (i.e. not if `nolang` is set or if `allow_etym_lang` is set and the associated language is an etymology-only language); otherwise there will be no umbrella category. `additional_umbrella_parents`: Additional parents to add to the umbrella (all-language) category along with "Request subcategories by language". `breadcrumb`: Specify the breadcrumb. If `parents` is given, there is no default (i.e. it will end up being the pagename). Otherwise, if the pagename is of the form "Requests for FOO by language", the default breadcrumb will be "FOO". Otherwise it is computed by removing the language name from the pagename and chopping out "Requests for" from the beginning and "in entries" and "for terms" from the end. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_breadcrumb` is used instead. `etym_breadcrumb`: Specify the breadcrumb for categories with associated etymology-only languages. Defaults to the value of `language_name`. `not_hidden_category`: Don't hide the category. `catfix`: Same as `catfix` in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. `toc_template`, `toc_template_full`: Same as the corresponding fields in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. In general, properties can contain references to templates (e.g. {{tl}} and {{para}}), which will be appropriately expanded (this expansion happens in the poscatboiler code, not in this module). The major exception is in the `template_sample_call` and `template_actual_sample_call` properties, which are surrounded by <pre>...</pre> when inserted, so template references are not expanded. Triple-brace property references are still expanded in these properties; but beware that if any of those property references contain template references, they won't be expanded. (This actually happens in the handlers for 'Request for SCRIPT script for LANG terms'; the sample call references {{{script_code}}}, whose definition therefore cannot contain template references. The solution is to define this property using a function.) ]=] local requests_categories = { { regex = "^Requests concerning (.+)$", allow_etym_lang = true, description = "Categories with {{{1}}} entries that need the attention of experienced editors.", parents = {{name = "entry maintenance", is_label = true, sort = "requests"}}, etym_parents = {{name = "Requests concerning {{{parent_language_name}}}", sort = "{{{1}}}"}, {name = "{{{1}}}", sort = "Requests"}}, umbrella = "Requests by language", breadcrumb = "Requests", not_hidden_category = true, }, { regex = "^Requests for etymologies in (.+) entries$", allow_etym_lang = true, umbrella = "Requests for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "rfe", }, { regex = "^Requests for expansion of etymologies in (.+) entries$", umbrella = "Requests for expansion of etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "etystub", }, { regex = "^Requests for pronunciation in (.+) entries$", umbrella = "Requests for pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfp", }, { regex = "^Requests for audio pronunciation in (.+) entries$", umbrella = "Requests for audio pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfap", }, { regex = "^Requests for definitions in (.+) entries$", umbrella = "Requests for definitions by language", template_name = "rfdef", }, { regex = "^Requests for clarification of definitions in (.+) entries$", umbrella = "Requests for clarification of definitions by language", template_name = "rfclarify", }, { regex = "^Requests for English equivalent terms in (.+) entries$", umbrella = "Requests for English equivalent terms by language", template_name = "rfeq", }, } for _, spec_with_pos in ipairs { {"inflections", "rfinfl"}, {"plural forms"}, {"tone", "rftone"}, {"accents"}, {"aspect", "rfaspect"}, {"animacy"}, {"gender", "rfgender"}, {"noun class"}, } do local property, rftemplate = unpack(spec_with_pos) table.insert(requests_categories, { -- This is for part-of-speech-specific categories such as -- "Requests for inflections in Northern Ndebele noun entries" or -- "Requests for accents in Ukrainian proper noun entries". -- Here and below, we assume that the part of speech is begins with -- a lowercase letter, while the preceding language name ends in a -- capitalized word. Note that this entry comes before the -- following one and takes precedence over it. regex = ("^Requests for %s in (.-) ([a-z]+[a-z ]*) entries$"):format(property), parents = {{name = ("Requests for %s in {{{language_name}}} entries"):format(property), sort = "{{{2}}}"}}, umbrella = ("Requests for %s of {{pluralize|{{{2}}}}} by language"):format(property), breadcrumb = "{{{2}}}", template_name = rftemplate, template_sample_call = rftemplate and ("{{%s|{{{language_code}}}|{{{2}}}}}"):format(rftemplate) or nil, } ) table.insert(requests_categories, { regex = ("^Requests for %s in (.+) entries$"):format(property), umbrella = ("Requests for %s by language"):format(property), template_name = rftemplate, } ) table.insert(requests_categories, { regex = ("^Requests for %s of (.+) by language$"):format(property), nolang = true, } ) end extend(requests_categories, { { regex = "^Requests for example sentences in (.+)$", umbrella = "Requests for example sentences by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfex", }, { regex = "^Requests for quotations in (.+)$", umbrella = "Requests for quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfquote", }, { regex = "^Requests for translations into (.+)$", allow_etym_lang = true, umbrella = "Requests for translations by language", template_name = "t-needed", catfix = "en", }, { regex = "^Requests for translations of (.+) usage examples$", allow_etym_lang = true, umbrella = "Requests for translations of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|usex}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|usex|nocat=1}}", additional_template_description = "The {{tl|ux}}, {{tl|uxi}}, {{tl|ja-usex}} and {{tl|zh-x}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for translations of (.+) quotations$", allow_etym_lang = true, umbrella = "Requests for translations of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|quote}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|quote|nocat=1}}", additional_template_description = "The {{tl|quote}}, and {{tl|Q}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for review of (.+) translations$", allow_etym_lang = true, umbrella = "Requests for review of translations by language", template_name = "t-check", template_sample_call = "{{t-check|{{{language_code}}}|example}}", template_example_output = "", catfix = "en", }, { regex = "^Requests for transliteration of (.+) terms$", umbrella = "Requests for transliteration by language", template_name = "rftranslit", additional_template_description = "The {{tl|head}} template, and the large number of language-specific variants of it, automatically add " .. "the page to this category if the example is in a foreign language and no transliteration can be generated (particularly in languages without " .. "automated transliteration, such as Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) usage examples$", umbrella = "Requests for transliteration of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rftranslit", template_sample_call = "{{rftranslit|{{{language_code}}}}}", template_actual_sample_call = "{{rftranslit|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) quotations$", umbrella = "Requests for transliteration of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for native script for (.+) terms$", allow_etym_lang = true, etym_parents = { {name = "Requests for native script for {{{parent_language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "native script"}, }, umbrella = "Requests for native script by language", template_name = "rfscript", template_actual_sample_call = "{{rfscript|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for native script in (.+) usage examples$", umbrella = "Requests for native script in usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|usex=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|usex=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example itself is missing but the translation is supplied." }, { regex = "^Requests for native script in (.+) quotations$", umbrella = "Requests for native script in quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|quote=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|quote=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation itself is missing but the translation is supplied." }, { regex = "^Requests for (.+) script for (.+) terms$", language_name = "{{{2}}}", allow_etym_lang = true, parents = {{name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}}, etym_parents = { {name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests for {{{1}}} script for {{{parent_language_name}}} terms", sort = "{{{language_name}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "{{{1}}} script"}, }, umbrella = "Requests for {{{1}}} script by language", breadcrumb = "{{{1}}}", etym_breadcrumb = "{{{1}}}", template_name = "rfscript", -- NOTE: The following is used in `template_sample_call` and `template_actual_sample_call`, meaning the -- conversion of script name to script code needs to be done using an inline function like this, instead of -- a {{#invoke:...}} template call. script_code = function(items) return script_name_to_code(items["1"]) end, template_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for (.+) script by language$", parents = {{name = "Requests for script by language", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, }, { regex = "^Requests for script by language$", nolang = true, }, { regex = "^Requests for images in (.+) entries$", umbrella = "Requests for images by language", template_name = "rfi", }, { regex = "^Requests for references for (.+) terms$", umbrella = "Requests for references by language", template_name = "rfref", }, { regex = "^Requests for references for etymologies in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "etymologies"}}, umbrella = "Requests for references for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, breadcrumb = "Etymologies", template_name = "rfv-etym", }, { regex = "^Requests for references for pronunciations in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "pronunciations"}}, umbrella = "Requests for references for pronunciations by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, breadcrumb = "Pronunciations", template_name = "rfv-pron", }, { regex = "^Requests for attention concerning (.+)$", umbrella = "Requests for attention by language", breadcrumb = "Attention", template_name = "attention", template_sample_call = "{{attention|{{{language_code}}}|insert a brief description of the request here}}", template_example_output = "This template does not generate any text in entries, but can be visualised by enabling the Catch My Attention gadget. See {{section link|Template:attention#Visibility}}.", -- These pages typically contain a mixture of English and native-language entries, so disable catfix. catfix = false, -- Setting catfix = false will normally trigger the English table of contents template. -- We still want the native-language table of contents template, though. toc_template = "{{{language_code}}}-categoryTOC", toc_template_full = "{{{language_code}}}-categoryTOC/full", }, { regex = "^Requests for cleanup in (.+) entries$", umbrella = "Requests for cleanup by language", template_name = "rfc", template_actual_sample_call = "{{rfc|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for cleanup of Pronunciation N headers in (.+) entries$", umbrella = "Requests for cleanup of Pronunciation N headers by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfc-pron-n", template_actual_sample_call = "{{rfc-pron-n|{{{language_code}}}|nocat=1}}", template_example_output = "This template does not generate any text in entries.", additional_template_description = [=[ The purpose of this category is to tag entries that use headers with "Pronunciation" and a number. While these headers and structure are sometimes used, they are not specifically prescribed by [[WT:ELE]]. No complete proposal has yet been made on how they should work, what the semantics are, or how they interact with multiple etymologies. As a result they should generally be avoided. Instead, merge the entries (possibly under multiple Etymology sections, if appropriate), and list all pronunciations, appropriately tagged, under a Pronunciation header. [[User:KassadBot|KassadBot]] tags these entries (or used to tag these entries, when the bot was operational). At some point if a proposal is made and adopted as policy, these entries should be reviewed. This category is hidden.]=], }, { regex = "^Requests for deletion in (.+) entries$", umbrella = "Requests for deletion by language", template_name = "rfd", template_actual_sample_call = "{{rfd|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for verification in (.+) entries$", umbrella = "Requests for verification by language", template_name = "rfv", }, { regex = "^Requests for attention in (.+) etymologies$", umbrella = "Requests for attention by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, }, { regex = "^Requests for quotations/(.+)$", description = "Requests for a quotation or for quotations from {{{1}}}.", parents = {{name = "Requests for quotations by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfquotek", template_sample_call = "{{rfquotek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfquotek|und|{{{1}}}}}", }, { regex = "^Requests for date in (.+) entries$", umbrella = "Requests for date by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfdate", additional_template_description = "The quotation templates, such as {{tl|quote-book}} and {{tl|quote-journal}}, " .. "automatically add the page to this category if neither {{para|date}} nor {{para|year}} is provided. Providing the " .. "parameter in each case on the page automatically removes the article from this category. See " .. "[[Wiktionary:Quotations]] for information about formatting dates and quotations.", }, { regex = "^Requests for date/(.+)$", description = "{{rfd|section=Category:Requests for date by source}}Requests for a date for a quotation or quotations from {{{1}}}.", parents = {{name = "Requests for date by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfdatek", template_sample_call = "{{rfdatek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfdatek|und|{{{1}}}}}", }, { regex = "^Requests for attestation of (.+) terms$", umbrella = "Requests for attestation of terms by language", breadcrumb = "Attestation", additional_template_description = "The {{tl|LDL}} template adds this category when a language code is supplied in {{para|1}} (as it should be)." }, }) local user_competency_additional_template_description = "This is added by user-competency categories such as " .. "[[:Category:User fr-4]], which groups users who speak French at level 4 (near-native proficiency), when " .. "the native-language text indicating this fact is missing. The appropriate translation should mirror the " .. "English text also displayed (e.g. in this case \"These users speak French at a '''near native''' " .. "level.\"), and should be supplied to {{tl|auto cat}} using the {{para|text}} parameter. The mention of the " .. "language in the text should be surrounded by double angle brackets, e.g. \"&lt;&lt;français>>\", which " .. "causes it to be automatically linked to the appropriate parent category." local user_competency_parents = {{name = "Requests for translations in user-competency categories by number of users", sort = function(items) return " " .. ("%010d"):format(items["1"]) end, }} extend(requests_categories, { { regex = "^Requests for translations in user%-competency categories with ([0-9]+)%-([0-9]+) users$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}}-{{{2}}} users.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}-{{{2}}}", nolang = true, }, { regex = "^Requests for translations in user%-competency categories with ([0-9]+) (users?)$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}} {{{2}}}.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}", nolang = true, } }) table.insert(raw_handlers, function(data) local items local function init_items() items = {pagename = data.category} end local function expand_value(item, val) if not val then return val elseif is_callable(val) then return expand_value(item .. " ⇒ function", val(items)) elseif type(val) == "table" then for k, v in pairs(val) do val[k] = expand_value(item .. " ⇒ " .. k, v) end return val elseif type(val) == "number" then val = tostring(val) end if type(val) ~= "string" then error(("The item '%s' on page %s is of type %s and can't be concatenated"):format( item, items.pagename, type(val))) end -- Replaces pseudo-template code {{{ }}} with the corresponding member of the "items" table. Has to be done -- recursively, since some of the items are nested: -- {{{template_sample_call_with_temp}}} -- ⇓ -- {{{{{template_name}}}|{{{language_code}}}}} -- ⇓ -- {{attention|en}} if val:find("{{{") then val = mw.ustring.gsub(val, "{{{([^%}%{]+)}}}", function(prop) local propval = items[prop] if not propval then error(("The item '%s' (expanded from property '%s' on page %s) was not found in the 'items' table"): format(prop, item, items.pagename)) end return expand_value(item .. " ⇒ " .. prop, propval) end ) end return val end local function expand_items_value(item) return expand_value(item, items[item]) end local function convert_items_to_category_data(items) if not items.nolang then items.language_name = items.language_name or "{{{1}}}" items.language_name = expand_items_value("language_name") items.language_object = require(languages_module).getByCanonicalName(items.language_name, true, items.allow_etym_lang) items.language_code = items.language_object:getCode() items.is_etym_lang = items.language_object:hasType("etymology-only") if items.is_etym_lang then items.parent_language_object = items.language_object:getFull() -- Reject weird cases where etymology language has no parent. if not items.parent_language_object then return nil end items.parent_language_code = items.parent_language_object:getCode() items.parent_language_name = items.parent_language_object:getCanonicalName() -- Reject weird cases where the parent language has the same name as the child etymology language. In -- that case, we'll get an infinite parent-category loop. This actually happens, e.g. with Rudbari and -- Bashkardi. if items.parent_language_name == items.language_name then return nil end else end end if items.template_name then items.template_sample_call = items.template_sample_call or "{{{{{template_name}}}|{{{language_code}}}}}" items.full_text_about_the_template = "To make this request, in this specific language, use this code in the entry (see also the documentation at [[Template:{{{template_name}}}]]):\n\n<pre>{{{template_sample_call}}}</pre>" if items.template_example_output then items.full_text_about_the_template = items.full_text_about_the_template .. " " .. items.template_example_output else items.template_actual_sample_call = items.template_actual_sample_call or items.template_sample_call items.full_text_about_the_template = items.full_text_about_the_template .. "\nIt results in the message below:\n\n{{{template_actual_sample_call}}}" end if items.additional_template_description then items.full_text_about_the_template = items.full_text_about_the_template .. "\n\n" .. items.additional_template_description end else items.full_text_about_the_template = items.additional_template_description end local parents, breadcrumb if items.is_etym_lang then parents = items.etym_parents breadcrumb = expand_items_value("etym_breadcrumb") or items.language_name else parents = items.parents breadcrumb = expand_items_value("breadcrumb") end if parents then for _, parent in ipairs(parents) do parent.name = expand_value("parent.name", parent.name) parent.sort = {sort_base = expand_value("parent.sort", parent.sort), lang = "en"} end else local umbrella_type = items.pagename:match("^Requests for (.+) by language$") if umbrella_type then breadcrumb = breadcrumb or umbrella_type parents = {{name = "Request subcategories by language", sort = umbrella_type}} if items.additional_umbrella_parents then extend(parents, items.additional_umbrella_parents) end elseif not items.language_name then error("Internal error: Don't know how to compute parents for non-language-specific category '" .. items.pagename .. "'") else local requests_concerning_breadcrumb = items.pagename:gsub(" " .. pattern_escape(items.language_name), "") requests_concerning_breadcrumb = requests_concerning_breadcrumb:gsub("^Requests for ", ""):gsub(" in entries$", ""):gsub(" for terms$", "") local requests_concerning_parent = { name = "Requests concerning " .. items.language_name, sort = {sort_base = requests_concerning_breadcrumb, lang = "en"} } if items.is_etym_lang then local parent_lang_cat = items.pagename:gsub(pattern_escape(items.language_name), replacement_escape(items.parent_language_name)) parents = { {name = parent_lang_cat, sort = {sort_base = items.language_name, lang = "en"}}, requests_concerning_parent } else breadcrumb = breadcrumb or requests_concerning_breadcrumb parents = {requests_concerning_parent} if items.additional_parents then extend(parents, items.additional_parents) end end end end if not items.nolang and not items.is_etym_lang and items.umbrella ~= false then table.insert(parents, { name = expand_items_value("umbrella"), sort = {sort_base = items.language_name, lang = "en"} }) end local additional = expand_items_value("full_text_about_the_template") if items.pagename:find(" by language$") then additional = "{{{umbrella_msg}}}" .. (additional and "\n\n" .. additional or "") end return { description = expand_items_value("description") or items.pagename .. ".", lang = items.parent_language_code or items.language_code, additional = additional, parents = parents, -- If no breadcrumb= and not an etym-only language, it will default to the category name breadcrumb = breadcrumb, catfix = expand_items_value("catfix"), toc_template = expand_items_value("toc_template"), toc_template_full = expand_items_value("toc_template_full"), hidden = not items.nolang and not items.not_hidden_category, can_be_empty = true, } end -- First look for a regular (usually language or script-specific) category. for _, category in ipairs(requests_categories) do local matchvals = {mw.ustring.match(data.category, category.regex)} if #matchvals > 0 then init_items() for key, value in pairs(category) do items[key] = value end for key, value in ipairs(matchvals) do items["" .. key] = value end local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end -- Now look for umbrella categories. for _, category in ipairs(requests_categories) do if data.category == category.umbrella then init_items() items.nolang = true items.additional_umbrella_parents = category.additional_umbrella_parents local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end return nil end) table.insert(raw_handlers, function(data) local langname = data.category:match("^Terms with (.+) translations$") local lang = langname and require(languages_module).getByCanonicalName(langname, true, true) if lang then local langcode = lang:getCode() local parents, breadcrumb_and_first_sort_key if lang:hasType("etymology-only") then parents = { "Terms with " .. lang:getFullName() .. " translations", {name = langname, sort = "Translations"}, } breadcrumb_and_first_sort_key = lang:getCanonicalName() else parents = { {name = "entry maintenance", is_label = true, lang = langcode}, { name = "Terms with translations by language", sort = {sort_base = langname, lang = "en"} }, } breadcrumb_and_first_sort_key = "Translations" end return { description = "Entries that contain translations into " .. langname .. " which were added using one of the translation templates, such as {{tl|t|" .. langcode .. "|...}}, {{tl|t+|" .. langcode .. "|...}}, etc.", parents = parents, breadcrumb_and_first_sort_key = breadcrumb_and_first_sort_key, catfix = false, can_be_empty = true, hidden = true, } end end) local recognized_taxtypes = require(table_module).listToSet { "ambiguous", "binomial", "branch", "clade", "cladus", "class", "cohort", "convariety", "cultivar group", "cultivar", "division", "empire", "epifamily", "epithet", "family", "form taxon", "form", "genus", "grade", "grandorder", "group", "hybrid", "informal group", "infraclass", "infracohort", "infrakingdom", "infraorder", "infraphylum", "infraspecies", "infratribe", "kingdom", "magnorder", "megacohort", "mirorder", "morph", "nothogenus", "nothospecies", "nothosubspecies", "nothovariety", "obsolete", "oofamily", "order", "parvclass", "parvorder", "phylum", "section", "series", "serovar", "species group", "species", "stem", "stirps", "strain", "subclass", "subcohort", "subdivision", "subfamily", "subgenus", "subgroup", "subinfraorder", "subkingdom", "suborder", "subphylum", "subsection", "subseries", "subspecies", "subterclass", "subtribe", "superclass", "supercohort", "superfamily", "supergroup", "superorder", "superphylum", "supertribe", "taxon", "tribe", "trinomial", "undescribed species", "unknown", "unranked group", "variety", "virus complex", } table.insert(raw_handlers, function(data) local taxtype = data.category:match("^Entries using missing taxonomic name %((.*)%)$") if taxtype and recognized_taxtypes[taxtype] then return { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name.", parents = {{name = "Entries using missing taxonomic names", sort = {sort_base = taxtype, lang = "en"}}}, breadcrumb = taxtype, hidden = true, } end end) return {LABELS = labels, RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers} 9exghuzutiwnuycepy3y01ftbitm13e 239379 239378 2026-11-22T08:45:47Z Lee 19 [[:en:Module:category_tree/entry_maintenance]] වෙතින් එක් සංශෝධනයක් 239378 Scribunto text/plain local labels = {} local raw_categories = {} local raw_handlers = {} local functions_module = "Module:fun" local languages_module = "Module:languages" local scripts_module = "Module:scripts" local string_pattern_escape_module = "Module:string/patternEscape" local string_replacement_escape_module = "Module:string/replacementEscape" local table_module = "Module:table" local extend = require(table_module).extend local is_callable = require(functions_module).is_callable local pattern_escape = require(string_pattern_escape_module) local replacement_escape = require(string_replacement_escape_module) local unpack = unpack or table.unpack -- Lua 5.2 compatibility ----------------------------------------------------------------------------- -- -- -- LABELS -- -- -- ----------------------------------------------------------------------------- labels["entry maintenance"] = { description = "{{{langname}}} entries, or entries in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {{name = "{{{langcat}}}", raw = true}}, breadcrumb_base = "entry maintenance", -- so the word 'maintenance' doesn't get chopped off umbrella_parents = {name = "Entry maintenance", sort = " "}, } labels["etymology maintenance"] = { description = "{{{langname}}} etymology sections, or etymology sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"entry maintenance"}, umbrella_parents = {name = "Etymology maintenance", sort = " "}, } labels["link maintenance"] = { description = "{{{langname}}} entries with internal links, or entries in other languages containing internal links to {{{langname}}} terms, that are being tracked for attention and improvement.", additional = "Internal links are those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"entry maintenance"}, umbrella_parents = {name = "Link maintenance", sort = " "}, } labels["pronunciation maintenance"] = { description = "{{{langname}}} pronunciation sections, or pronunciation sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"entry maintenance"}, umbrella_parents = {name = "Pronunciation maintenance", sort = " "}, } labels["entries with incorrect language header"] = { description = "{{{langname}}} entries that have been placed under the wrong language header.", additional = "This can happen for several reasons:\n" .. "* Typos.\n" .. "* Vandalism.\n" .. "* Using the wrong language code.\n" .. "* Using an alternative name for the language.\n" .. "* Using special characters which haven't been used in the name given in the language data modules.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["entries without References header"] = { description = "{{{langname}}} entries without a References header.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["entries without References or Further reading header"] = { description = "{{{langname}}} entries without a References or Further reading header.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["entries that don't exist"] = { description = "{{{langname}}} terms that do not meet the [[Wiktionary:Criteria for inclusion|criteria for inclusion]] (CFI). They are added to the category with the template {{tl|no entry|{{{langcode}}}}}.", parents = {"entry maintenance"}, umbrella_parents = "Fundamental", } labels["entries with etymology trees"] = { description = "{{{langname}}} entries that display an etymology tree generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology texts"] = { description = "{{{langname}}} entries that display an etymology generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymon"] = { description = "{{{langname}}} entries that use the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology text stop language not in chain"] = { description = "{{{langname}}} entries where {{tl|etymon}} is used with {{para|text}} set to stop at a language but that language never appears in the rendered etymology chain.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon that cannot be found, either because the target page does not exist (redlink) or because it has no {{tl|etymon}} template.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing ambiguous etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon without the ID, when the target page contains multiple {{tl|etymon}} templates, and an ID is therefore required to select the correct {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons with mismatched IDs"] = { description = "Entries which use the {{tl|etymon}} template with a mismatched ID. For example, {{code|lang:entry<id:mismatched ID>}}", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with multiple etymons missing IDs"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one {{tl|etymon}} template for the same language, where at least one of those templates has no {{para|id}}. When several {{tl|etymon}} templates share a language section, each must have a distinct {{para|id}} so that links and descendants logic can tell them apart.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with etymology sections missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one etymology section for the same language, where at least one section contains a {{tl|etymon}} template for that language and at least one other etymology section does not.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has no Descendants section.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without this term in Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has a Descendants section, but does not list the current term there.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with language name categories using raw markup"] = { description = "{{{langname}}} entries that have been placed in a language name category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langname}}} ...]]}}). They should be added using {{tl|cln|{{{langcode}}}|...}} instead.", parents = {"entry maintenance"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["entries with topic categories using raw markup"] = { description = "{{{langname}}} entries that have been placed in a topic category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langcode}}}:...]]}}). They should be added using {{tl|C|{{{langcode}}}|...}} instead.", parents = {"entry maintenance"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["entries with outdated source"] = { description = "{{{langname}}} entries that have been partly or fully imported from an outdated source.", parents = {"entry maintenance"}, } labels["entries with inflection not matching pagename"] = { description = "{{{langname}}} entries which have an inflection table whose lemma form does not match the page name.", additional = "This is usually the result of incorrect or missing parameters.", parents = {"entry maintenance"}, hidden = true, can_be_empty = true, } labels["undefined derivations"] = { description = "{{{langname}}} etymologies using {{tl|undefined derivation}}, where a more specific template such as {{tl|borrowed}} or {{tl|inherited}} should be used instead.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["descendants to be fixed in desctree"] = { description = "Entries that use {{tl|desctree}} to link to {{{langname}}} entries with no Descendants section.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["term requests"] = { description = "Entries with {{tl|der}}, {{tl|inh}}, {{tl|m}} and similar templates lacking the parameter for linking to {{{langname}}} terms.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["redlinks"] = { description = "Links to {{{langname}}} entries that have not been created yet.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", catfix = false, can_be_empty = true, hidden = true, } labels["terms with IPA pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of IPA.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with enPR pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of enPR.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with Indic pronunciation"] = { description = "{{langname}} terms that include the pronunciation in the form of ISO 15919.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["IPA pronunciations with invalid separators"] = { description = "{{{langname}}} terms with IPA using invalid separators such as /.ˈ/, /.ˌ/, a dot followed by primary or secondary stress; or /ˈ / or /ˌ /, primary or secondary stress followed by a space.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["terms with hyphenation"] = { description = "{{{langname}}} terms that include hyphenation.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with audio pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of an audio file.", additional = "For requests related to this category, see [[:Category:Requests for audio pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with nonstandard or incorrect audio pronunciations"] = { description = "{{{langname}}} terms which have been tagged as having audio pronunciations which are nonstandard or incorrect.", parents = {"terms with audio pronunciation"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["entries missing Template:reconstructed"] = { description = "Reconstructed {{{langname}}} entries which do not have the {{tl|reconstructed}} template.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } local function add_manual_param_category(label, desc, addl_intro, include_addl_continuation) local breadcrumb_base, parents, umbrella_parents if label:find("^links") then parents = {"link maintenance"} umbrella_parents = "Link maintenance" breadcrumb_base = label:gsub("^links with ", "") else parents = {"entry maintenance"} -- the call to finalize_labels() farther down will set the right breadcrumb, sortkey and umbrella_parents. end labels[label] = { description = desc or "Pages containing {{{langname}}} " .. label .. ".", additional = addl_intro .. (not include_addl_continuation and "" or "\n\n" .. "Note that the pages in this category are not necessarily the same as the actual term in question. This " .. "frequently happens, for example, with English pages with translation sections, where the term that " .. "triggers the addition of the category is one of the translations."), parents = parents, breadcrumb_base = breadcrumb_base, umbrella_parents = umbrella_parents, -- Set catfix = false because the page will have a mixture of native-language and -- non-native-language pages, but include the normal native-language table of contents headers -- because most pages are in the native language. catfix = false, toc_template = "{{{langcode}}}-categoryTOC", toc_template_full = "{{{langcode}}}-categoryTOC/full", can_be_empty = true, hidden = true, } end add_manual_param_category("terms in nonstandard scripts", nil, "Pages are placed here if they contain terms written in a script that isn't in the language's " .. "list of scripts in the language data. This may mean the script should be added to the list, or that the wrong language code has been used.", true) add_manual_param_category("terms with non-redundant manual transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is different from the transliteration which is automatically generated.", true) add_manual_param_category("terms with redundant transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is the same as the transliteration which is automatically generated.", true) add_manual_param_category("terms with non-redundant manual script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is different from the script code which is automatically generated.", true) add_manual_param_category("terms with redundant script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is the same as the script code which is automatically generated.", true) add_manual_param_category("terms with non-redundant non-automated sortkeys", "{{{langname}}} terms with non-redundant non-automated sortkeys.", "Terms are placed here if they have been sorted using a sortkey other than the one which is automatically " .. "generated. This can happen for two reasons:\n# A different sortkey has been specified using the {{para|sort}} " .. "parameter.\n# One or more categories have been added using raw wikitext, which means the page's default " .. "sortkey is used for that category. If that default sortkey is different from the automatic sortkey, then the " .. "page will also be added here.") add_manual_param_category("terms with redundant sortkeys", "{{{langname}}} terms with redundant sortkeys.", "Terms are placed here if their sortkey has been specified using the {{para|sort}} parameter, and it the same " .. "as the one which is automatically generated.") add_manual_param_category("links with redundant target parameters", "Pages containing {{{langname}}} links where the alt text could replace the link target, instead of being given " .. "separately.", "This occurs when the only difference between the link target and the alt text is that the alt text contains " .. "diacritics (or other characters) which would have been ignored anyway had they been included in the link " .. "target. For example, {{tl|l|la|amo|amō}} ({{l|la|amo|amō}}) is exactly the same as {{tl|l|la|amō}} " .. "({{l|la|amō}}), because macrons are automatically stripped from Latin link targets, even though they're still " .. "displayed.") add_manual_param_category("links with ignored alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("links with redundant alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter is redundant.", "This occurs when the alt text makes no difference to the output. For example, {{tl|l|en|foo|foo}} " .. "({{l|en|foo|foo}}) is exactly the same as {{tl|l|en|foo}} ({{l|en|foo}}).") add_manual_param_category("links with ignored id parameters", "Pages containing {{{langname}}} links where the {{para|id}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("links with redundant wikilinks", "Pages containing {{{langname}}} links which contain a redundant wikilink.", "This occurs if link target consists of a single wikilink, which should instead be entered in the " .. "conventional manner without link brackets. For example, {{tl|l|en|<nowiki>[[foo]]</nowiki>}} " .. "is the same as {{tl|l|en|foo}}, and {{tl|l|en|<nowiki>[[foo|bar]]</nowiki>}} is the same as " .. "{{tl|l|en|foo|bar}}.\n\nThis also occurs when link templates are nested inside each other " .. "unnecessarily: e.g. {{tl|l|en|{{tl|l|en|foo}}}}") add_manual_param_category("links with manual fragments", "Pages containing {{{langname}}} links where a manual link fragment has been given.", "This occurs when the link fragment has been specified using {{code|#}} after the term, " .. "which overrides the normal fragment generated by link templates that points to the relevant " .. "language section.\n\nLink fragments are used to point to a specific section on a target page, and " .. "it is preferable to use the {{para|id}} parameter to do this, since it is less likely to break if " .. "additional content is added to the target page: for example, the fragment {{code|#Adjective}} " .. "will start pointing to the wrong section if another language with an adjective section is added above " .. "the intended language.") labels["descendant hubs"] = { description = "{{{langname}}} terms that do not mean more than the sum of their parts but exist for listing two or more inclusion-worthy descendants.", parents = {"entry maintenance"}, } labels["terms needing to be assigned to a sense"] = { description = "{{{langname}}} entries that have terms under headers such as \"Synonyms\" or \"Antonyms\" not assigned to a specific sense of the entry in which they appear. Use [[Template:syn]] or [[Template:ant]] to fix these.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } --[=[ labels["terms with inflection tables"] = { description = "{{{langname}}} entries that contain inflection tables.". additional = "For requests related to this category," see [[:Category:Requests for inflections in {{{langname}}} entries]].", parents = {"entry maintenance"}, } ]=] local function generate_category_with_illustrations(typ, link, example_templates, other_types_in_group) local function make_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss in {{{langname}}}]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end local function make_umbrella_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss by language]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end labels[("terms with %ss"):format(typ)] = { description = ("{{{langname}}} entries that contain %s that were added using templates such as %s."):format(link, example_templates), additional = ("For requests related to this category, see [[:Category:Requests for %ss in {{{langname}}}]]. See also %s."):format( typ, make_other_request_cats()), parents = {"entry maintenance"}, umbrella = { additional = ("For requests related to this category, see [[:Category:Requests for %ss by language]]. See also %s."):format( typ, make_umbrella_other_request_cats()), }, umbrella_parents = ("%s maintenance"):format(mw.getContentLanguage():ucfirst(typ)), } end local function generate_related_categories_with_illustrations(info) for typ, spec in pairs(info) do local other_types = {} for other_type, _ in pairs(info) do if other_type ~= typ then table.insert(other_types, other_type) end end table.sort(other_types) generate_category_with_illustrations(typ, spec.link, spec.example_templates, other_types) end end generate_related_categories_with_illustrations { collocation = { link = "[[collocation]]s", example_templates = "{{tl|co}}", }, ["usage example"] = { link = "[[usage]] [[example]]s", example_templates = "{{tl|ux}}", }, quotation = { link = "[[quotation]]s", example_templates = "{{tl|quote}}, {{tl|quote-book}}, {{tl|quote-journal}}, etc", }, } labels["terms with interlinear glossed text"] = { description = "{{{langname}}} entries that contain interlinear glossed text added using {{tl|interlinear}}.", parents = {"entry maintenance"}, } labels["terms with redundant head parameter"] = { description = "{{{langname}}} terms that contain a redundant head= parameter in their headword (called using {{tl|head}} or a language-specific equivalent).", additional = "Individual languages can prevent terms from being added to this category by setting `data.no_redundant_head_cat`.", parents = {"entry maintenance"}, can_be_empty = true, hidden = true, } labels["terms with red links in their headword lines"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"redlinks"}, breadcrumb_base = "headword lines", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["terms with red links in their inflection tables"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"redlinks"}, breadcrumb_base = "inflection tables", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } for _, quot_type in ipairs { "quotations", "usage examples" } do local umbrella_parent = quot_type == "quotations" and "Quotation maintenance" or "Usage example maintenance" labels[quot_type .. " with omitted translation"] = { description = "{{{langname}}} " .. quot_type .. " where a translation would normally be required but the translation has explicitly been omitted by specifying {{code|-}}. The translation should be supplied instead.", parents = {"entry maintenance"}, umbrella = { parents = {name = umbrella_parent, sort = "omitted translation"}, breadcrumb = "with omitted translation", }, can_be_empty = true, hidden = true, } end for _, pos in ipairs({"nouns", "proper nouns", "verbs", "adjectives", "adverbs", "participles", "determiners", "pronouns", "numerals", "suffixes", "contractions"}) do labels[pos .. " with red links in their headword lines"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"terms with red links in their headword lines"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels[pos .. " with red links in their inflection tables"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"terms with red links in their inflection tables"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } end for _, pos in ipairs { "nouns", "proper nouns", "pronouns" } do local label = pos .. " with unknown or uncertain plurals" labels[label] = { description = "{{{langname}}} " .. label .. ".", additional = "Terms are usually added to this category by specifying {{code|?}} as the plural. As much " .. "is possible, a plural should be added or, if the noun is uncountable, indicated appropriately (usually " .. "using {{code|-}} in place of the plural). Some languages support the value {{code|!}} to indicate " .. "that a plural cannot be attested but the noun is theoretically countable.", parents = {pos, "entry maintenance"}, } end -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_labels(labels, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in"}, default_umbrella_parents = "Entry maintenance subcategories by language", }) ----------------------------------------------------------------------------- -- -- -- RAW CATEGORIES -- -- -- ----------------------------------------------------------------------------- raw_categories["Entry maintenance subcategories by language"] = { description = "Umbrella categories covering topics related to entry maintenance.", additional = "{{{umbrella_meta_msg}}}", parents = { "Umbrella metacategories", {name = "entry maintenance", is_label = true, sort = " "}, {name = "Entry maintenance", sort = " "}, }, } raw_categories["Citation maintenance"] = { description = "Categories for maintaining citations specified using {{tl|cite-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Collocation maintenance"] = { description = "Categories for maintaining collocations specified using {{tl|co}}, {{tl|coi}} or {{tl|coa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Link maintenance"] = { description = "Categories for maintaining internal links, such as those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Pronunciation maintenance"] = { description = "Categories for maintaining pronunciations specified in pronunciation sections.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Quotation maintenance"] = { description = "Categories for maintaining quotations specified using {{tl|quote-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Usage example maintenance"] = { description = "Categories for maintaining usage examples specified using {{tl|ux}}, {{tl|uxi}} or {{tl|uxa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Citations using nocat parameter"] = { description = "Instances of {{tl|cite-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Citation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotation templates to be cleaned"] = { description = "Instances of quotations using {{tl|quote-text}}.", additional = "They should be converted to other '''[[:Category:Citation templates|quotation templates]]''' if relevant.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using nocat parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using quoted-in parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|quoted_in}} parameter.", additional = "It is recommended to restructure these template calls using the {{para|newversion}} parameter along with associated parameters {{para|2ndauthor}}, {{para|title2}}, {{para|year2}}, {{para|publisher2}} and the like, as described in the documentation for {{tl|quote-book}}.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Requests"] = { topright = "{{shortcut|WT:CR|WT:RQ}}", description = "A parent category for the various request categories.", parents = {"Category:Wiktionary"}, } raw_categories["Requests by language"] = { description = "Categories with requests in various specific languages.", additional = "{{{umbrella_msg}}}", parents = { {name = "Request subcategories by language", sort = " "}, {name = "Requests", sort = " "}, }, breadcrumb = "by language", } raw_categories["Request subcategories by language"] = { description = "Umbrella categories covering topics related to requests.", additional = "{{{umbrella_meta_msg}}}", parents = { "Umbrella metacategories", {name = "Requests", sort = " "}, }, } raw_categories["Requests for quotations by source"] = { description = "Categories with requests for quotation, broken out by the source of the quotation.", additional = "Some abbreviated names of sources are explained at [[Wiktionary:Abbreviated Authorities in Webster]].", parents = {"Requests for quotations"}, } raw_categories["Requests for quotations"] = { -- FIXME description = "Words are added to this category by the inclusion in their entries of {{tl|rfv-quote}}.", parents = {"Requests", "Quotation maintenance"}, } raw_categories["Requests for date"] = { description = "Requests for a date to be added to a quotation.", additional = "To add an article to this category, use {{tl|rfdate}} or {{tl|rfdatek}} to include the author. " .. "Please remove the template from the article once the date has been provided.", parents = {"Requests", "Quotation maintenance"}, } raw_categories["Requests for translations in user-competency categories by number of users"] = { description = "Requests for translations to be added to user-competency categories, sorted by number of users with that competency.", parents = {"Requests"}, } raw_categories["Requests for translations in user-competency categories by language"] = { description = "Requests for translations to be added to user-competency categories, sorted by language.", parents = {"Requests"}, hidden = true, } raw_categories["Terms with translations by language"] = { description = "Terms with translations, sorted by language.", parents = {"Entry maintenance subcategories by language"}, breadcrumb_base = "translations", } raw_categories["Entries using missing taxonomic names"] = { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name." .. "\n\nSee [[:Category:mul:Taxonomic names]].", parents = {{name = "entry maintenance", is_label = true, lang = "mul"}}, breadcrumb_base = "missing taxonomic names", hidden = true, } raw_categories["Entries with collapsible category lists for nonexistent categories"] = { description = "Entries where [[Module:collapsible category list]] is used, but the requested category does not exist.", additional = "Normally the culprit is a template like {{tl|prefixsee}} or {{tl|suffixsee}}.", parents = {"Entry maintenance", "Category maintenance"}, hidden = true, } -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_raw_categories(raw_categories, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "requests for", "citations", "quotations", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in", "by", "using"}, }) ----------------------------------------------------------------------------- -- -- -- RAW HANDLERS -- -- -- ----------------------------------------------------------------------------- local function script_name_to_code(name) local sc = require(scripts_module).getByCanonicalName(name) if not sc then error("Unrecognized script name '" .. name .. "'") end return sc:getCode() end --[=[ This array consists of category match specs. Each spec contains one or more properties, whose values are (a) strings that may contain references to other properties using the {{{PROPERTY}}} syntax; (b) functions of one argument, an `items` table of the same properties that are accessible using the {{{PROPERTY}} syntax. Each such spec should have at least a `regex` property that matches the name of the category. Capturing groups in this regex can be referenced in other properties using {{{1}}} for the first group, {{{2}}} for the second group, etc. (or using keys "1", "2", etc. in functions). Property expansion happens recursively if needed (i.e. a property can reference another property, which in turn references a third property). If there is a `language_name` propery, it specifies the language name (and will typically be a reference to a capturing group from the `regex` property); if not specified, it defaults to "{{{1}}}" unless the `nolang` property is set, in which case there is no language name associated with the category name. The language name must be the canonical name of a recognized full language, or an error is thrown; however, if the `allow_etym_lang` property is set, the language name may also be the canonical name of an etymology-only language. Based on the language name, the `language_code` and `language_object` properties are automatically filled in. If `language_name` is an etymology-only language, additional properties `parent_language_name`, `parent_language_code` and `parent_language_object` are set for the parent full language of the etymology-only language. If the `regex` values of multiple category specs match, the first one takes precedence. Recognized or predefined properties: `pagename`: Current pagename. `regex`: See above. `1`, `2`, `3`, ...: See above. `language_name`, `language_code`, `language_object`: See above. `parent_language_name`, `parent_language_code`, `parent_language_object`: See above. `nolang`: See above. `allow_etym_lang`: Language names may be etymology-only languages. See above. `description`: Override the description (normally taken directly from the pagename). `template_name`: Name of template which generates this category. `template_sample_call`: Syntax for calling the template. Defaults to "{{{template_name}}}|{{{language_code}}}". Used to display an example template call and the output of this call. `template_actual_sample_call`: Syntax for calling the template. Takes precedence over `template_sample_call` when generating example template output (but not when displaying an example template call) and is intended for a template call that uses the |nocat=1 parameter. `template_example_output`: Override the text that displays example template output (see `template_sample_call`). `additional_template_description`: Extra text to be displayed after the example template output. `parents`: Parent categories. Should be a list of elements, each of which is an object containing at least a name= and sort= field (same format as parents= for regular raw categories, except that the name= and sort= field will have {{{PROPERTY}}} references expanded). If no parents are specified, and the pagename is of the form "Requests for FOO by language", the parents will be "Request subcategories by language" with FOO as the sort key, along with any parents specified in `additional_umbrella_parents`. Otherwise, the `language_name` property must exist, and the parent will be "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key, along with any parents specified in `additional_parents`. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_parents` is used instead. `additional_parents`: Additional parents to add to the per-language category along with "Requests concerning LANGNAME". `etym_parents`: Parent categories for categories with associated etymology-only languages. The format is the same as `parents`. If omitted, there are two parents by default: (1) The pagename (i.e. category name) with the language name replaced by the corresponding parent language name, with the value of `language_name` as the sort key; (2) "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key. `umbrella`: Parent all-language category. Sort key is based on the language name. This applies *ONLY* if a full language is associated with the category name (i.e. not if `nolang` is set or if `allow_etym_lang` is set and the associated language is an etymology-only language); otherwise there will be no umbrella category. `additional_umbrella_parents`: Additional parents to add to the umbrella (all-language) category along with "Request subcategories by language". `breadcrumb`: Specify the breadcrumb. If `parents` is given, there is no default (i.e. it will end up being the pagename). Otherwise, if the pagename is of the form "Requests for FOO by language", the default breadcrumb will be "FOO". Otherwise it is computed by removing the language name from the pagename and chopping out "Requests for" from the beginning and "in entries" and "for terms" from the end. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_breadcrumb` is used instead. `etym_breadcrumb`: Specify the breadcrumb for categories with associated etymology-only languages. Defaults to the value of `language_name`. `not_hidden_category`: Don't hide the category. `catfix`: Same as `catfix` in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. `toc_template`, `toc_template_full`: Same as the corresponding fields in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. In general, properties can contain references to templates (e.g. {{tl}} and {{para}}), which will be appropriately expanded (this expansion happens in the poscatboiler code, not in this module). The major exception is in the `template_sample_call` and `template_actual_sample_call` properties, which are surrounded by <pre>...</pre> when inserted, so template references are not expanded. Triple-brace property references are still expanded in these properties; but beware that if any of those property references contain template references, they won't be expanded. (This actually happens in the handlers for 'Request for SCRIPT script for LANG terms'; the sample call references {{{script_code}}}, whose definition therefore cannot contain template references. The solution is to define this property using a function.) ]=] local requests_categories = { { regex = "^Requests concerning (.+)$", allow_etym_lang = true, description = "Categories with {{{1}}} entries that need the attention of experienced editors.", parents = {{name = "entry maintenance", is_label = true, sort = "requests"}}, etym_parents = {{name = "Requests concerning {{{parent_language_name}}}", sort = "{{{1}}}"}, {name = "{{{1}}}", sort = "Requests"}}, umbrella = "Requests by language", breadcrumb = "Requests", not_hidden_category = true, }, { regex = "^Requests for etymologies in (.+) entries$", allow_etym_lang = true, umbrella = "Requests for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "rfe", }, { regex = "^Requests for expansion of etymologies in (.+) entries$", umbrella = "Requests for expansion of etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "etystub", }, { regex = "^Requests for pronunciation in (.+) entries$", umbrella = "Requests for pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfp", }, { regex = "^Requests for audio pronunciation in (.+) entries$", umbrella = "Requests for audio pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfap", }, { regex = "^Requests for definitions in (.+) entries$", umbrella = "Requests for definitions by language", template_name = "rfdef", }, { regex = "^Requests for clarification of definitions in (.+) entries$", umbrella = "Requests for clarification of definitions by language", template_name = "rfclarify", }, { regex = "^Requests for English equivalent terms in (.+) entries$", umbrella = "Requests for English equivalent terms by language", template_name = "rfeq", }, } for _, spec_with_pos in ipairs { {"inflections", "rfinfl"}, {"plural forms"}, {"tone", "rftone"}, {"accents"}, {"aspect", "rfaspect"}, {"animacy"}, {"gender", "rfgender"}, {"noun class"}, } do local property, rftemplate = unpack(spec_with_pos) table.insert(requests_categories, { -- This is for part-of-speech-specific categories such as -- "Requests for inflections in Northern Ndebele noun entries" or -- "Requests for accents in Ukrainian proper noun entries". -- Here and below, we assume that the part of speech is begins with -- a lowercase letter, while the preceding language name ends in a -- capitalized word. Note that this entry comes before the -- following one and takes precedence over it. regex = ("^Requests for %s in (.-) ([a-z]+[a-z ]*) entries$"):format(property), parents = {{name = ("Requests for %s in {{{language_name}}} entries"):format(property), sort = "{{{2}}}"}}, umbrella = ("Requests for %s of {{pluralize|{{{2}}}}} by language"):format(property), breadcrumb = "{{{2}}}", template_name = rftemplate, template_sample_call = rftemplate and ("{{%s|{{{language_code}}}|{{{2}}}}}"):format(rftemplate) or nil, } ) table.insert(requests_categories, { regex = ("^Requests for %s in (.+) entries$"):format(property), umbrella = ("Requests for %s by language"):format(property), template_name = rftemplate, } ) table.insert(requests_categories, { regex = ("^Requests for %s of (.+) by language$"):format(property), nolang = true, } ) end extend(requests_categories, { { regex = "^Requests for example sentences in (.+)$", umbrella = "Requests for example sentences by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfex", }, { regex = "^Requests for quotations in (.+)$", umbrella = "Requests for quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfquote", }, { regex = "^Requests for translations into (.+)$", allow_etym_lang = true, umbrella = "Requests for translations by language", template_name = "t-needed", catfix = "en", }, { regex = "^Requests for translations of (.+) usage examples$", allow_etym_lang = true, umbrella = "Requests for translations of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|usex}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|usex|nocat=1}}", additional_template_description = "The {{tl|ux}}, {{tl|uxi}}, {{tl|ja-usex}} and {{tl|zh-x}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for translations of (.+) quotations$", allow_etym_lang = true, umbrella = "Requests for translations of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|quote}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|quote|nocat=1}}", additional_template_description = "The {{tl|quote}}, and {{tl|Q}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for review of (.+) translations$", allow_etym_lang = true, umbrella = "Requests for review of translations by language", template_name = "t-check", template_sample_call = "{{t-check|{{{language_code}}}|example}}", template_example_output = "", catfix = "en", }, { regex = "^Requests for transliteration of (.+) terms$", umbrella = "Requests for transliteration by language", template_name = "rftranslit", additional_template_description = "The {{tl|head}} template, and the large number of language-specific variants of it, automatically add " .. "the page to this category if the example is in a foreign language and no transliteration can be generated (particularly in languages without " .. "automated transliteration, such as Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) usage examples$", umbrella = "Requests for transliteration of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rftranslit", template_sample_call = "{{rftranslit|{{{language_code}}}}}", template_actual_sample_call = "{{rftranslit|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) quotations$", umbrella = "Requests for transliteration of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for native script for (.+) terms$", allow_etym_lang = true, etym_parents = { {name = "Requests for native script for {{{parent_language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "native script"}, }, umbrella = "Requests for native script by language", template_name = "rfscript", template_actual_sample_call = "{{rfscript|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for native script in (.+) usage examples$", umbrella = "Requests for native script in usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|usex=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|usex=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example itself is missing but the translation is supplied." }, { regex = "^Requests for native script in (.+) quotations$", umbrella = "Requests for native script in quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|quote=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|quote=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation itself is missing but the translation is supplied." }, { regex = "^Requests for (.+) script for (.+) terms$", language_name = "{{{2}}}", allow_etym_lang = true, parents = {{name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}}, etym_parents = { {name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests for {{{1}}} script for {{{parent_language_name}}} terms", sort = "{{{language_name}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "{{{1}}} script"}, }, umbrella = "Requests for {{{1}}} script by language", breadcrumb = "{{{1}}}", etym_breadcrumb = "{{{1}}}", template_name = "rfscript", -- NOTE: The following is used in `template_sample_call` and `template_actual_sample_call`, meaning the -- conversion of script name to script code needs to be done using an inline function like this, instead of -- a {{#invoke:...}} template call. script_code = function(items) return script_name_to_code(items["1"]) end, template_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for (.+) script by language$", parents = {{name = "Requests for script by language", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, }, { regex = "^Requests for script by language$", nolang = true, }, { regex = "^Requests for images in (.+) entries$", umbrella = "Requests for images by language", template_name = "rfi", }, { regex = "^Requests for references for (.+) terms$", umbrella = "Requests for references by language", template_name = "rfref", }, { regex = "^Requests for references for etymologies in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "etymologies"}}, umbrella = "Requests for references for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, breadcrumb = "Etymologies", template_name = "rfv-etym", }, { regex = "^Requests for references for pronunciations in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "pronunciations"}}, umbrella = "Requests for references for pronunciations by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, breadcrumb = "Pronunciations", template_name = "rfv-pron", }, { regex = "^Requests for attention concerning (.+)$", umbrella = "Requests for attention by language", breadcrumb = "Attention", template_name = "attention", template_sample_call = "{{attention|{{{language_code}}}|insert a brief description of the request here}}", template_example_output = "This template does not generate any text in entries, but can be visualised by enabling the Catch My Attention gadget. See {{section link|Template:attention#Visibility}}.", -- These pages typically contain a mixture of English and native-language entries, so disable catfix. catfix = false, -- Setting catfix = false will normally trigger the English table of contents template. -- We still want the native-language table of contents template, though. toc_template = "{{{language_code}}}-categoryTOC", toc_template_full = "{{{language_code}}}-categoryTOC/full", }, { regex = "^Requests for cleanup in (.+) entries$", umbrella = "Requests for cleanup by language", template_name = "rfc", template_actual_sample_call = "{{rfc|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for cleanup of Pronunciation N headers in (.+) entries$", umbrella = "Requests for cleanup of Pronunciation N headers by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfc-pron-n", template_actual_sample_call = "{{rfc-pron-n|{{{language_code}}}|nocat=1}}", template_example_output = "This template does not generate any text in entries.", additional_template_description = [=[ The purpose of this category is to tag entries that use headers with "Pronunciation" and a number. While these headers and structure are sometimes used, they are not specifically prescribed by [[WT:ELE]]. No complete proposal has yet been made on how they should work, what the semantics are, or how they interact with multiple etymologies. As a result they should generally be avoided. Instead, merge the entries (possibly under multiple Etymology sections, if appropriate), and list all pronunciations, appropriately tagged, under a Pronunciation header. [[User:KassadBot|KassadBot]] tags these entries (or used to tag these entries, when the bot was operational). At some point if a proposal is made and adopted as policy, these entries should be reviewed. This category is hidden.]=], }, { regex = "^Requests for deletion in (.+) entries$", umbrella = "Requests for deletion by language", template_name = "rfd", template_actual_sample_call = "{{rfd|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for verification in (.+) entries$", umbrella = "Requests for verification by language", template_name = "rfv", }, { regex = "^Requests for attention in (.+) etymologies$", umbrella = "Requests for attention by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, }, { regex = "^Requests for quotations/(.+)$", description = "Requests for a quotation or for quotations from {{{1}}}.", parents = {{name = "Requests for quotations by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfquotek", template_sample_call = "{{rfquotek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfquotek|und|{{{1}}}}}", }, { regex = "^Requests for date in (.+) entries$", umbrella = "Requests for date by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfdate", additional_template_description = "The quotation templates, such as {{tl|quote-book}} and {{tl|quote-journal}}, " .. "automatically add the page to this category if neither {{para|date}} nor {{para|year}} is provided. Providing the " .. "parameter in each case on the page automatically removes the article from this category. See " .. "[[Wiktionary:Quotations]] for information about formatting dates and quotations.", }, { regex = "^Requests for date/(.+)$", description = "{{rfd|section=Category:Requests for date by source}}Requests for a date for a quotation or quotations from {{{1}}}.", parents = {{name = "Requests for date by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfdatek", template_sample_call = "{{rfdatek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfdatek|und|{{{1}}}}}", }, { regex = "^Requests for attestation of (.+) terms$", umbrella = "Requests for attestation of terms by language", breadcrumb = "Attestation", additional_template_description = "The {{tl|LDL}} template adds this category when a language code is supplied in {{para|1}} (as it should be)." }, }) local user_competency_additional_template_description = "This is added by user-competency categories such as " .. "[[:Category:User fr-4]], which groups users who speak French at level 4 (near-native proficiency), when " .. "the native-language text indicating this fact is missing. The appropriate translation should mirror the " .. "English text also displayed (e.g. in this case \"These users speak French at a '''near native''' " .. "level.\"), and should be supplied to {{tl|auto cat}} using the {{para|text}} parameter. The mention of the " .. "language in the text should be surrounded by double angle brackets, e.g. \"&lt;&lt;français>>\", which " .. "causes it to be automatically linked to the appropriate parent category." local user_competency_parents = {{name = "Requests for translations in user-competency categories by number of users", sort = function(items) return " " .. ("%010d"):format(items["1"]) end, }} extend(requests_categories, { { regex = "^Requests for translations in user%-competency categories with ([0-9]+)%-([0-9]+) users$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}}-{{{2}}} users.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}-{{{2}}}", nolang = true, }, { regex = "^Requests for translations in user%-competency categories with ([0-9]+) (users?)$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}} {{{2}}}.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}", nolang = true, } }) table.insert(raw_handlers, function(data) local items local function init_items() items = {pagename = data.category} end local function expand_value(item, val) if not val then return val elseif is_callable(val) then return expand_value(item .. " ⇒ function", val(items)) elseif type(val) == "table" then for k, v in pairs(val) do val[k] = expand_value(item .. " ⇒ " .. k, v) end return val elseif type(val) == "number" then val = tostring(val) end if type(val) ~= "string" then error(("The item '%s' on page %s is of type %s and can't be concatenated"):format( item, items.pagename, type(val))) end -- Replaces pseudo-template code {{{ }}} with the corresponding member of the "items" table. Has to be done -- recursively, since some of the items are nested: -- {{{template_sample_call_with_temp}}} -- ⇓ -- {{{{{template_name}}}|{{{language_code}}}}} -- ⇓ -- {{attention|en}} if val:find("{{{") then val = mw.ustring.gsub(val, "{{{([^%}%{]+)}}}", function(prop) local propval = items[prop] if not propval then error(("The item '%s' (expanded from property '%s' on page %s) was not found in the 'items' table"): format(prop, item, items.pagename)) end return expand_value(item .. " ⇒ " .. prop, propval) end ) end return val end local function expand_items_value(item) return expand_value(item, items[item]) end local function convert_items_to_category_data(items) if not items.nolang then items.language_name = items.language_name or "{{{1}}}" items.language_name = expand_items_value("language_name") items.language_object = require(languages_module).getByCanonicalName(items.language_name, true, items.allow_etym_lang) items.language_code = items.language_object:getCode() items.is_etym_lang = items.language_object:hasType("etymology-only") if items.is_etym_lang then items.parent_language_object = items.language_object:getFull() -- Reject weird cases where etymology language has no parent. if not items.parent_language_object then return nil end items.parent_language_code = items.parent_language_object:getCode() items.parent_language_name = items.parent_language_object:getCanonicalName() -- Reject weird cases where the parent language has the same name as the child etymology language. In -- that case, we'll get an infinite parent-category loop. This actually happens, e.g. with Rudbari and -- Bashkardi. if items.parent_language_name == items.language_name then return nil end else end end if items.template_name then items.template_sample_call = items.template_sample_call or "{{{{{template_name}}}|{{{language_code}}}}}" items.full_text_about_the_template = "To make this request, in this specific language, use this code in the entry (see also the documentation at [[Template:{{{template_name}}}]]):\n\n<pre>{{{template_sample_call}}}</pre>" if items.template_example_output then items.full_text_about_the_template = items.full_text_about_the_template .. " " .. items.template_example_output else items.template_actual_sample_call = items.template_actual_sample_call or items.template_sample_call items.full_text_about_the_template = items.full_text_about_the_template .. "\nIt results in the message below:\n\n{{{template_actual_sample_call}}}" end if items.additional_template_description then items.full_text_about_the_template = items.full_text_about_the_template .. "\n\n" .. items.additional_template_description end else items.full_text_about_the_template = items.additional_template_description end local parents, breadcrumb if items.is_etym_lang then parents = items.etym_parents breadcrumb = expand_items_value("etym_breadcrumb") or items.language_name else parents = items.parents breadcrumb = expand_items_value("breadcrumb") end if parents then for _, parent in ipairs(parents) do parent.name = expand_value("parent.name", parent.name) parent.sort = {sort_base = expand_value("parent.sort", parent.sort), lang = "en"} end else local umbrella_type = items.pagename:match("^Requests for (.+) by language$") if umbrella_type then breadcrumb = breadcrumb or umbrella_type parents = {{name = "Request subcategories by language", sort = umbrella_type}} if items.additional_umbrella_parents then extend(parents, items.additional_umbrella_parents) end elseif not items.language_name then error("Internal error: Don't know how to compute parents for non-language-specific category '" .. items.pagename .. "'") else local requests_concerning_breadcrumb = items.pagename:gsub(" " .. pattern_escape(items.language_name), "") requests_concerning_breadcrumb = requests_concerning_breadcrumb:gsub("^Requests for ", ""):gsub(" in entries$", ""):gsub(" for terms$", "") local requests_concerning_parent = { name = "Requests concerning " .. items.language_name, sort = {sort_base = requests_concerning_breadcrumb, lang = "en"} } if items.is_etym_lang then local parent_lang_cat = items.pagename:gsub(pattern_escape(items.language_name), replacement_escape(items.parent_language_name)) parents = { {name = parent_lang_cat, sort = {sort_base = items.language_name, lang = "en"}}, requests_concerning_parent } else breadcrumb = breadcrumb or requests_concerning_breadcrumb parents = {requests_concerning_parent} if items.additional_parents then extend(parents, items.additional_parents) end end end end if not items.nolang and not items.is_etym_lang and items.umbrella ~= false then table.insert(parents, { name = expand_items_value("umbrella"), sort = {sort_base = items.language_name, lang = "en"} }) end local additional = expand_items_value("full_text_about_the_template") if items.pagename:find(" by language$") then additional = "{{{umbrella_msg}}}" .. (additional and "\n\n" .. additional or "") end return { description = expand_items_value("description") or items.pagename .. ".", lang = items.parent_language_code or items.language_code, additional = additional, parents = parents, -- If no breadcrumb= and not an etym-only language, it will default to the category name breadcrumb = breadcrumb, catfix = expand_items_value("catfix"), toc_template = expand_items_value("toc_template"), toc_template_full = expand_items_value("toc_template_full"), hidden = not items.nolang and not items.not_hidden_category, can_be_empty = true, } end -- First look for a regular (usually language or script-specific) category. for _, category in ipairs(requests_categories) do local matchvals = {mw.ustring.match(data.category, category.regex)} if #matchvals > 0 then init_items() for key, value in pairs(category) do items[key] = value end for key, value in ipairs(matchvals) do items["" .. key] = value end local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end -- Now look for umbrella categories. for _, category in ipairs(requests_categories) do if data.category == category.umbrella then init_items() items.nolang = true items.additional_umbrella_parents = category.additional_umbrella_parents local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end return nil end) table.insert(raw_handlers, function(data) local langname = data.category:match("^Terms with (.+) translations$") local lang = langname and require(languages_module).getByCanonicalName(langname, true, true) if lang then local langcode = lang:getCode() local parents, breadcrumb_and_first_sort_key if lang:hasType("etymology-only") then parents = { "Terms with " .. lang:getFullName() .. " translations", {name = langname, sort = "Translations"}, } breadcrumb_and_first_sort_key = lang:getCanonicalName() else parents = { {name = "entry maintenance", is_label = true, lang = langcode}, { name = "Terms with translations by language", sort = {sort_base = langname, lang = "en"} }, } breadcrumb_and_first_sort_key = "Translations" end return { description = "Entries that contain translations into " .. langname .. " which were added using one of the translation templates, such as {{tl|t|" .. langcode .. "|...}}, {{tl|t+|" .. langcode .. "|...}}, etc.", parents = parents, breadcrumb_and_first_sort_key = breadcrumb_and_first_sort_key, catfix = false, can_be_empty = true, hidden = true, } end end) local recognized_taxtypes = require(table_module).listToSet { "ambiguous", "binomial", "branch", "clade", "cladus", "class", "cohort", "convariety", "cultivar group", "cultivar", "division", "empire", "epifamily", "epithet", "family", "form taxon", "form", "genus", "grade", "grandorder", "group", "hybrid", "informal group", "infraclass", "infracohort", "infrakingdom", "infraorder", "infraphylum", "infraspecies", "infratribe", "kingdom", "magnorder", "megacohort", "mirorder", "morph", "nothogenus", "nothospecies", "nothosubspecies", "nothovariety", "obsolete", "oofamily", "order", "parvclass", "parvorder", "phylum", "section", "series", "serovar", "species group", "species", "stem", "stirps", "strain", "subclass", "subcohort", "subdivision", "subfamily", "subgenus", "subgroup", "subinfraorder", "subkingdom", "suborder", "subphylum", "subsection", "subseries", "subspecies", "subterclass", "subtribe", "superclass", "supercohort", "superfamily", "supergroup", "superorder", "superphylum", "supertribe", "taxon", "tribe", "trinomial", "undescribed species", "unknown", "unranked group", "variety", "virus complex", } table.insert(raw_handlers, function(data) local taxtype = data.category:match("^Entries using missing taxonomic name %((.*)%)$") if taxtype and recognized_taxtypes[taxtype] then return { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name.", parents = {{name = "Entries using missing taxonomic names", sort = {sort_base = taxtype, lang = "en"}}}, breadcrumb = taxtype, hidden = true, } end end) return {LABELS = labels, RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers} 9exghuzutiwnuycepy3y01ftbitm13e 239380 239379 2026-11-22T08:46:39Z Lee 19 පැරණි සංස්කරණයකින් ගත් කොටස්... 239380 Scribunto text/plain local m_sinhala = require("Module:sinhala") local labels = {} local raw_categories = {} local raw_handlers = {} local functions_module = "Module:fun" local languages_module = "Module:languages" local scripts_module = "Module:scripts" local string_pattern_escape_module = "Module:string/patternEscape" local string_replacement_escape_module = "Module:string/replacementEscape" local table_module = "Module:table" local extend = require(table_module).extend local is_callable = require(functions_module).is_callable local pattern_escape = require(string_pattern_escape_module) local replacement_escape = require(string_replacement_escape_module) local unpack = unpack or table.unpack -- Lua 5.2 compatibility ----------------------------------------------------------------------------- -- -- -- LABELS -- -- -- ----------------------------------------------------------------------------- labels["ප්‍රවේශ නඩත්තුව"] = { description = "{{{langname}}} entries, or entries in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement by editors.", parents = {{name = "{{{langcat}}}", raw = true}}, breadcrumb_base = "ප්‍රවේශ නඩත්තුව", -- so the word 'maintenance' doesn't get chopped off umbrella_parents = {name = "ප්‍රවේශ නඩත්තුව", sort = " "}, } labels["etymology maintenance"] = { description = "{{{langname}}} etymology sections, or etymology sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = {name = "Etymology maintenance", sort = " "}, } labels["link maintenance"] = { description = "{{{langname}}} entries with internal links, or entries in other languages containing internal links to {{{langname}}} terms, that are being tracked for attention and improvement.", additional = "Internal links are those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = {name = "Link maintenance", sort = " "}, } labels["pronunciation maintenance"] = { description = "{{{langname}}} pronunciation sections, or pronunciation sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = {name = "Pronunciation maintenance", sort = " "}, } labels["ප්‍රවේශ, දෝෂ සහගත භාෂා ශීර්ෂක සහිත"] = { description = "{{{langname}}} ප්‍රවේශ, වැරදි භාෂා ශීර්ෂක යටතේ දක්වා ඇති.", additional = "හේතු කිහිපයක් නිසා මෙය සිදුවිය හැකිය:\n" .. "* අක්ෂර වින්‍යාසය දෝෂ (Typos).\n" .. "* විනාශ කිරීම් (Vandalism).\n" .. "* වැරදි භාෂා කේතය භාවිතා කිරීම.\n" .. "* භාෂාව සඳහා වන විකල්ප නාමයක් භාවිතා කිරීම.\n" .. "* භාෂා දත්ත මොඩියුල තුළ භාෂා නාම සඳහා දක්වා නොමැති විශේෂ අනුකල්ෂණ භාවිතා කිරීම.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["entries without References header"] = { description = "{{{langname}}} entries without a References header.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["entries without References or Further reading header"] = { description = "{{{langname}}} entries without a References or Further reading header.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["entries that don't exist"] = { description = "{{{langname}}} terms that do not meet the [[Wiktionary:Criteria for inclusion|criteria for inclusion]] (CFI). They are added to the category with the template {{tl|no entry|{{{langcode}}}}}.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = "මූලධර්ම", } labels["entries with etymology trees"] = { description = "{{{langname}}} entries that display an etymology tree generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology texts"] = { description = "{{{langname}}} entries that display an etymology generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymon"] = { description = "{{{langname}}} entries that use the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology text stop language not in chain"] = { description = "{{{langname}}} entries where {{tl|etymon}} is used with {{para|text}} set to stop at a language but that language never appears in the rendered etymology chain.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon that cannot be found, either because the target page does not exist (redlink) or because it has no {{tl|etymon}} template.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing ambiguous etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon without the ID, when the target page contains multiple {{tl|etymon}} templates, and an ID is therefore required to select the correct {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons with mismatched IDs"] = { description = "Entries which use the {{tl|etymon}} template with a mismatched ID. For example, {{code|lang:entry<id:mismatched ID>}}", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with multiple etymons missing IDs"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one {{tl|etymon}} template for the same language, where at least one of those templates has no {{para|id}}. When several {{tl|etymon}} templates share a language section, each must have a distinct {{para|id}} so that links and descendants logic can tell them apart.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with etymology sections missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one etymology section for the same language, where at least one section contains a {{tl|etymon}} template for that language and at least one other etymology section does not.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has no Descendants section.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without this term in Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has a Descendants section, but does not list the current term there.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["ප්‍රවේශ, ඍජු එක් කිරීම මගින් භාෂා නාම ප්‍රවර්ග දක්වා ඇති"] = { description = "{{{langname}}} entries that have been placed in a language name category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langname}}} ...]]}}). They should be added using {{tl|cln|{{{langcode}}}|...}} instead.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["ප්‍රවේශ, ඍජු එක් කිරීම මගින් මාතෘකා ප්‍රවර්ග දක්වා ඇති"] = { description = "{{{langname}}} entries that have been placed in a topic category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langcode}}}:...]]}}). They should be added using {{tl|C|{{{langcode}}}|...}} instead.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["entries with outdated source"] = { description = "{{{langname}}} entries that have been partly or fully imported from an outdated source.", parents = {"ප්‍රවේශ නඩත්තුව"}, } labels["entries with inflection not matching pagename"] = { description = "{{{langname}}} entries which have an inflection table whose lemma form does not match the page name.", additional = "This is usually the result of incorrect or missing parameters.", parents = {"ප්‍රවේශ නඩත්තුව"}, hidden = true, can_be_empty = true, } labels["undefined derivations"] = { description = "{{{langname}}} etymologies using {{tl|undefined derivation}}, where a more specific template such as {{tl|borrowed}} or {{tl|inherited}} should be used instead.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["descendants to be fixed in desctree"] = { description = "Entries that use {{tl|desctree}} to link to {{{langname}}} entries with no Descendants section.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["term requests"] = { description = "Entries with {{tl|der}}, {{tl|inh}}, {{tl|m}} and similar templates lacking the parameter for linking to {{{langname}}} terms.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["රතු සබැඳි"] = { description = "Links to {{{langname}}} entries that have not been created yet.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", catfix = false, can_be_empty = true, hidden = true, } labels["යෙදුම්, ස්වරශාස්ත්‍ර හෝඩි උච්චාරණ සහිත"] = { description = "{{{langname}}} යෙදුම්, ජාත්‍යන්තර ස්වරශාස්ත්‍ර හෝඩිය (IPA) භාවිතා කොට උච්චාරණය දක්වා ඇති.", additional = "මෙම ප්‍රවර්ගය හා සබැඳි ඉල්ලීම් සඳහා, [[:Category:Requests for pronunciation in {{{langname}}} entries]] වෙත යොමු වන්න.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with enPR pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of enPR.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with Indic pronunciation"] = { description = "{{langname}} terms that include the pronunciation in the form of ISO 15919.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["IPA pronunciations with invalid separators"] = { description = "{{{langname}}} terms with IPA using invalid separators such as /.ˈ/, /.ˌ/, a dot followed by primary or secondary stress; or /ˈ / or /ˌ /, primary or secondary stress followed by a space.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["terms with hyphenation"] = { description = "{{{langname}}} terms that include hyphenation.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["යෙදුම්, ඕඩියෝ උච්චාරණ සහිත"] = { description = "{{{langname}}} යෙදුම්, ඕඩියෝ ගොනුවක් භාවිතයෙන් උච්චාරණය දක්වා ඇති.", additional = "For requests related to this category, see [[:Category:Requests for audio pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with nonstandard or incorrect audio pronunciations"] = { description = "{{{langname}}} terms which have been tagged as having audio pronunciations which are nonstandard or incorrect.", parents = {"යෙදුම්, ඕඩියෝ උච්චාරණ සහිත"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["entries missing Template:reconstructed"] = { description = "Reconstructed {{{langname}}} entries which do not have the {{tl|reconstructed}} template.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } local function add_manual_param_category(label, desc, addl_intro, include_addl_continuation) local breadcrumb_base, parents, umbrella_parents if label:find("^links") then parents = {"link maintenance"} umbrella_parents = "Link maintenance" breadcrumb_base = label:gsub("^links with ", "") else parents = {"ප්‍රවේශ නඩත්තුව"} -- the call to finalize_labels() farther down will set the right breadcrumb, sortkey and umbrella_parents. end labels[label] = { description = desc or "Pages containing {{{langname}}} " .. label .. ".", additional = addl_intro .. (not include_addl_continuation and "" or "\n\n" .. "Note that the pages in this category are not necessarily the same as the actual term in question. This " .. "frequently happens, for example, with English pages with translation sections, where the term that " .. "triggers the addition of the category is one of the translations."), parents = parents, breadcrumb_base = breadcrumb_base, umbrella_parents = umbrella_parents, -- Set catfix = false because the page will have a mixture of native-language and -- non-native-language pages, but include the normal native-language table of contents headers -- because most pages are in the native language. catfix = false, toc_template = "{{{langcode}}}-categoryTOC", toc_template_full = "{{{langcode}}}-categoryTOC/full", can_be_empty = true, hidden = true, } end add_manual_param_category("terms in nonstandard scripts", nil, "Pages are placed here if they contain terms written in a script that isn't in the language's " .. "list of scripts in the language data. This may mean the script should be added to the list, or that the wrong language code has been used.", true) add_manual_param_category("terms with non-redundant manual transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is different from the transliteration which is automatically generated.", true) add_manual_param_category("terms with redundant transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is the same as the transliteration which is automatically generated.", true) add_manual_param_category("terms with non-redundant manual script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is different from the script code which is automatically generated.", true) add_manual_param_category("terms with redundant script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is the same as the script code which is automatically generated.", true) add_manual_param_category("යෙදුම්, non-redundant non-automated සෝට්කී සහිත", "{{{langname}}} terms with non-redundant non-automated sortkeys.", "Terms are placed here if they have been sorted using a sortkey other than the one which is automatically " .. "generated. This can happen for two reasons:\n# A different sortkey has been specified using the {{para|sort}} " .. "parameter.\n# One or more categories have been added using raw wikitext, which means the page's default " .. "sortkey is used for that category. If that default sortkey is different from the automatic sortkey, then the " .. "page will also be added here.") add_manual_param_category("යෙදුම්, අනු පිටපත් කළ සෝට්කී සහිත", "{{{langname}}} terms with redundant sortkeys.", "Terms are placed here if their sortkey has been specified using the {{para|sort}} parameter, and it the same " .. "as the one which is automatically generated.") add_manual_param_category("links with redundant target parameters", "Pages containing {{{langname}}} links where the alt text could replace the link target, instead of being given " .. "separately.", "This occurs when the only difference between the link target and the alt text is that the alt text contains " .. "diacritics (or other characters) which would have been ignored anyway had they been included in the link " .. "target. For example, {{tl|l|la|amo|amō}} ({{l|la|amo|amō}}) is exactly the same as {{tl|l|la|amō}} " .. "({{l|la|amō}}), because macrons are automatically stripped from Latin link targets, even though they're still " .. "displayed.") add_manual_param_category("links with ignored alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("links with redundant alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter is redundant.", "This occurs when the alt text makes no difference to the output. For example, {{tl|l|en|foo|foo}} " .. "({{l|en|foo|foo}}) is exactly the same as {{tl|l|en|foo}} ({{l|en|foo}}).") add_manual_param_category("links with ignored id parameters", "Pages containing {{{langname}}} links where the {{para|id}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("සබැඳි, අනු පිටපත් කළ විකි සබැඳි සහිත", "Pages containing {{{langname}}} links which contain a redundant wikilink.", "This occurs if link target consists of a single wikilink, which should instead be entered in the " .. "conventional manner without link brackets. For example, {{tl|l|en|<nowiki>[[foo]]</nowiki>}} " .. "is the same as {{tl|l|en|foo}}, and {{tl|l|en|<nowiki>[[foo|bar]]</nowiki>}} is the same as " .. "{{tl|l|en|foo|bar}}.\n\nThis also occurs when link templates are nested inside each other " .. "unnecessarily: e.g. {{tl|l|en|{{tl|l|en|foo}}}}") add_manual_param_category("links with manual fragments", "Pages containing {{{langname}}} links where a manual link fragment has been given.", "This occurs when the link fragment has been specified using {{code|#}} after the term, " .. "which overrides the normal fragment generated by link templates that points to the relevant " .. "language section.\n\nLink fragments are used to point to a specific section on a target page, and " .. "it is preferable to use the {{para|id}} parameter to do this, since it is less likely to break if " .. "additional content is added to the target page: for example, the fragment {{code|#Adjective}} " .. "will start pointing to the wrong section if another language with an adjective section is added above " .. "the intended language.") labels["descendant hubs"] = { description = "{{{langname}}} terms that do not mean more than the sum of their parts but exist for listing two or more inclusion-worthy descendants.", parents = {"ප්‍රවේශ නඩත්තුව"}, } labels["terms needing to be assigned to a sense"] = { description = "{{{langname}}} entries that have terms under headers such as \"Synonyms\" or \"Antonyms\" not assigned to a specific sense of the entry in which they appear. Use [[Template:syn]] or [[Template:ant]] to fix these.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } --[=[ labels["terms with inflection tables"] = { description = "{{{langname}}} entries that contain inflection tables.". additional = "For requests related to this category," see [[:Category:Requests for inflections in {{{langname}}} entries]].", parents = {"ප්‍රවේශ නඩත්තුව"}, } ]=] local function generate_category_with_illustrations(typ, link, example_templates, other_types_in_group) local function make_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss in {{{langname}}}]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end local function make_umbrella_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss by language]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end labels[("යෙදුම්, %ss සහිත"):format(typ)] = { description = ("{{{langname}}} entries that contain %s that were added using templates such as %s."):format(link, example_templates), additional = ("For requests related to this category, see [[:Category:Requests for %ss in {{{langname}}}]]. See also %s."):format( typ, make_other_request_cats()), parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella = { additional = ("For requests related to this category, see [[:Category:Requests for %ss by language]]. See also %s."):format( typ, make_umbrella_other_request_cats()), }, umbrella_parents = ("%s maintenance"):format(mw.getContentLanguage():ucfirst(typ)), } end local function generate_related_categories_with_illustrations(info) for typ, spec in pairs(info) do local other_types = {} for other_type, _ in pairs(info) do if other_type ~= typ then table.insert(other_types, other_type) end end table.sort(other_types) generate_category_with_illustrations(typ, spec.link, spec.example_templates, other_types) end end generate_related_categories_with_illustrations { collocation = { link = "[[collocation]]s", example_templates = "{{tl|co}}", }, ["භාවිත නිදර්ශන"] = { link = "[[usage]] [[example]]s", example_templates = "{{tl|ux}}", }, ["උපුටා දැක්වීම්"] = { link = "[[quotation]]s", example_templates = "{{tl|quote}}, {{tl|quote-book}}, {{tl|quote-journal}}, etc", }, } labels["terms with interlinear glossed text"] = { description = "{{{langname}}} entries that contain interlinear glossed text added using {{tl|interlinear}}.", parents = {"ප්‍රවේශ නඩත්තුව"}, } labels["පද, අනු පිටපත් කළ යොමු පරාමිති සහිත"] = { description = "{{{langname}}} terms that contain a redundant head= parameter in their headword (called using {{tl|head}} or a language-specific equivalent).", additional = "Individual languages can prevent terms from being added to this category by setting `data.no_redundant_head_cat`.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["පද, යොමු වචන පේළි තුළ රතු සබැඳි සහිත"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"රතු සබැඳි"}, breadcrumb_base = "headword lines", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["terms with red links in their inflection tables"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"රතු සබැඳි"}, breadcrumb_base = "inflection tables", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } for _, quot_type in ipairs { "quotations", "usage examples" } do local umbrella_parent = quot_type == "quotations" and "Quotation maintenance" or "Usage example maintenance" labels[quot_type .. " with omitted translation"] = { description = "{{{langname}}} " .. quot_type .. " where a translation would normally be required but the translation has explicitly been omitted by specifying {{code|-}}. The translation should be supplied instead.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella = { parents = {name = umbrella_parent, sort = "omitted translation"}, breadcrumb = "with omitted translation", }, can_be_empty = true, hidden = true, } end for _, pos in ipairs({"nouns", "proper nouns", "verbs", "adjectives", "adverbs", "participles", "determiners", "pronouns", "numerals", "suffixes", "contractions"}) do labels[m_sinhala.sinhala(pos) .. ", යොමු වචන පේළි තුළ රතු සබැඳි සහිත"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"පද, යොමු වචන පේළි තුළ රතු සබැඳි සහිත"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels[pos .. " with red links in their inflection tables"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"terms with red links in their inflection tables"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } end for _, pos in ipairs { "nouns", "proper nouns", "pronouns" } do local label = pos .. " with unknown or uncertain plurals" labels[label] = { description = "{{{langname}}} " .. label .. ".", additional = "Terms are usually added to this category by specifying {{code|?}} as the plural. As much " .. "is possible, a plural should be added or, if the noun is uncountable, indicated appropriately (usually " .. "using {{code|-}} in place of the plural). Some languages support the value {{code|!}} to indicate " .. "that a plural cannot be attested but the noun is theoretically countable.", parents = {pos, "ප්‍රවේශ නඩත්තුව"}, } end -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_labels(labels, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in"}, default_umbrella_parents = "භාෂාව අනුව ප්‍රවේශ නඩත්තු උපප්‍රවර්ග", }) ----------------------------------------------------------------------------- -- -- -- RAW CATEGORIES -- -- -- ----------------------------------------------------------------------------- raw_categories["භාෂාව අනුව ප්‍රවේශ නඩත්තු උපප්‍රවර්ග"] = { description = "Umbrella categories covering topics related to entry maintenance.", additional = "{{{umbrella_meta_msg}}}", parents = { "ඡත්‍ර මෙටා ප්‍රවර්ග", {name = "ප්‍රවේශ නඩත්තුව", is_label = true, sort = " "}, {name = "Entry maintenance", sort = " "}, }, } raw_categories["Citation maintenance"] = { description = "Categories for maintaining citations specified using {{tl|cite-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Collocation maintenance"] = { description = "Categories for maintaining collocations specified using {{tl|co}}, {{tl|coi}} or {{tl|coa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Link maintenance"] = { description = "Categories for maintaining internal links, such as those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Pronunciation maintenance"] = { description = "Categories for maintaining pronunciations specified in pronunciation sections.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Quotation maintenance"] = { description = "Categories for maintaining quotations specified using {{tl|quote-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Usage example maintenance"] = { description = "Categories for maintaining usage examples specified using {{tl|ux}}, {{tl|uxi}} or {{tl|uxa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Citations using nocat parameter"] = { description = "Instances of {{tl|cite-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Citation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotation templates to be cleaned"] = { description = "Instances of quotations using {{tl|quote-text}}.", additional = "They should be converted to other '''[[:Category:Citation templates|quotation templates]]''' if relevant.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using nocat parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using quoted-in parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|quoted_in}} parameter.", additional = "It is recommended to restructure these template calls using the {{para|newversion}} parameter along with associated parameters {{para|2ndauthor}}, {{para|title2}}, {{para|year2}}, {{para|publisher2}} and the like, as described in the documentation for {{tl|quote-book}}.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["ඉල්ලීම්"] = { topright = "{{shortcut|WT:CR|WT:RQ}}", description = "A parent category for the various request categories.", parents = {"ප්‍රවර්ගය:වික්ෂනරිය"}, } raw_categories["Requests by language"] = { description = "Categories with requests in various specific languages.", additional = "{{{umbrella_msg}}}", parents = { {name = "Request subcategories by language", sort = " "}, {name = "ඉල්ලීම්", sort = " "}, }, breadcrumb = "by language", } raw_categories["Request subcategories by language"] = { description = "Umbrella categories covering topics related to requests.", additional = "{{{umbrella_meta_msg}}}", parents = { "ඡත්‍ර මෙටා ප්‍රවර්ග", {name = "ඉල්ලීම්", sort = " "}, }, } raw_categories["Requests for quotations by source"] = { description = "Categories with requests for quotation, broken out by the source of the quotation.", additional = "Some abbreviated names of sources are explained at [[Wiktionary:Abbreviated Authorities in Webster]].", parents = {"Requests for quotations"}, } raw_categories["Requests for quotations"] = { -- FIXME description = "Words are added to this category by the inclusion in their entries of {{tl|rfv-quote}}.", parents = {"ඉල්ලීම්", "Quotation maintenance"}, } raw_categories["Requests for date"] = { description = "Requests for a date to be added to a quotation.", additional = "To add an article to this category, use {{tl|rfdate}} or {{tl|rfdatek}} to include the author. " .. "Please remove the template from the article once the date has been provided.", parents = {"ඉල්ලීම්", "Quotation maintenance"}, } raw_categories["Requests for translations in user-competency categories by number of users"] = { description = "Requests for translations to be added to user-competency categories, sorted by number of users with that competency.", parents = {"ඉල්ලීම්"}, } raw_categories["Requests for translations in user-competency categories by language"] = { description = "Requests for translations to be added to user-competency categories, sorted by language.", parents = {"ඉල්ලීම්"}, hidden = true, } raw_categories["භාෂාව අනුව යෙදුම්, පරිවර්තන සහිත"] = { description = "Terms with translations, sorted by language.", parents = {"භාෂාව අනුව ප්‍රවේශ නඩත්තු උපප්‍රවර්ග"}, breadcrumb_base = "පරිවර්තන", } raw_categories["Entries using missing taxonomic names"] = { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name." .. "\n\nSee [[:Category:mul:Taxonomic names]].", parents = {{name = "ප්‍රවේශ නඩත්තුව", is_label = true, lang = "mul"}}, breadcrumb_base = "missing taxonomic names", hidden = true, } raw_categories["Entries with collapsible category lists for nonexistent categories"] = { description = "Entries where [[Module:collapsible category list]] is used, but the requested category does not exist.", additional = "Normally the culprit is a template like {{tl|prefixsee}} or {{tl|suffixsee}}.", parents = {"Entry maintenance", "Category maintenance"}, hidden = true, } -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_raw_categories(raw_categories, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "requests for", "citations", "quotations", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in", "by", "using"}, }) ----------------------------------------------------------------------------- -- -- -- RAW HANDLERS -- -- -- ----------------------------------------------------------------------------- local function script_name_to_code(name) local sc = require(scripts_module).getByCanonicalName(name) if not sc then error("Unrecognized script name '" .. name .. "'") end return sc:getCode() end --[=[ This array consists of category match specs. Each spec contains one or more properties, whose values are (a) strings that may contain references to other properties using the {{{PROPERTY}}} syntax; (b) functions of one argument, an `items` table of the same properties that are accessible using the {{{PROPERTY}} syntax. Each such spec should have at least a `regex` property that matches the name of the category. Capturing groups in this regex can be referenced in other properties using {{{1}}} for the first group, {{{2}}} for the second group, etc. (or using keys "1", "2", etc. in functions). Property expansion happens recursively if needed (i.e. a property can reference another property, which in turn references a third property). If there is a `language_name` propery, it specifies the language name (and will typically be a reference to a capturing group from the `regex` property); if not specified, it defaults to "{{{1}}}" unless the `nolang` property is set, in which case there is no language name associated with the category name. The language name must be the canonical name of a recognized full language, or an error is thrown; however, if the `allow_etym_lang` property is set, the language name may also be the canonical name of an etymology-only language. Based on the language name, the `language_code` and `language_object` properties are automatically filled in. If `language_name` is an etymology-only language, additional properties `parent_language_name`, `parent_language_code` and `parent_language_object` are set for the parent full language of the etymology-only language. If the `regex` values of multiple category specs match, the first one takes precedence. Recognized or predefined properties: `pagename`: Current pagename. `regex`: See above. `1`, `2`, `3`, ...: See above. `language_name`, `language_code`, `language_object`: See above. `parent_language_name`, `parent_language_code`, `parent_language_object`: See above. `nolang`: See above. `allow_etym_lang`: Language names may be etymology-only languages. See above. `description`: Override the description (normally taken directly from the pagename). `template_name`: Name of template which generates this category. `template_sample_call`: Syntax for calling the template. Defaults to "{{{template_name}}}|{{{language_code}}}". Used to display an example template call and the output of this call. `template_actual_sample_call`: Syntax for calling the template. Takes precedence over `template_sample_call` when generating example template output (but not when displaying an example template call) and is intended for a template call that uses the |nocat=1 parameter. `template_example_output`: Override the text that displays example template output (see `template_sample_call`). `additional_template_description`: Extra text to be displayed after the example template output. `parents`: Parent categories. Should be a list of elements, each of which is an object containing at least a name= and sort= field (same format as parents= for regular raw categories, except that the name= and sort= field will have {{{PROPERTY}}} references expanded). If no parents are specified, and the pagename is of the form "Requests for FOO by language", the parents will be "Request subcategories by language" with FOO as the sort key, along with any parents specified in `additional_umbrella_parents`. Otherwise, the `language_name` property must exist, and the parent will be "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key, along with any parents specified in `additional_parents`. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_parents` is used instead. `additional_parents`: Additional parents to add to the per-language category along with "Requests concerning LANGNAME". `etym_parents`: Parent categories for categories with associated etymology-only languages. The format is the same as `parents`. If omitted, there are two parents by default: (1) The pagename (i.e. category name) with the language name replaced by the corresponding parent language name, with the value of `language_name` as the sort key; (2) "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key. `umbrella`: Parent all-language category. Sort key is based on the language name. This applies *ONLY* if a full language is associated with the category name (i.e. not if `nolang` is set or if `allow_etym_lang` is set and the associated language is an etymology-only language); otherwise there will be no umbrella category. `additional_umbrella_parents`: Additional parents to add to the umbrella (all-language) category along with "Request subcategories by language". `breadcrumb`: Specify the breadcrumb. If `parents` is given, there is no default (i.e. it will end up being the pagename). Otherwise, if the pagename is of the form "Requests for FOO by language", the default breadcrumb will be "FOO". Otherwise it is computed by removing the language name from the pagename and chopping out "Requests for" from the beginning and "in entries" and "for terms" from the end. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_breadcrumb` is used instead. `etym_breadcrumb`: Specify the breadcrumb for categories with associated etymology-only languages. Defaults to the value of `language_name`. `not_hidden_category`: Don't hide the category. `catfix`: Same as `catfix` in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. `toc_template`, `toc_template_full`: Same as the corresponding fields in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. In general, properties can contain references to templates (e.g. {{tl}} and {{para}}), which will be appropriately expanded (this expansion happens in the poscatboiler code, not in this module). The major exception is in the `template_sample_call` and `template_actual_sample_call` properties, which are surrounded by <pre>...</pre> when inserted, so template references are not expanded. Triple-brace property references are still expanded in these properties; but beware that if any of those property references contain template references, they won't be expanded. (This actually happens in the handlers for 'Request for SCRIPT script for LANG terms'; the sample call references {{{script_code}}}, whose definition therefore cannot contain template references. The solution is to define this property using a function.) ]=] local requests_categories = { { regex = "^Requests concerning (.+)$", allow_etym_lang = true, description = "Categories with {{{1}}} entries that need the attention of experienced editors.", parents = {{name = "ප්‍රවේශ නඩත්තුව", is_label = true, sort = "requests"}}, etym_parents = {{name = "Requests concerning {{{parent_language_name}}}", sort = "{{{1}}}"}, {name = "{{{1}}}", sort = "ඉල්ලීම්"}}, umbrella = "Requests by language", breadcrumb = "ඉල්ලීම්", not_hidden_category = true, }, { regex = "^Requests for etymologies in (.+) entries$", allow_etym_lang = true, umbrella = "Requests for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "rfe", }, { regex = "^Requests for expansion of etymologies in (.+) entries$", umbrella = "Requests for expansion of etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "etystub", }, { regex = "^Requests for pronunciation in (.+) entries$", umbrella = "Requests for pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfp", }, { regex = "^Requests for audio pronunciation in (.+) entries$", umbrella = "Requests for audio pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfap", }, { regex = "^Requests for definitions in (.+) entries$", umbrella = "Requests for definitions by language", template_name = "rfdef", }, { regex = "^Requests for clarification of definitions in (.+) entries$", umbrella = "Requests for clarification of definitions by language", template_name = "rfclarify", }, { regex = "^Requests for English equivalent terms in (.+) entries$", umbrella = "Requests for English equivalent terms by language", template_name = "rfeq", }, } for _, spec_with_pos in ipairs { {"inflections", "rfinfl"}, {"plural forms"}, {"tone", "rftone"}, {"accents"}, {"aspect", "rfaspect"}, {"animacy"}, {"gender", "rfgender"}, {"noun class"}, } do local property, rftemplate = unpack(spec_with_pos) table.insert(requests_categories, { -- This is for part-of-speech-specific categories such as -- "Requests for inflections in Northern Ndebele noun entries" or -- "Requests for accents in Ukrainian proper noun entries". -- Here and below, we assume that the part of speech is begins with -- a lowercase letter, while the preceding language name ends in a -- capitalized word. Note that this entry comes before the -- following one and takes precedence over it. regex = ("^Requests for %s in (.-) ([a-z]+[a-z ]*) entries$"):format(property), parents = {{name = ("Requests for %s in {{{language_name}}} entries"):format(property), sort = "{{{2}}}"}}, umbrella = ("Requests for %s of {{pluralize|{{{2}}}}} by language"):format(property), breadcrumb = "{{{2}}}", template_name = rftemplate, template_sample_call = rftemplate and ("{{%s|{{{language_code}}}|{{{2}}}}}"):format(rftemplate) or nil, } ) table.insert(requests_categories, { regex = ("^Requests for %s in (.+) entries$"):format(property), umbrella = ("Requests for %s by language"):format(property), template_name = rftemplate, } ) table.insert(requests_categories, { regex = ("^Requests for %s of (.+) by language$"):format(property), nolang = true, } ) end extend(requests_categories, { { regex = "^Requests for example sentences in (.+)$", umbrella = "Requests for example sentences by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfex", }, { regex = "^Requests for quotations in (.+)$", umbrella = "Requests for quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfquote", }, { regex = "^Requests for translations into (.+)$", allow_etym_lang = true, umbrella = "Requests for translations by language", template_name = "t-needed", catfix = "en", }, { regex = "^Requests for translations of (.+) usage examples$", allow_etym_lang = true, umbrella = "Requests for translations of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|usex}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|usex|nocat=1}}", additional_template_description = "The {{tl|ux}}, {{tl|uxi}}, {{tl|ja-usex}} and {{tl|zh-x}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for translations of (.+) quotations$", allow_etym_lang = true, umbrella = "Requests for translations of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|quote}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|quote|nocat=1}}", additional_template_description = "The {{tl|quote}}, and {{tl|Q}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for review of (.+) translations$", allow_etym_lang = true, umbrella = "Requests for review of translations by language", template_name = "t-check", template_sample_call = "{{t-check|{{{language_code}}}|example}}", template_example_output = "", catfix = "en", }, { regex = "^Requests for transliteration of (.+) terms$", umbrella = "Requests for transliteration by language", template_name = "rftranslit", additional_template_description = "The {{tl|head}} template, and the large number of language-specific variants of it, automatically add " .. "the page to this category if the example is in a foreign language and no transliteration can be generated (particularly in languages without " .. "automated transliteration, such as Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) usage examples$", umbrella = "Requests for transliteration of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rftranslit", template_sample_call = "{{rftranslit|{{{language_code}}}}}", template_actual_sample_call = "{{rftranslit|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) quotations$", umbrella = "Requests for transliteration of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for native script for (.+) terms$", allow_etym_lang = true, etym_parents = { {name = "Requests for native script for {{{parent_language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "native script"}, }, umbrella = "Requests for native script by language", template_name = "rfscript", template_actual_sample_call = "{{rfscript|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for native script in (.+) usage examples$", umbrella = "Requests for native script in usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|usex=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|usex=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example itself is missing but the translation is supplied." }, { regex = "^Requests for native script in (.+) quotations$", umbrella = "Requests for native script in quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|quote=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|quote=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation itself is missing but the translation is supplied." }, { regex = "^Requests for (.+) script for (.+) terms$", language_name = "{{{2}}}", allow_etym_lang = true, parents = {{name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}}, etym_parents = { {name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests for {{{1}}} script for {{{parent_language_name}}} terms", sort = "{{{language_name}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "{{{1}}} script"}, }, umbrella = "Requests for {{{1}}} script by language", breadcrumb = "{{{1}}}", etym_breadcrumb = "{{{1}}}", template_name = "rfscript", -- NOTE: The following is used in `template_sample_call` and `template_actual_sample_call`, meaning the -- conversion of script name to script code needs to be done using an inline function like this, instead of -- a {{#invoke:...}} template call. script_code = function(items) return script_name_to_code(items["1"]) end, template_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for (.+) script by language$", parents = {{name = "Requests for script by language", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, }, { regex = "^Requests for script by language$", nolang = true, }, { regex = "^Requests for images in (.+) entries$", umbrella = "Requests for images by language", template_name = "rfi", }, { regex = "^Requests for references for (.+) terms$", umbrella = "Requests for references by language", template_name = "rfref", }, { regex = "^Requests for references for etymologies in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "etymologies"}}, umbrella = "Requests for references for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, breadcrumb = "නිරුක්ති", template_name = "rfv-etym", }, { regex = "^Requests for references for pronunciations in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "pronunciations"}}, umbrella = "Requests for references for pronunciations by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, breadcrumb = "Pronunciations", template_name = "rfv-pron", }, { regex = "^Requests for attention concerning (.+)$", umbrella = "Requests for attention by language", breadcrumb = "Attention", template_name = "attention", template_sample_call = "{{attention|{{{language_code}}}|insert a brief description of the request here}}", template_example_output = "This template does not generate any text in entries, but can be visualised by enabling the Catch My Attention gadget. See {{section link|Template:attention#Visibility}}.", -- These pages typically contain a mixture of English and native-language entries, so disable catfix. catfix = false, -- Setting catfix = false will normally trigger the English table of contents template. -- We still want the native-language table of contents template, though. toc_template = "{{{language_code}}}-categoryTOC", toc_template_full = "{{{language_code}}}-categoryTOC/full", }, { regex = "^Requests for cleanup in (.+) entries$", umbrella = "Requests for cleanup by language", template_name = "rfc", template_actual_sample_call = "{{rfc|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for cleanup of Pronunciation N headers in (.+) entries$", umbrella = "Requests for cleanup of Pronunciation N headers by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfc-pron-n", template_actual_sample_call = "{{rfc-pron-n|{{{language_code}}}|nocat=1}}", template_example_output = "This template does not generate any text in entries.", additional_template_description = [=[ The purpose of this category is to tag entries that use headers with "Pronunciation" and a number. While these headers and structure are sometimes used, they are not specifically prescribed by [[WT:ELE]]. No complete proposal has yet been made on how they should work, what the semantics are, or how they interact with multiple etymologies. As a result they should generally be avoided. Instead, merge the entries (possibly under multiple Etymology sections, if appropriate), and list all pronunciations, appropriately tagged, under a Pronunciation header. [[User:KassadBot|KassadBot]] tags these entries (or used to tag these entries, when the bot was operational). At some point if a proposal is made and adopted as policy, these entries should be reviewed. This category is hidden.]=], }, { regex = "^Requests for deletion in (.+) entries$", umbrella = "Requests for deletion by language", template_name = "rfd", template_actual_sample_call = "{{rfd|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for verification in (.+) entries$", umbrella = "Requests for verification by language", template_name = "rfv", }, { regex = "^Requests for attention in (.+) etymologies$", umbrella = "Requests for attention by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, }, { regex = "^Requests for quotations/(.+)$", description = "Requests for a quotation or for quotations from {{{1}}}.", parents = {{name = "Requests for quotations by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfquotek", template_sample_call = "{{rfquotek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfquotek|und|{{{1}}}}}", }, { regex = "^Requests for date in (.+) entries$", umbrella = "Requests for date by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfdate", additional_template_description = "The quotation templates, such as {{tl|quote-book}} and {{tl|quote-journal}}, " .. "automatically add the page to this category if neither {{para|date}} nor {{para|year}} is provided. Providing the " .. "parameter in each case on the page automatically removes the article from this category. See " .. "[[Wiktionary:Quotations]] for information about formatting dates and quotations.", }, { regex = "^Requests for date/(.+)$", description = "{{rfd|section=Category:Requests for date by source}}Requests for a date for a quotation or quotations from {{{1}}}.", parents = {{name = "Requests for date by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfdatek", template_sample_call = "{{rfdatek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfdatek|und|{{{1}}}}}", }, { regex = "^Requests for attestation of (.+) terms$", umbrella = "Requests for attestation of terms by language", breadcrumb = "Attestation", additional_template_description = "The {{tl|LDL}} template adds this category when a language code is supplied in {{para|1}} (as it should be)." }, }) local user_competency_additional_template_description = "This is added by user-competency categories such as " .. "[[:Category:User fr-4]], which groups users who speak French at level 4 (near-native proficiency), when " .. "the native-language text indicating this fact is missing. The appropriate translation should mirror the " .. "English text also displayed (e.g. in this case \"These users speak French at a '''near native''' " .. "level.\"), and should be supplied to {{tl|auto cat}} using the {{para|text}} parameter. The mention of the " .. "language in the text should be surrounded by double angle brackets, e.g. \"&lt;&lt;français>>\", which " .. "causes it to be automatically linked to the appropriate parent category." local user_competency_parents = {{name = "Requests for translations in user-competency categories by number of users", sort = function(items) return " " .. ("%010d"):format(items["1"]) end, }} extend(requests_categories, { { regex = "^Requests for translations in user%-competency categories with ([0-9]+)%-([0-9]+) users$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}}-{{{2}}} users.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}-{{{2}}}", nolang = true, }, { regex = "^Requests for translations in user%-competency categories with ([0-9]+) (users?)$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}} {{{2}}}.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}", nolang = true, } }) table.insert(raw_handlers, function(data) local items local function init_items() items = {pagename = data.category} end local function expand_value(item, val) if not val then return val elseif is_callable(val) then return expand_value(item .. " ⇒ function", val(items)) elseif type(val) == "table" then for k, v in pairs(val) do val[k] = expand_value(item .. " ⇒ " .. k, v) end return val elseif type(val) == "number" then val = tostring(val) end if type(val) ~= "string" then error(("The item '%s' on page %s is of type %s and can't be concatenated"):format( item, items.pagename, type(val))) end -- Replaces pseudo-template code {{{ }}} with the corresponding member of the "items" table. Has to be done -- recursively, since some of the items are nested: -- {{{template_sample_call_with_temp}}} -- ⇓ -- {{{{{template_name}}}|{{{language_code}}}}} -- ⇓ -- {{attention|en}} if val:find("{{{") then val = mw.ustring.gsub(val, "{{{([^%}%{]+)}}}", function(prop) local propval = items[prop] if not propval then error(("The item '%s' (expanded from property '%s' on page %s) was not found in the 'items' table"): format(prop, item, items.pagename)) end return expand_value(item .. " ⇒ " .. prop, propval) end ) end return val end local function expand_items_value(item) return expand_value(item, items[item]) end local function convert_items_to_category_data(items) if not items.nolang then items.language_name = items.language_name or "{{{1}}}" items.language_name = expand_items_value("language_name") items.language_object = require(languages_module).getByCanonicalName(items.language_name, true, items.allow_etym_lang) items.language_code = items.language_object:getCode() items.is_etym_lang = items.language_object:hasType("etymology-only") if items.is_etym_lang then items.parent_language_object = items.language_object:getFull() -- Reject weird cases where etymology language has no parent. if not items.parent_language_object then return nil end items.parent_language_code = items.parent_language_object:getCode() items.parent_language_name = items.parent_language_object:getCanonicalName() -- Reject weird cases where the parent language has the same name as the child etymology language. In -- that case, we'll get an infinite parent-category loop. This actually happens, e.g. with Rudbari and -- Bashkardi. if items.parent_language_name == items.language_name then return nil end else end end if items.template_name then items.template_sample_call = items.template_sample_call or "{{{{{template_name}}}|{{{language_code}}}}}" items.full_text_about_the_template = "මෙම ඉල්ලීම කිරීම සඳහා, මෙම භාෂාව සඳහා, අදාළ ප්‍රවේශය තුළ මෙම කේතය භාවිතා කරන්න ([[Template:{{{template_name}}}]] සඳහා වන උපදෙස් පත්‍රිකාව වෙත ද අවධානය යොමු කරන්න):\n\n<pre>{{{template_sample_call}}}</pre>" if items.template_example_output then items.full_text_about_the_template = items.full_text_about_the_template .. " " .. items.template_example_output else items.template_actual_sample_call = items.template_actual_sample_call or items.template_sample_call items.full_text_about_the_template = items.full_text_about_the_template .. "\nඑමගින් පහත දැක්වෙන නිවේදනය ප්‍රදර්ශනය වෙයි:\n\n{{{template_actual_sample_call}}}" end if items.additional_template_description then items.full_text_about_the_template = items.full_text_about_the_template .. "\n\n" .. items.additional_template_description end else items.full_text_about_the_template = items.additional_template_description end local parents, breadcrumb if items.is_etym_lang then parents = items.etym_parents breadcrumb = expand_items_value("etym_breadcrumb") or items.language_name else parents = items.parents breadcrumb = expand_items_value("breadcrumb") end if parents then for _, parent in ipairs(parents) do parent.name = expand_value("parent.name", parent.name) parent.sort = {sort_base = expand_value("parent.sort", parent.sort), lang = "en"} end else local umbrella_type = items.pagename:match("^Requests for (.+) by language$") if umbrella_type then breadcrumb = breadcrumb or umbrella_type parents = {{name = "Request subcategories by language", sort = umbrella_type}} if items.additional_umbrella_parents then extend(parents, items.additional_umbrella_parents) end elseif not items.language_name then error("Internal error: Don't know how to compute parents for non-language-specific category '" .. items.pagename .. "'") else local requests_concerning_breadcrumb = items.pagename:gsub(" " .. pattern_escape(items.language_name), "") requests_concerning_breadcrumb = requests_concerning_breadcrumb:gsub("^Requests for ", ""):gsub(" in entries$", ""):gsub(" for terms$", "") local requests_concerning_parent = { name = "Requests concerning " .. items.language_name, sort = {sort_base = requests_concerning_breadcrumb, lang = "en"} } if items.is_etym_lang then local parent_lang_cat = items.pagename:gsub(pattern_escape(items.language_name), replacement_escape(items.parent_language_name)) parents = { {name = parent_lang_cat, sort = {sort_base = items.language_name, lang = "en"}}, requests_concerning_parent } else breadcrumb = breadcrumb or requests_concerning_breadcrumb parents = {requests_concerning_parent} if items.additional_parents then extend(parents, items.additional_parents) end end end end if not items.nolang and not items.is_etym_lang and items.umbrella ~= false then table.insert(parents, { name = expand_items_value("umbrella"), sort = {sort_base = items.language_name, lang = "en"} }) end local additional = expand_items_value("full_text_about_the_template") if items.pagename:find(" by language$") then additional = "{{{umbrella_msg}}}" .. (additional and "\n\n" .. additional or "") end return { description = expand_items_value("description") or items.pagename .. ".", lang = items.parent_language_code or items.language_code, additional = additional, parents = parents, -- If no breadcrumb= and not an etym-only language, it will default to the category name breadcrumb = breadcrumb, catfix = expand_items_value("catfix"), toc_template = expand_items_value("toc_template"), toc_template_full = expand_items_value("toc_template_full"), hidden = not items.nolang and not items.not_hidden_category, can_be_empty = true, } end -- First look for a regular (usually language or script-specific) category. for _, category in ipairs(requests_categories) do local matchvals = {mw.ustring.match(data.category, category.regex)} if #matchvals > 0 then init_items() for key, value in pairs(category) do items[key] = value end for key, value in ipairs(matchvals) do items["" .. key] = value end local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end -- Now look for umbrella categories. for _, category in ipairs(requests_categories) do if data.category == category.umbrella then init_items() items.nolang = true items.additional_umbrella_parents = category.additional_umbrella_parents local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end return nil end) table.insert(raw_handlers, function(data) local langname = data.category:match("^යෙදුම්, (.+) පරිවර්තන සහිත$") local lang = langname and require(languages_module).getByCanonicalName(langname, true, true) if lang then local langcode = lang:getCode() local parents, breadcrumb_and_first_sort_key if lang:hasType("etymology-only") then parents = { "යෙදුම්, " .. lang:getFullName() .. " පරිවර්තන සහිත", {name = langname, sort = "පරිවර්තන"}, } breadcrumb_and_first_sort_key = lang:getCanonicalName() else parents = { {name = "ප්‍රවේශ නඩත්තුව", is_label = true, lang = langcode}, { name = "භාෂාව අනුව යෙදුම්, පරිවර්තන සහිත", sort = {sort_base = langname, lang = "en"} }, } breadcrumb_and_first_sort_key = "පරිවර්තන" end return { description = "Entries that contain translations into " .. langname .. " which were added using one of the translation templates, such as {{tl|t|" .. langcode .. "|...}}, {{tl|t+|" .. langcode .. "|...}}, etc.", parents = parents, breadcrumb_and_first_sort_key = breadcrumb_and_first_sort_key, catfix = false, can_be_empty = true, hidden = true, } end end) local recognized_taxtypes = require(table_module).listToSet { "ambiguous", "binomial", "branch", "clade", "cladus", "class", "cohort", "convariety", "cultivar group", "cultivar", "division", "empire", "epifamily", "epithet", "family", "form taxon", "form", "genus", "grade", "grandorder", "group", "hybrid", "informal group", "infraclass", "infracohort", "infrakingdom", "infraorder", "infraphylum", "infraspecies", "infratribe", "kingdom", "magnorder", "megacohort", "mirorder", "morph", "nothogenus", "nothospecies", "nothosubspecies", "nothovariety", "obsolete", "oofamily", "order", "parvclass", "parvorder", "phylum", "section", "series", "serovar", "species group", "species", "stem", "stirps", "strain", "subclass", "subcohort", "subdivision", "subfamily", "subgenus", "subgroup", "subinfraorder", "subkingdom", "suborder", "subphylum", "subsection", "subseries", "subspecies", "subterclass", "subtribe", "superclass", "supercohort", "superfamily", "supergroup", "superorder", "superphylum", "supertribe", "taxon", "tribe", "trinomial", "undescribed species", "unknown", "unranked group", "variety", "virus complex", } table.insert(raw_handlers, function(data) local taxtype = data.category:match("^Entries using missing taxonomic name %((.*)%)$") if taxtype and recognized_taxtypes[taxtype] then return { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name.", parents = {{name = "Entries using missing taxonomic names", sort = {sort_base = taxtype, lang = "en"}}}, breadcrumb = taxtype, hidden = true, } end end) return {LABELS = labels, RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers} q8ddbraudiaj8y77kuu4qivx9euia9p 239387 239380 2026-11-22T09:33:32Z Lee 19 "entries with etymology trees" සිට "ප්‍රවේශ, නිරුක්ති ශාඛා සහිත" වෙතට 239387 Scribunto text/plain local m_sinhala = require("Module:sinhala") local labels = {} local raw_categories = {} local raw_handlers = {} local functions_module = "Module:fun" local languages_module = "Module:languages" local scripts_module = "Module:scripts" local string_pattern_escape_module = "Module:string/patternEscape" local string_replacement_escape_module = "Module:string/replacementEscape" local table_module = "Module:table" local extend = require(table_module).extend local is_callable = require(functions_module).is_callable local pattern_escape = require(string_pattern_escape_module) local replacement_escape = require(string_replacement_escape_module) local unpack = unpack or table.unpack -- Lua 5.2 compatibility ----------------------------------------------------------------------------- -- -- -- LABELS -- -- -- ----------------------------------------------------------------------------- labels["ප්‍රවේශ නඩත්තුව"] = { description = "{{{langname}}} entries, or entries in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement by editors.", parents = {{name = "{{{langcat}}}", raw = true}}, breadcrumb_base = "ප්‍රවේශ නඩත්තුව", -- so the word 'maintenance' doesn't get chopped off umbrella_parents = {name = "ප්‍රවේශ නඩත්තුව", sort = " "}, } labels["etymology maintenance"] = { description = "{{{langname}}} etymology sections, or etymology sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = {name = "Etymology maintenance", sort = " "}, } labels["link maintenance"] = { description = "{{{langname}}} entries with internal links, or entries in other languages containing internal links to {{{langname}}} terms, that are being tracked for attention and improvement.", additional = "Internal links are those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = {name = "Link maintenance", sort = " "}, } labels["pronunciation maintenance"] = { description = "{{{langname}}} pronunciation sections, or pronunciation sections in other languages containing {{{langname}}} terms, that are being tracked for attention and improvement.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = {name = "Pronunciation maintenance", sort = " "}, } labels["ප්‍රවේශ, දෝෂ සහගත භාෂා ශීර්ෂක සහිත"] = { description = "{{{langname}}} ප්‍රවේශ, වැරදි භාෂා ශීර්ෂක යටතේ දක්වා ඇති.", additional = "හේතු කිහිපයක් නිසා මෙය සිදුවිය හැකිය:\n" .. "* අක්ෂර වින්‍යාසය දෝෂ (Typos).\n" .. "* විනාශ කිරීම් (Vandalism).\n" .. "* වැරදි භාෂා කේතය භාවිතා කිරීම.\n" .. "* භාෂාව සඳහා වන විකල්ප නාමයක් භාවිතා කිරීම.\n" .. "* භාෂා දත්ත මොඩියුල තුළ භාෂා නාම සඳහා දක්වා නොමැති විශේෂ අනුකල්ෂණ භාවිතා කිරීම.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["entries without References header"] = { description = "{{{langname}}} entries without a References header.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["entries without References or Further reading header"] = { description = "{{{langname}}} entries without a References or Further reading header.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["entries that don't exist"] = { description = "{{{langname}}} terms that do not meet the [[Wiktionary:Criteria for inclusion|criteria for inclusion]] (CFI). They are added to the category with the template {{tl|no entry|{{{langcode}}}}}.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = "මූලධර්ම", } labels["ප්‍රවේශ, නිරුක්ති ශාඛා සහිත"] = { description = "{{{langname}}} entries that display an etymology tree generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology texts"] = { description = "{{{langname}}} entries that display an etymology generated by the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymon"] = { description = "{{{langname}}} entries that use the template {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries with etymology text stop language not in chain"] = { description = "{{{langname}}} entries where {{tl|etymon}} is used with {{para|text}} set to stop at a language but that language never appears in the rendered etymology chain.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon that cannot be found, either because the target page does not exist (redlink) or because it has no {{tl|etymon}} template.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing ambiguous etymons"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon without the ID, when the target page contains multiple {{tl|etymon}} templates, and an ID is therefore required to select the correct {{tl|etymon}}.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons with mismatched IDs"] = { description = "Entries which use the {{tl|etymon}} template with a mismatched ID. For example, {{code|lang:entry<id:mismatched ID>}}", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with multiple etymons missing IDs"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one {{tl|etymon}} template for the same language, where at least one of those templates has no {{para|id}}. When several {{tl|etymon}} templates share a language section, each must have a distinct {{para|id}} so that links and descendants logic can tell them apart.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing pages with etymology sections missing etymons"] = { description = "Entries which use the {{tl|etymon}} template to link to a page that has more than one etymology section for the same language, where at least one section contains a {{tl|etymon}} template for that language and at least one other etymology section does not.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has no Descendants section.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["entries referencing etymons without this term in Descendants sections"] = { description = "Entries which use the {{tl|etymon}} template to reference an etymon whose source entry has a Descendants section, but does not list the current term there.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["ප්‍රවේශ, ඍජු එක් කිරීම මගින් භාෂා නාම ප්‍රවර්ග දක්වා ඇති"] = { description = "{{{langname}}} entries that have been placed in a language name category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langname}}} ...]]}}). They should be added using {{tl|cln|{{{langcode}}}|...}} instead.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["ප්‍රවේශ, ඍජු එක් කිරීම මගින් මාතෘකා ප්‍රවර්ග දක්වා ඇති"] = { description = "{{{langname}}} entries that have been placed in a topic category using raw wiki markup (i.e. {{code|[[<nowiki/>Category:{{{langcode}}}:...]]}}). They should be added using {{tl|C|{{{langcode}}}|...}} instead.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella_parents = "Category maintenance", can_be_empty = true, hidden = true, } labels["entries with outdated source"] = { description = "{{{langname}}} entries that have been partly or fully imported from an outdated source.", parents = {"ප්‍රවේශ නඩත්තුව"}, } labels["entries with inflection not matching pagename"] = { description = "{{{langname}}} entries which have an inflection table whose lemma form does not match the page name.", additional = "This is usually the result of incorrect or missing parameters.", parents = {"ප්‍රවේශ නඩත්තුව"}, hidden = true, can_be_empty = true, } labels["undefined derivations"] = { description = "{{{langname}}} etymologies using {{tl|undefined derivation}}, where a more specific template such as {{tl|borrowed}} or {{tl|inherited}} should be used instead.", parents = {"etymology maintenance"}, umbrella_parents = "Etymology maintenance", can_be_empty = true, hidden = true, } labels["descendants to be fixed in desctree"] = { description = "Entries that use {{tl|desctree}} to link to {{{langname}}} entries with no Descendants section.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["term requests"] = { description = "Entries with {{tl|der}}, {{tl|inh}}, {{tl|m}} and similar templates lacking the parameter for linking to {{{langname}}} terms.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["රතු සබැඳි"] = { description = "Links to {{{langname}}} entries that have not been created yet.", parents = {"link maintenance"}, umbrella_parents = "Link maintenance", catfix = false, can_be_empty = true, hidden = true, } labels["යෙදුම්, ස්වරශාස්ත්‍ර හෝඩි උච්චාරණ සහිත"] = { description = "{{{langname}}} යෙදුම්, ජාත්‍යන්තර ස්වරශාස්ත්‍ර හෝඩිය (IPA) භාවිතා කොට උච්චාරණය දක්වා ඇති.", additional = "මෙම ප්‍රවර්ගය හා සබැඳි ඉල්ලීම් සඳහා, [[:Category:Requests for pronunciation in {{{langname}}} entries]] වෙත යොමු වන්න.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with enPR pronunciation"] = { description = "{{{langname}}} terms that include the pronunciation in the form of enPR.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with Indic pronunciation"] = { description = "{{langname}} terms that include the pronunciation in the form of ISO 15919.", additional = "For requests related to this category, see [[:Category:Requests for pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["IPA pronunciations with invalid separators"] = { description = "{{{langname}}} terms with IPA using invalid separators such as /.ˈ/, /.ˌ/, a dot followed by primary or secondary stress; or /ˈ / or /ˌ /, primary or secondary stress followed by a space.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["terms with hyphenation"] = { description = "{{{langname}}} terms that include hyphenation.", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["යෙදුම්, ඕඩියෝ උච්චාරණ සහිත"] = { description = "{{{langname}}} යෙදුම්, ඕඩියෝ ගොනුවක් භාවිතයෙන් උච්චාරණය දක්වා ඇති.", additional = "For requests related to this category, see [[:Category:Requests for audio pronunciation in {{{langname}}} entries]].", parents = {"pronunciation maintenance"}, umbrella_parents = "Pronunciation maintenance", } labels["terms with nonstandard or incorrect audio pronunciations"] = { description = "{{{langname}}} terms which have been tagged as having audio pronunciations which are nonstandard or incorrect.", parents = {"යෙදුම්, ඕඩියෝ උච්චාරණ සහිත"}, umbrella_parents = "Pronunciation maintenance", can_be_empty = true, hidden = true, } labels["entries missing Template:reconstructed"] = { description = "Reconstructed {{{langname}}} entries which do not have the {{tl|reconstructed}} template.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } local function add_manual_param_category(label, desc, addl_intro, include_addl_continuation) local breadcrumb_base, parents, umbrella_parents if label:find("^links") then parents = {"link maintenance"} umbrella_parents = "Link maintenance" breadcrumb_base = label:gsub("^links with ", "") else parents = {"ප්‍රවේශ නඩත්තුව"} -- the call to finalize_labels() farther down will set the right breadcrumb, sortkey and umbrella_parents. end labels[label] = { description = desc or "Pages containing {{{langname}}} " .. label .. ".", additional = addl_intro .. (not include_addl_continuation and "" or "\n\n" .. "Note that the pages in this category are not necessarily the same as the actual term in question. This " .. "frequently happens, for example, with English pages with translation sections, where the term that " .. "triggers the addition of the category is one of the translations."), parents = parents, breadcrumb_base = breadcrumb_base, umbrella_parents = umbrella_parents, -- Set catfix = false because the page will have a mixture of native-language and -- non-native-language pages, but include the normal native-language table of contents headers -- because most pages are in the native language. catfix = false, toc_template = "{{{langcode}}}-categoryTOC", toc_template_full = "{{{langcode}}}-categoryTOC/full", can_be_empty = true, hidden = true, } end add_manual_param_category("terms in nonstandard scripts", nil, "Pages are placed here if they contain terms written in a script that isn't in the language's " .. "list of scripts in the language data. This may mean the script should be added to the list, or that the wrong language code has been used.", true) add_manual_param_category("terms with non-redundant manual transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is different from the transliteration which is automatically generated.", true) add_manual_param_category("terms with redundant transliterations", nil, "Pages are placed here if they contain terms whose transliteration has been specified manually using " .. "{{para|tr}} or a similar parameter and is the same as the transliteration which is automatically generated.", true) add_manual_param_category("terms with non-redundant manual script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is different from the script code which is automatically generated.", true) add_manual_param_category("terms with redundant script codes", nil, "Pages are placed here if they contain terms whose script code has been specified manually using " .. "{{para|sc}} or a similar parameter and is the same as the script code which is automatically generated.", true) add_manual_param_category("යෙදුම්, non-redundant non-automated සෝට්කී සහිත", "{{{langname}}} terms with non-redundant non-automated sortkeys.", "Terms are placed here if they have been sorted using a sortkey other than the one which is automatically " .. "generated. This can happen for two reasons:\n# A different sortkey has been specified using the {{para|sort}} " .. "parameter.\n# One or more categories have been added using raw wikitext, which means the page's default " .. "sortkey is used for that category. If that default sortkey is different from the automatic sortkey, then the " .. "page will also be added here.") add_manual_param_category("යෙදුම්, අනු පිටපත් කළ සෝට්කී සහිත", "{{{langname}}} terms with redundant sortkeys.", "Terms are placed here if their sortkey has been specified using the {{para|sort}} parameter, and it the same " .. "as the one which is automatically generated.") add_manual_param_category("links with redundant target parameters", "Pages containing {{{langname}}} links where the alt text could replace the link target, instead of being given " .. "separately.", "This occurs when the only difference between the link target and the alt text is that the alt text contains " .. "diacritics (or other characters) which would have been ignored anyway had they been included in the link " .. "target. For example, {{tl|l|la|amo|amō}} ({{l|la|amo|amō}}) is exactly the same as {{tl|l|la|amō}} " .. "({{l|la|amō}}), because macrons are automatically stripped from Latin link targets, even though they're still " .. "displayed.") add_manual_param_category("links with ignored alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("links with redundant alt parameters", "Pages containing {{{langname}}} links where the {{para|alt}} parameter is redundant.", "This occurs when the alt text makes no difference to the output. For example, {{tl|l|en|foo|foo}} " .. "({{l|en|foo|foo}}) is exactly the same as {{tl|l|en|foo}} ({{l|en|foo}}).") add_manual_param_category("links with ignored id parameters", "Pages containing {{{langname}}} links where the {{para|id}} parameter has been ignored.", "This occurs when the main linked text includes a wikilink.") add_manual_param_category("සබැඳි, අනු පිටපත් කළ විකි සබැඳි සහිත", "Pages containing {{{langname}}} links which contain a redundant wikilink.", "This occurs if link target consists of a single wikilink, which should instead be entered in the " .. "conventional manner without link brackets. For example, {{tl|l|en|<nowiki>[[foo]]</nowiki>}} " .. "is the same as {{tl|l|en|foo}}, and {{tl|l|en|<nowiki>[[foo|bar]]</nowiki>}} is the same as " .. "{{tl|l|en|foo|bar}}.\n\nThis also occurs when link templates are nested inside each other " .. "unnecessarily: e.g. {{tl|l|en|{{tl|l|en|foo}}}}") add_manual_param_category("links with manual fragments", "Pages containing {{{langname}}} links where a manual link fragment has been given.", "This occurs when the link fragment has been specified using {{code|#}} after the term, " .. "which overrides the normal fragment generated by link templates that points to the relevant " .. "language section.\n\nLink fragments are used to point to a specific section on a target page, and " .. "it is preferable to use the {{para|id}} parameter to do this, since it is less likely to break if " .. "additional content is added to the target page: for example, the fragment {{code|#Adjective}} " .. "will start pointing to the wrong section if another language with an adjective section is added above " .. "the intended language.") labels["descendant hubs"] = { description = "{{{langname}}} terms that do not mean more than the sum of their parts but exist for listing two or more inclusion-worthy descendants.", parents = {"ප්‍රවේශ නඩත්තුව"}, } labels["terms needing to be assigned to a sense"] = { description = "{{{langname}}} entries that have terms under headers such as \"Synonyms\" or \"Antonyms\" not assigned to a specific sense of the entry in which they appear. Use [[Template:syn]] or [[Template:ant]] to fix these.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } --[=[ labels["terms with inflection tables"] = { description = "{{{langname}}} entries that contain inflection tables.". additional = "For requests related to this category," see [[:Category:Requests for inflections in {{{langname}}} entries]].", parents = {"ප්‍රවේශ නඩත්තුව"}, } ]=] local function generate_category_with_illustrations(typ, link, example_templates, other_types_in_group) local function make_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss in {{{langname}}}]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end local function make_umbrella_other_request_cats() if not other_types_in_group then return nil end local cats = {} for _, other_type in ipairs(other_types_in_group) do table.insert(cats, ("[[:Category:Requests for %ss by language]]"):format(other_type)) end return require(table_module).serialCommaJoin(cats) end labels[("යෙදුම්, %ss සහිත"):format(typ)] = { description = ("{{{langname}}} entries that contain %s that were added using templates such as %s."):format(link, example_templates), additional = ("For requests related to this category, see [[:Category:Requests for %ss in {{{langname}}}]]. See also %s."):format( typ, make_other_request_cats()), parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella = { additional = ("For requests related to this category, see [[:Category:Requests for %ss by language]]. See also %s."):format( typ, make_umbrella_other_request_cats()), }, umbrella_parents = ("%s maintenance"):format(mw.getContentLanguage():ucfirst(typ)), } end local function generate_related_categories_with_illustrations(info) for typ, spec in pairs(info) do local other_types = {} for other_type, _ in pairs(info) do if other_type ~= typ then table.insert(other_types, other_type) end end table.sort(other_types) generate_category_with_illustrations(typ, spec.link, spec.example_templates, other_types) end end generate_related_categories_with_illustrations { collocation = { link = "[[collocation]]s", example_templates = "{{tl|co}}", }, ["භාවිත නිදර්ශන"] = { link = "[[usage]] [[example]]s", example_templates = "{{tl|ux}}", }, ["උපුටා දැක්වීම්"] = { link = "[[quotation]]s", example_templates = "{{tl|quote}}, {{tl|quote-book}}, {{tl|quote-journal}}, etc", }, } labels["terms with interlinear glossed text"] = { description = "{{{langname}}} entries that contain interlinear glossed text added using {{tl|interlinear}}.", parents = {"ප්‍රවේශ නඩත්තුව"}, } labels["පද, අනු පිටපත් කළ යොමු පරාමිති සහිත"] = { description = "{{{langname}}} terms that contain a redundant head= parameter in their headword (called using {{tl|head}} or a language-specific equivalent).", additional = "Individual languages can prevent terms from being added to this category by setting `data.no_redundant_head_cat`.", parents = {"ප්‍රවේශ නඩත්තුව"}, can_be_empty = true, hidden = true, } labels["පද, යොමු වචන පේළි තුළ රතු සබැඳි සහිත"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"රතු සබැඳි"}, breadcrumb_base = "headword lines", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels["terms with red links in their inflection tables"] = { description = "{{{langname}}} terms that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"රතු සබැඳි"}, breadcrumb_base = "inflection tables", umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } for _, quot_type in ipairs { "quotations", "usage examples" } do local umbrella_parent = quot_type == "quotations" and "Quotation maintenance" or "Usage example maintenance" labels[quot_type .. " with omitted translation"] = { description = "{{{langname}}} " .. quot_type .. " where a translation would normally be required but the translation has explicitly been omitted by specifying {{code|-}}. The translation should be supplied instead.", parents = {"ප්‍රවේශ නඩත්තුව"}, umbrella = { parents = {name = umbrella_parent, sort = "omitted translation"}, breadcrumb = "with omitted translation", }, can_be_empty = true, hidden = true, } end for _, pos in ipairs({"nouns", "proper nouns", "verbs", "adjectives", "adverbs", "participles", "determiners", "pronouns", "numerals", "suffixes", "contractions"}) do labels[m_sinhala.sinhala(pos) .. ", යොමු වචන පේළි තුළ රතු සබැඳි සහිත"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their headword lines.", parents = {"පද, යොමු වචන පේළි තුළ රතු සබැඳි සහිත"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } labels[pos .. " with red links in their inflection tables"] = { description = "{{{langname}}} " .. pos .. " that contain red links (i.e. uncreated forms) in their inflection tables.", parents = {"terms with red links in their inflection tables"}, breadcrumb_base = pos, umbrella_parents = "Link maintenance", can_be_empty = true, hidden = true, } end for _, pos in ipairs { "nouns", "proper nouns", "pronouns" } do local label = pos .. " with unknown or uncertain plurals" labels[label] = { description = "{{{langname}}} " .. label .. ".", additional = "Terms are usually added to this category by specifying {{code|?}} as the plural. As much " .. "is possible, a plural should be added or, if the noun is uncountable, indicated appropriately (usually " .. "using {{code|-}} in place of the plural). Some languages support the value {{code|!}} to indicate " .. "that a plural cannot be attested but the noun is theoretically countable.", parents = {pos, "ප්‍රවේශ නඩත්තුව"}, } end -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_labels(labels, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in"}, default_umbrella_parents = "භාෂාව අනුව ප්‍රවේශ නඩත්තු උපප්‍රවර්ග", }) ----------------------------------------------------------------------------- -- -- -- RAW CATEGORIES -- -- -- ----------------------------------------------------------------------------- raw_categories["භාෂාව අනුව ප්‍රවේශ නඩත්තු උපප්‍රවර්ග"] = { description = "Umbrella categories covering topics related to entry maintenance.", additional = "{{{umbrella_meta_msg}}}", parents = { "ඡත්‍ර මෙටා ප්‍රවර්ග", {name = "ප්‍රවේශ නඩත්තුව", is_label = true, sort = " "}, {name = "Entry maintenance", sort = " "}, }, } raw_categories["Citation maintenance"] = { description = "Categories for maintaining citations specified using {{tl|cite-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Collocation maintenance"] = { description = "Categories for maintaining collocations specified using {{tl|co}}, {{tl|coi}} or {{tl|coa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Link maintenance"] = { description = "Categories for maintaining internal links, such as those specified using {{tl|l}}, {{tl|m}} or any other template linking to another Wiktionary term.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Pronunciation maintenance"] = { description = "Categories for maintaining pronunciations specified in pronunciation sections.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Quotation maintenance"] = { description = "Categories for maintaining quotations specified using {{tl|quote-*}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Usage example maintenance"] = { description = "Categories for maintaining usage examples specified using {{tl|ux}}, {{tl|uxi}} or {{tl|uxa}}.", parents = {"Entry maintenance", "Wiktionary maintenance"}, } raw_categories["Citations using nocat parameter"] = { description = "Instances of {{tl|cite-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Citation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotation templates to be cleaned"] = { description = "Instances of quotations using {{tl|quote-text}}.", additional = "They should be converted to other '''[[:Category:Citation templates|quotation templates]]''' if relevant.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using nocat parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|nocat}} parameter, which should be eliminated (?).", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["Quotations using quoted-in parameter"] = { description = "Instances of {{tl|quote-*}} templates using the {{para|quoted_in}} parameter.", additional = "It is recommended to restructure these template calls using the {{para|newversion}} parameter along with associated parameters {{para|2ndauthor}}, {{para|title2}}, {{para|year2}}, {{para|publisher2}} and the like, as described in the documentation for {{tl|quote-book}}.", parents = {"Quotation maintenance"}, can_be_empty = true, hidden = true, } raw_categories["ඉල්ලීම්"] = { topright = "{{shortcut|WT:CR|WT:RQ}}", description = "A parent category for the various request categories.", parents = {"ප්‍රවර්ගය:වික්ෂනරිය"}, } raw_categories["Requests by language"] = { description = "Categories with requests in various specific languages.", additional = "{{{umbrella_msg}}}", parents = { {name = "Request subcategories by language", sort = " "}, {name = "ඉල්ලීම්", sort = " "}, }, breadcrumb = "by language", } raw_categories["Request subcategories by language"] = { description = "Umbrella categories covering topics related to requests.", additional = "{{{umbrella_meta_msg}}}", parents = { "ඡත්‍ර මෙටා ප්‍රවර්ග", {name = "ඉල්ලීම්", sort = " "}, }, } raw_categories["Requests for quotations by source"] = { description = "Categories with requests for quotation, broken out by the source of the quotation.", additional = "Some abbreviated names of sources are explained at [[Wiktionary:Abbreviated Authorities in Webster]].", parents = {"Requests for quotations"}, } raw_categories["Requests for quotations"] = { -- FIXME description = "Words are added to this category by the inclusion in their entries of {{tl|rfv-quote}}.", parents = {"ඉල්ලීම්", "Quotation maintenance"}, } raw_categories["Requests for date"] = { description = "Requests for a date to be added to a quotation.", additional = "To add an article to this category, use {{tl|rfdate}} or {{tl|rfdatek}} to include the author. " .. "Please remove the template from the article once the date has been provided.", parents = {"ඉල්ලීම්", "Quotation maintenance"}, } raw_categories["Requests for translations in user-competency categories by number of users"] = { description = "Requests for translations to be added to user-competency categories, sorted by number of users with that competency.", parents = {"ඉල්ලීම්"}, } raw_categories["Requests for translations in user-competency categories by language"] = { description = "Requests for translations to be added to user-competency categories, sorted by language.", parents = {"ඉල්ලීම්"}, hidden = true, } raw_categories["භාෂාව අනුව යෙදුම්, පරිවර්තන සහිත"] = { description = "Terms with translations, sorted by language.", parents = {"භාෂාව අනුව ප්‍රවේශ නඩත්තු උපප්‍රවර්ග"}, breadcrumb_base = "පරිවර්තන", } raw_categories["Entries using missing taxonomic names"] = { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name." .. "\n\nSee [[:Category:mul:Taxonomic names]].", parents = {{name = "ප්‍රවේශ නඩත්තුව", is_label = true, lang = "mul"}}, breadcrumb_base = "missing taxonomic names", hidden = true, } raw_categories["Entries with collapsible category lists for nonexistent categories"] = { description = "Entries where [[Module:collapsible category list]] is used, but the requested category does not exist.", additional = "Normally the culprit is a template like {{tl|prefixsee}} or {{tl|suffixsee}}.", parents = {"Entry maintenance", "Category maintenance"}, hidden = true, } -- Add breadcrumb by chopping off the parent (or the parent's parent, etc.) or the words 'entries (with/that/in)' or 'terms (with/that/in)' from the -- beginning or end of the label, if possible. Further chop off with/that/in to form the sortkey, if possible. require("Module:category tree/utilities").finalize_raw_categories(raw_categories, { addl_terms_to_remove_for_breadcrumb_base = {"entries with", "terms with", "entries that", "terms that", "entries in", "terms in", "entries", "terms", "requests for", "citations", "quotations", "maintenance"}, addl_terms_to_remove_for_sort = {"with", "that", "in", "by", "using"}, }) ----------------------------------------------------------------------------- -- -- -- RAW HANDLERS -- -- -- ----------------------------------------------------------------------------- local function script_name_to_code(name) local sc = require(scripts_module).getByCanonicalName(name) if not sc then error("Unrecognized script name '" .. name .. "'") end return sc:getCode() end --[=[ This array consists of category match specs. Each spec contains one or more properties, whose values are (a) strings that may contain references to other properties using the {{{PROPERTY}}} syntax; (b) functions of one argument, an `items` table of the same properties that are accessible using the {{{PROPERTY}} syntax. Each such spec should have at least a `regex` property that matches the name of the category. Capturing groups in this regex can be referenced in other properties using {{{1}}} for the first group, {{{2}}} for the second group, etc. (or using keys "1", "2", etc. in functions). Property expansion happens recursively if needed (i.e. a property can reference another property, which in turn references a third property). If there is a `language_name` propery, it specifies the language name (and will typically be a reference to a capturing group from the `regex` property); if not specified, it defaults to "{{{1}}}" unless the `nolang` property is set, in which case there is no language name associated with the category name. The language name must be the canonical name of a recognized full language, or an error is thrown; however, if the `allow_etym_lang` property is set, the language name may also be the canonical name of an etymology-only language. Based on the language name, the `language_code` and `language_object` properties are automatically filled in. If `language_name` is an etymology-only language, additional properties `parent_language_name`, `parent_language_code` and `parent_language_object` are set for the parent full language of the etymology-only language. If the `regex` values of multiple category specs match, the first one takes precedence. Recognized or predefined properties: `pagename`: Current pagename. `regex`: See above. `1`, `2`, `3`, ...: See above. `language_name`, `language_code`, `language_object`: See above. `parent_language_name`, `parent_language_code`, `parent_language_object`: See above. `nolang`: See above. `allow_etym_lang`: Language names may be etymology-only languages. See above. `description`: Override the description (normally taken directly from the pagename). `template_name`: Name of template which generates this category. `template_sample_call`: Syntax for calling the template. Defaults to "{{{template_name}}}|{{{language_code}}}". Used to display an example template call and the output of this call. `template_actual_sample_call`: Syntax for calling the template. Takes precedence over `template_sample_call` when generating example template output (but not when displaying an example template call) and is intended for a template call that uses the |nocat=1 parameter. `template_example_output`: Override the text that displays example template output (see `template_sample_call`). `additional_template_description`: Extra text to be displayed after the example template output. `parents`: Parent categories. Should be a list of elements, each of which is an object containing at least a name= and sort= field (same format as parents= for regular raw categories, except that the name= and sort= field will have {{{PROPERTY}}} references expanded). If no parents are specified, and the pagename is of the form "Requests for FOO by language", the parents will be "Request subcategories by language" with FOO as the sort key, along with any parents specified in `additional_umbrella_parents`. Otherwise, the `language_name` property must exist, and the parent will be "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key, along with any parents specified in `additional_parents`. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_parents` is used instead. `additional_parents`: Additional parents to add to the per-language category along with "Requests concerning LANGNAME". `etym_parents`: Parent categories for categories with associated etymology-only languages. The format is the same as `parents`. If omitted, there are two parents by default: (1) The pagename (i.e. category name) with the language name replaced by the corresponding parent language name, with the value of `language_name` as the sort key; (2) "Requests concerning LANGNAME", with the pagename minus any initial "Requests for " as the sort key. `umbrella`: Parent all-language category. Sort key is based on the language name. This applies *ONLY* if a full language is associated with the category name (i.e. not if `nolang` is set or if `allow_etym_lang` is set and the associated language is an etymology-only language); otherwise there will be no umbrella category. `additional_umbrella_parents`: Additional parents to add to the umbrella (all-language) category along with "Request subcategories by language". `breadcrumb`: Specify the breadcrumb. If `parents` is given, there is no default (i.e. it will end up being the pagename). Otherwise, if the pagename is of the form "Requests for FOO by language", the default breadcrumb will be "FOO". Otherwise it is computed by removing the language name from the pagename and chopping out "Requests for" from the beginning and "in entries" and "for terms" from the end. Note that this does *NOT* apply if an etymology-only language is associated with the category, in which case `etym_breadcrumb` is used instead. `etym_breadcrumb`: Specify the breadcrumb for categories with associated etymology-only languages. Defaults to the value of `language_name`. `not_hidden_category`: Don't hide the category. `catfix`: Same as `catfix` in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. `toc_template`, `toc_template_full`: Same as the corresponding fields in regular labels and raw categories, except that request-specific {{{PROPERTY}}} syntax is expanded. In general, properties can contain references to templates (e.g. {{tl}} and {{para}}), which will be appropriately expanded (this expansion happens in the poscatboiler code, not in this module). The major exception is in the `template_sample_call` and `template_actual_sample_call` properties, which are surrounded by <pre>...</pre> when inserted, so template references are not expanded. Triple-brace property references are still expanded in these properties; but beware that if any of those property references contain template references, they won't be expanded. (This actually happens in the handlers for 'Request for SCRIPT script for LANG terms'; the sample call references {{{script_code}}}, whose definition therefore cannot contain template references. The solution is to define this property using a function.) ]=] local requests_categories = { { regex = "^Requests concerning (.+)$", allow_etym_lang = true, description = "Categories with {{{1}}} entries that need the attention of experienced editors.", parents = {{name = "ප්‍රවේශ නඩත්තුව", is_label = true, sort = "requests"}}, etym_parents = {{name = "Requests concerning {{{parent_language_name}}}", sort = "{{{1}}}"}, {name = "{{{1}}}", sort = "ඉල්ලීම්"}}, umbrella = "Requests by language", breadcrumb = "ඉල්ලීම්", not_hidden_category = true, }, { regex = "^Requests for etymologies in (.+) entries$", allow_etym_lang = true, umbrella = "Requests for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "rfe", }, { regex = "^Requests for expansion of etymologies in (.+) entries$", umbrella = "Requests for expansion of etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, template_name = "etystub", }, { regex = "^Requests for pronunciation in (.+) entries$", umbrella = "Requests for pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfp", }, { regex = "^Requests for audio pronunciation in (.+) entries$", umbrella = "Requests for audio pronunciation by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfap", }, { regex = "^Requests for definitions in (.+) entries$", umbrella = "Requests for definitions by language", template_name = "rfdef", }, { regex = "^Requests for clarification of definitions in (.+) entries$", umbrella = "Requests for clarification of definitions by language", template_name = "rfclarify", }, { regex = "^Requests for English equivalent terms in (.+) entries$", umbrella = "Requests for English equivalent terms by language", template_name = "rfeq", }, } for _, spec_with_pos in ipairs { {"inflections", "rfinfl"}, {"plural forms"}, {"tone", "rftone"}, {"accents"}, {"aspect", "rfaspect"}, {"animacy"}, {"gender", "rfgender"}, {"noun class"}, } do local property, rftemplate = unpack(spec_with_pos) table.insert(requests_categories, { -- This is for part-of-speech-specific categories such as -- "Requests for inflections in Northern Ndebele noun entries" or -- "Requests for accents in Ukrainian proper noun entries". -- Here and below, we assume that the part of speech is begins with -- a lowercase letter, while the preceding language name ends in a -- capitalized word. Note that this entry comes before the -- following one and takes precedence over it. regex = ("^Requests for %s in (.-) ([a-z]+[a-z ]*) entries$"):format(property), parents = {{name = ("Requests for %s in {{{language_name}}} entries"):format(property), sort = "{{{2}}}"}}, umbrella = ("Requests for %s of {{pluralize|{{{2}}}}} by language"):format(property), breadcrumb = "{{{2}}}", template_name = rftemplate, template_sample_call = rftemplate and ("{{%s|{{{language_code}}}|{{{2}}}}}"):format(rftemplate) or nil, } ) table.insert(requests_categories, { regex = ("^Requests for %s in (.+) entries$"):format(property), umbrella = ("Requests for %s by language"):format(property), template_name = rftemplate, } ) table.insert(requests_categories, { regex = ("^Requests for %s of (.+) by language$"):format(property), nolang = true, } ) end extend(requests_categories, { { regex = "^Requests for example sentences in (.+)$", umbrella = "Requests for example sentences by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfex", }, { regex = "^Requests for quotations in (.+)$", umbrella = "Requests for quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfquote", }, { regex = "^Requests for translations into (.+)$", allow_etym_lang = true, umbrella = "Requests for translations by language", template_name = "t-needed", catfix = "en", }, { regex = "^Requests for translations of (.+) usage examples$", allow_etym_lang = true, umbrella = "Requests for translations of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|usex}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|usex|nocat=1}}", additional_template_description = "The {{tl|ux}}, {{tl|uxi}}, {{tl|ja-usex}} and {{tl|zh-x}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for translations of (.+) quotations$", allow_etym_lang = true, umbrella = "Requests for translations of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "t-needed", template_sample_call = "{{t-needed|{{{language_code}}}|quote}}", template_actual_sample_call = "{{t-needed|{{{language_code}}}|quote|nocat=1}}", additional_template_description = "The {{tl|quote}}, and {{tl|Q}} templates automatically add the page to this category if the example is in a foreign language and the translation is missing." }, { regex = "^Requests for review of (.+) translations$", allow_etym_lang = true, umbrella = "Requests for review of translations by language", template_name = "t-check", template_sample_call = "{{t-check|{{{language_code}}}|example}}", template_example_output = "", catfix = "en", }, { regex = "^Requests for transliteration of (.+) terms$", umbrella = "Requests for transliteration by language", template_name = "rftranslit", additional_template_description = "The {{tl|head}} template, and the large number of language-specific variants of it, automatically add " .. "the page to this category if the example is in a foreign language and no transliteration can be generated (particularly in languages without " .. "automated transliteration, such as Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) usage examples$", umbrella = "Requests for transliteration of usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rftranslit", template_sample_call = "{{rftranslit|{{{language_code}}}}}", template_actual_sample_call = "{{rftranslit|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for transliteration of (.+) quotations$", umbrella = "Requests for transliteration of quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation " .. "is in a foreign language and no transliteration can be generated (particularly in languages without automated transliteration, such as " .. "Hebrew and Persian).", }, { regex = "^Requests for native script for (.+) terms$", allow_etym_lang = true, etym_parents = { {name = "Requests for native script for {{{parent_language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "native script"}, }, umbrella = "Requests for native script by language", template_name = "rfscript", template_actual_sample_call = "{{rfscript|{{{language_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for native script in (.+) usage examples$", umbrella = "Requests for native script in usage examples by language", additional_umbrella_parents = {"Usage example maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|usex=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|usex=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|ux}} and {{tl|uxi}} templates automatically add the page to this category if the example itself is missing but the translation is supplied." }, { regex = "^Requests for native script in (.+) quotations$", umbrella = "Requests for native script in quotations by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfscript", template_sample_call = "{{rfscript|{{{language_code}}}|quote=1}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|quote=1|nocat=1}}", catfix = false, additional_template_description = "The {{tl|quote}} and {{code|<nowiki>{{quote-*}}</nowiki>}} templates automatically add the page to this category if the quotation itself is missing but the translation is supplied." }, { regex = "^Requests for (.+) script for (.+) terms$", language_name = "{{{2}}}", allow_etym_lang = true, parents = {{name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}}, etym_parents = { {name = "Requests for native script for {{{language_name}}} terms", sort = "{{{1}}}"}, {name = "Requests for {{{1}}} script for {{{parent_language_name}}} terms", sort = "{{{language_name}}}"}, {name = "Requests concerning {{{language_name}}}", sort = "{{{1}}} script"}, }, umbrella = "Requests for {{{1}}} script by language", breadcrumb = "{{{1}}}", etym_breadcrumb = "{{{1}}}", template_name = "rfscript", -- NOTE: The following is used in `template_sample_call` and `template_actual_sample_call`, meaning the -- conversion of script name to script code needs to be done using an inline function like this, instead of -- a {{#invoke:...}} template call. script_code = function(items) return script_name_to_code(items["1"]) end, template_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}}}", template_actual_sample_call = "{{rfscript|{{{language_code}}}|sc={{{script_code}}}|nocat=1}}", catfix = false, additional_template_description = "Many templates such as {{tl|l}}, {{tl|m}} and {{tl|t}} automatically place the page in this category when they are missing the term but have been provided with a transliteration." }, { regex = "^Requests for (.+) script by language$", parents = {{name = "Requests for script by language", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, }, { regex = "^Requests for script by language$", nolang = true, }, { regex = "^Requests for images in (.+) entries$", umbrella = "Requests for images by language", template_name = "rfi", }, { regex = "^Requests for references for (.+) terms$", umbrella = "Requests for references by language", template_name = "rfref", }, { regex = "^Requests for references for etymologies in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "etymologies"}}, umbrella = "Requests for references for etymologies by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, breadcrumb = "නිරුක්ති", template_name = "rfv-etym", }, { regex = "^Requests for references for pronunciations in (.+) entries$", parents = {{name = "Requests for references for {{{language_name}}} terms", sort = "pronunciations"}}, umbrella = "Requests for references for pronunciations by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, breadcrumb = "Pronunciations", template_name = "rfv-pron", }, { regex = "^Requests for attention concerning (.+)$", umbrella = "Requests for attention by language", breadcrumb = "Attention", template_name = "attention", template_sample_call = "{{attention|{{{language_code}}}|insert a brief description of the request here}}", template_example_output = "This template does not generate any text in entries, but can be visualised by enabling the Catch My Attention gadget. See {{section link|Template:attention#Visibility}}.", -- These pages typically contain a mixture of English and native-language entries, so disable catfix. catfix = false, -- Setting catfix = false will normally trigger the English table of contents template. -- We still want the native-language table of contents template, though. toc_template = "{{{language_code}}}-categoryTOC", toc_template_full = "{{{language_code}}}-categoryTOC/full", }, { regex = "^Requests for cleanup in (.+) entries$", umbrella = "Requests for cleanup by language", template_name = "rfc", template_actual_sample_call = "{{rfc|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for cleanup of Pronunciation N headers in (.+) entries$", umbrella = "Requests for cleanup of Pronunciation N headers by language", additional_parents = {{name = "pronunciation maintenance", is_label = true}}, additional_umbrella_parents = {"Pronunciation maintenance"}, template_name = "rfc-pron-n", template_actual_sample_call = "{{rfc-pron-n|{{{language_code}}}|nocat=1}}", template_example_output = "This template does not generate any text in entries.", additional_template_description = [=[ The purpose of this category is to tag entries that use headers with "Pronunciation" and a number. While these headers and structure are sometimes used, they are not specifically prescribed by [[WT:ELE]]. No complete proposal has yet been made on how they should work, what the semantics are, or how they interact with multiple etymologies. As a result they should generally be avoided. Instead, merge the entries (possibly under multiple Etymology sections, if appropriate), and list all pronunciations, appropriately tagged, under a Pronunciation header. [[User:KassadBot|KassadBot]] tags these entries (or used to tag these entries, when the bot was operational). At some point if a proposal is made and adopted as policy, these entries should be reviewed. This category is hidden.]=], }, { regex = "^Requests for deletion in (.+) entries$", umbrella = "Requests for deletion by language", template_name = "rfd", template_actual_sample_call = "{{rfd|{{{language_code}}}|nocat=1}}", }, { regex = "^Requests for verification in (.+) entries$", umbrella = "Requests for verification by language", template_name = "rfv", }, { regex = "^Requests for attention in (.+) etymologies$", umbrella = "Requests for attention by language", additional_parents = {{name = "etymology maintenance", is_label = true}}, additional_umbrella_parents = {"Etymology maintenance"}, }, { regex = "^Requests for quotations/(.+)$", description = "Requests for a quotation or for quotations from {{{1}}}.", parents = {{name = "Requests for quotations by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfquotek", template_sample_call = "{{rfquotek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfquotek|und|{{{1}}}}}", }, { regex = "^Requests for date in (.+) entries$", umbrella = "Requests for date by language", additional_umbrella_parents = {"Quotation maintenance"}, template_name = "rfdate", additional_template_description = "The quotation templates, such as {{tl|quote-book}} and {{tl|quote-journal}}, " .. "automatically add the page to this category if neither {{para|date}} nor {{para|year}} is provided. Providing the " .. "parameter in each case on the page automatically removes the article from this category. See " .. "[[Wiktionary:Quotations]] for information about formatting dates and quotations.", }, { regex = "^Requests for date/(.+)$", description = "{{rfd|section=Category:Requests for date by source}}Requests for a date for a quotation or quotations from {{{1}}}.", parents = {{name = "Requests for date by source", sort = "{{{1}}}"}}, breadcrumb = "{{{1}}}", nolang = true, template_name = "rfdatek", template_sample_call = "{{rfdatek|LANGCODE|{{{1}}}}}", template_example_output = "\n(where LANGCODE is the language code of the entry)\n\nIt results in the message below:\n\n{{rfdatek|und|{{{1}}}}}", }, { regex = "^Requests for attestation of (.+) terms$", umbrella = "Requests for attestation of terms by language", breadcrumb = "Attestation", additional_template_description = "The {{tl|LDL}} template adds this category when a language code is supplied in {{para|1}} (as it should be)." }, }) local user_competency_additional_template_description = "This is added by user-competency categories such as " .. "[[:Category:User fr-4]], which groups users who speak French at level 4 (near-native proficiency), when " .. "the native-language text indicating this fact is missing. The appropriate translation should mirror the " .. "English text also displayed (e.g. in this case \"These users speak French at a '''near native''' " .. "level.\"), and should be supplied to {{tl|auto cat}} using the {{para|text}} parameter. The mention of the " .. "language in the text should be surrounded by double angle brackets, e.g. \"&lt;&lt;français>>\", which " .. "causes it to be automatically linked to the appropriate parent category." local user_competency_parents = {{name = "Requests for translations in user-competency categories by number of users", sort = function(items) return " " .. ("%010d"):format(items["1"]) end, }} extend(requests_categories, { { regex = "^Requests for translations in user%-competency categories with ([0-9]+)%-([0-9]+) users$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}}-{{{2}}} users.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}-{{{2}}}", nolang = true, }, { regex = "^Requests for translations in user%-competency categories with ([0-9]+) (users?)$", description = "Requests for translation of phrases indicating user competencies for specific languages and specific competency levels, for categories with {{{1}}} {{{2}}}.", additional_template_description = user_competency_additional_template_description, parents = user_competency_parents, breadcrumb = "{{{1}}}", nolang = true, } }) table.insert(raw_handlers, function(data) local items local function init_items() items = {pagename = data.category} end local function expand_value(item, val) if not val then return val elseif is_callable(val) then return expand_value(item .. " ⇒ function", val(items)) elseif type(val) == "table" then for k, v in pairs(val) do val[k] = expand_value(item .. " ⇒ " .. k, v) end return val elseif type(val) == "number" then val = tostring(val) end if type(val) ~= "string" then error(("The item '%s' on page %s is of type %s and can't be concatenated"):format( item, items.pagename, type(val))) end -- Replaces pseudo-template code {{{ }}} with the corresponding member of the "items" table. Has to be done -- recursively, since some of the items are nested: -- {{{template_sample_call_with_temp}}} -- ⇓ -- {{{{{template_name}}}|{{{language_code}}}}} -- ⇓ -- {{attention|en}} if val:find("{{{") then val = mw.ustring.gsub(val, "{{{([^%}%{]+)}}}", function(prop) local propval = items[prop] if not propval then error(("The item '%s' (expanded from property '%s' on page %s) was not found in the 'items' table"): format(prop, item, items.pagename)) end return expand_value(item .. " ⇒ " .. prop, propval) end ) end return val end local function expand_items_value(item) return expand_value(item, items[item]) end local function convert_items_to_category_data(items) if not items.nolang then items.language_name = items.language_name or "{{{1}}}" items.language_name = expand_items_value("language_name") items.language_object = require(languages_module).getByCanonicalName(items.language_name, true, items.allow_etym_lang) items.language_code = items.language_object:getCode() items.is_etym_lang = items.language_object:hasType("etymology-only") if items.is_etym_lang then items.parent_language_object = items.language_object:getFull() -- Reject weird cases where etymology language has no parent. if not items.parent_language_object then return nil end items.parent_language_code = items.parent_language_object:getCode() items.parent_language_name = items.parent_language_object:getCanonicalName() -- Reject weird cases where the parent language has the same name as the child etymology language. In -- that case, we'll get an infinite parent-category loop. This actually happens, e.g. with Rudbari and -- Bashkardi. if items.parent_language_name == items.language_name then return nil end else end end if items.template_name then items.template_sample_call = items.template_sample_call or "{{{{{template_name}}}|{{{language_code}}}}}" items.full_text_about_the_template = "මෙම ඉල්ලීම කිරීම සඳහා, මෙම භාෂාව සඳහා, අදාළ ප්‍රවේශය තුළ මෙම කේතය භාවිතා කරන්න ([[Template:{{{template_name}}}]] සඳහා වන උපදෙස් පත්‍රිකාව වෙත ද අවධානය යොමු කරන්න):\n\n<pre>{{{template_sample_call}}}</pre>" if items.template_example_output then items.full_text_about_the_template = items.full_text_about_the_template .. " " .. items.template_example_output else items.template_actual_sample_call = items.template_actual_sample_call or items.template_sample_call items.full_text_about_the_template = items.full_text_about_the_template .. "\nඑමගින් පහත දැක්වෙන නිවේදනය ප්‍රදර්ශනය වෙයි:\n\n{{{template_actual_sample_call}}}" end if items.additional_template_description then items.full_text_about_the_template = items.full_text_about_the_template .. "\n\n" .. items.additional_template_description end else items.full_text_about_the_template = items.additional_template_description end local parents, breadcrumb if items.is_etym_lang then parents = items.etym_parents breadcrumb = expand_items_value("etym_breadcrumb") or items.language_name else parents = items.parents breadcrumb = expand_items_value("breadcrumb") end if parents then for _, parent in ipairs(parents) do parent.name = expand_value("parent.name", parent.name) parent.sort = {sort_base = expand_value("parent.sort", parent.sort), lang = "en"} end else local umbrella_type = items.pagename:match("^Requests for (.+) by language$") if umbrella_type then breadcrumb = breadcrumb or umbrella_type parents = {{name = "Request subcategories by language", sort = umbrella_type}} if items.additional_umbrella_parents then extend(parents, items.additional_umbrella_parents) end elseif not items.language_name then error("Internal error: Don't know how to compute parents for non-language-specific category '" .. items.pagename .. "'") else local requests_concerning_breadcrumb = items.pagename:gsub(" " .. pattern_escape(items.language_name), "") requests_concerning_breadcrumb = requests_concerning_breadcrumb:gsub("^Requests for ", ""):gsub(" in entries$", ""):gsub(" for terms$", "") local requests_concerning_parent = { name = "Requests concerning " .. items.language_name, sort = {sort_base = requests_concerning_breadcrumb, lang = "en"} } if items.is_etym_lang then local parent_lang_cat = items.pagename:gsub(pattern_escape(items.language_name), replacement_escape(items.parent_language_name)) parents = { {name = parent_lang_cat, sort = {sort_base = items.language_name, lang = "en"}}, requests_concerning_parent } else breadcrumb = breadcrumb or requests_concerning_breadcrumb parents = {requests_concerning_parent} if items.additional_parents then extend(parents, items.additional_parents) end end end end if not items.nolang and not items.is_etym_lang and items.umbrella ~= false then table.insert(parents, { name = expand_items_value("umbrella"), sort = {sort_base = items.language_name, lang = "en"} }) end local additional = expand_items_value("full_text_about_the_template") if items.pagename:find(" by language$") then additional = "{{{umbrella_msg}}}" .. (additional and "\n\n" .. additional or "") end return { description = expand_items_value("description") or items.pagename .. ".", lang = items.parent_language_code or items.language_code, additional = additional, parents = parents, -- If no breadcrumb= and not an etym-only language, it will default to the category name breadcrumb = breadcrumb, catfix = expand_items_value("catfix"), toc_template = expand_items_value("toc_template"), toc_template_full = expand_items_value("toc_template_full"), hidden = not items.nolang and not items.not_hidden_category, can_be_empty = true, } end -- First look for a regular (usually language or script-specific) category. for _, category in ipairs(requests_categories) do local matchvals = {mw.ustring.match(data.category, category.regex)} if #matchvals > 0 then init_items() for key, value in pairs(category) do items[key] = value end for key, value in ipairs(matchvals) do items["" .. key] = value end local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end -- Now look for umbrella categories. for _, category in ipairs(requests_categories) do if data.category == category.umbrella then init_items() items.nolang = true items.additional_umbrella_parents = category.additional_umbrella_parents local catdata = convert_items_to_category_data(items) if catdata then return catdata end end end return nil end) table.insert(raw_handlers, function(data) local langname = data.category:match("^යෙදුම්, (.+) පරිවර්තන සහිත$") local lang = langname and require(languages_module).getByCanonicalName(langname, true, true) if lang then local langcode = lang:getCode() local parents, breadcrumb_and_first_sort_key if lang:hasType("etymology-only") then parents = { "යෙදුම්, " .. lang:getFullName() .. " පරිවර්තන සහිත", {name = langname, sort = "පරිවර්තන"}, } breadcrumb_and_first_sort_key = lang:getCanonicalName() else parents = { {name = "ප්‍රවේශ නඩත්තුව", is_label = true, lang = langcode}, { name = "භාෂාව අනුව යෙදුම්, පරිවර්තන සහිත", sort = {sort_base = langname, lang = "en"} }, } breadcrumb_and_first_sort_key = "පරිවර්තන" end return { description = "Entries that contain translations into " .. langname .. " which were added using one of the translation templates, such as {{tl|t|" .. langcode .. "|...}}, {{tl|t+|" .. langcode .. "|...}}, etc.", parents = parents, breadcrumb_and_first_sort_key = breadcrumb_and_first_sort_key, catfix = false, can_be_empty = true, hidden = true, } end end) local recognized_taxtypes = require(table_module).listToSet { "ambiguous", "binomial", "branch", "clade", "cladus", "class", "cohort", "convariety", "cultivar group", "cultivar", "division", "empire", "epifamily", "epithet", "family", "form taxon", "form", "genus", "grade", "grandorder", "group", "hybrid", "informal group", "infraclass", "infracohort", "infrakingdom", "infraorder", "infraphylum", "infraspecies", "infratribe", "kingdom", "magnorder", "megacohort", "mirorder", "morph", "nothogenus", "nothospecies", "nothosubspecies", "nothovariety", "obsolete", "oofamily", "order", "parvclass", "parvorder", "phylum", "section", "series", "serovar", "species group", "species", "stem", "stirps", "strain", "subclass", "subcohort", "subdivision", "subfamily", "subgenus", "subgroup", "subinfraorder", "subkingdom", "suborder", "subphylum", "subsection", "subseries", "subspecies", "subterclass", "subtribe", "superclass", "supercohort", "superfamily", "supergroup", "superorder", "superphylum", "supertribe", "taxon", "tribe", "trinomial", "undescribed species", "unknown", "unranked group", "variety", "virus complex", } table.insert(raw_handlers, function(data) local taxtype = data.category:match("^Entries using missing taxonomic name %((.*)%)$") if taxtype and recognized_taxtypes[taxtype] then return { description = "Entries that link to wikispecies because there is no corresponding Wiktionary entry for the taxonomic name in the template {{tl|taxlink}}.", additional = "The missing name is one or more of those enclosed in {{tl|taxlink}}. The entries are sorted by the missing taxonomic name.", parents = {{name = "Entries using missing taxonomic names", sort = {sort_base = taxtype, lang = "en"}}}, breadcrumb = taxtype, hidden = true, } end end) return {LABELS = labels, RAW_CATEGORIES = raw_categories, RAW_HANDLERS = raw_handlers} eydyyhb2ml1ycx5wt2cox1kl1ghdegw Module:scripts 828 8910 239375 220333 2026-10-06T01:22:39Z en>Fenakhay 0 Add caret_capitalization 239375 Scribunto text/plain local export = {} local combining_classes_module = "Module:Unicode data/combining classes" local debug_track_module = "Module:debug/track" local json_module = "Module:JSON" local language_like_module = "Module:language-like" local load_module = "Module:load" local scripts_canonical_names_module = "Module:scripts/canonical names" local scripts_chartoscript_module = "Module:scripts/charToScript" local scripts_data_module = "Module:scripts/data" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local writing_systems_module = "Module:writing systems" local writing_systems_data_module = "Module:writing systems/data" local concat = table.concat local get_by_code -- Defined below. local gmatch = string.gmatch local insert = table.insert local make_object -- Defined below. local match = string.match local require = require local select = select local setmetatable = setmetatable local toNFC = mw.ustring.toNFC local toNFD = mw.ustring.toNFD local toNFKC = mw.ustring.toNFKC local toNFKD = mw.ustring.toNFKD local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function category_name_has_suffix(...) category_name_has_suffix = require(language_like_module).categoryNameHasSuffix return category_name_has_suffix(...) end local function category_name_to_code(...) category_name_to_code = require(language_like_module).categoryNameToCode return category_name_to_code(...) end local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) end local function explode(...) explode = require(string_utilities_module).explode_utf8 return explode(...) end local function get_writing_system(...) get_writing_system = require(writing_systems_module).getByCode return get_writing_system(...) end local function keys_to_list(...) keys_to_list = require(table_module).keysToList return keys_to_list(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function to_json(...) to_json = require(json_module).toJSON return to_json(...) end local function track(page) debug_track("scripts/" .. page) return true end local function ugsub(...) ugsub = require(string_utilities_module).gsub return ugsub(...) end local function umatch(...) umatch = require(string_utilities_module).match return umatch(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local scripts_canonical_names local function get_scripts_canonical_names() scripts_canonical_names, get_scripts_canonical_names = load_data(scripts_canonical_names_module), nil return scripts_canonical_names end local scripts_data local function get_scripts_data() scripts_data, get_scripts_data = load_data(scripts_data_module), nil return scripts_data end local scripts_suffixes local function get_scripts_suffixes() scripts_suffixes, get_scripts_suffixes = { "script", "code", "notation", "letters", "numerals", "semaphore", }, nil for _, v in pairs(load_data(writing_systems_data_module)) do insert(scripts_suffixes, v[1]) end return scripts_suffixes end local Script = {} Script.__index = Script --[==[Returns the script code of the script. Example: {{lua|"Cyrl"}} for Cyrillic.]==] function Script:getCode() return self._code end --[==[ Return the canonical name of the script. This is the name used to represent that script on Wiktionary. Example: {"Cyrillic"} for Cyrillic. If `lang` is specified and the script has a language-specific name, return that (e.g. {"Shahmukhi"} for script `Aran` with Punjabi and certain related languages); otherwise, return the default name (if the script has different names in different languages, e.g. {"Arabic"} for `Aran`), or the only name if there is only one. ]==] function Script:getCanonicalName(lang) local rawdata = self._data[1] if type(rawdata) == "string" then return rawdata end local name if lang then name = rawdata[lang:getCode()] if name then return name end name = rawdata[lang:getFullCode()] if name then return name end end name = rawdata.default if not name then error(("Internal error: no default key in script name table for script %s"):format(self:getCode())) end return name end --[==[ Return the table mapping languages to names for the script. If the script has only one name (as most scripts do), return a string consisting of that name. Otherwise, return a table mapping language codes to names, where the key named `default` contains the default name used for languages not specified in the table. ]==] function Script:getCanonicalNameTable() return self._data[1] end --[==[ Return all canonical names of the script. The default name is first. ]==] function Script:getCanonicalNames() local rawdata = self._data[1] if type(rawdata) == "string" then return {rawdata} end local names = {} for lang, name in pairs(rawdata) do if lang ~= "default" then require(table_module).insertIfNot(names, name) end end table.sort(names) require(table_module).insertIfNot(names, rawdata.default, {pos = 1}) return names end --[==[ Return the display form of the script. For scripts, this is the same as the value returned by {:getCategoryName("nocap")}, i.e. it reads <code>"<var>NAME</var> script"</code> (e.g. {"Arabic script"}). The displayed text used in {:makeCategoryLink()} is always the same as the display form. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:getDisplayForm(lang) return self:getCategoryName("nocap", lang) end function Script:getAliases() Script.getAliases = require(language_like_module).getAliases return self:getAliases() end function Script:getVarieties(flatten) Script.getVarieties = require(language_like_module).getVarieties return self:getVarieties(flatten) end function Script:getOtherNames() Script.getOtherNames = require(language_like_module).getOtherNames return self:getOtherNames() end function Script:getAllNames() Script.getAllNames = require(language_like_module).getAllNames return self:getAllNames() end --[==[Returns the {{w|IETF language tag#Syntax of language tags|IETF subtag}} used for the script, which should always be a valid {{w|ISO 15924}} script code. This is used when constructing HTML {{code|html|lang{{=}}}} tags. The {{lua|ietf_subtag}} value from the script's data file is used, if present; otherwise, the script code is used. For script codes which contain a hyphen, only the part after the hyphen is used (e.g. {{lua|"fa-Arab"}} becomes {{lua|"Arab"}}).]==] function Script:getIETFSubtag() local code = self._ietf_subtag if code == nil then code = self._data.ietf_subtag or match(self:getCode(), "[^%-]+$") self._ietf_subtag = code end return code end --[==[Returns a script object for the parent of the script, such as {"Arab"} for {"fa-Arab"}. It returns {nil} for scripts without a parent, like {"Latn"}, {"Grek"}, etc.]==] function Script:getParent() local parent = self._parentObject if parent == nil then parent = self:getParentCode() -- If the value is nil, it's cached as false. parent = parent and get_by_code(parent) or false self._parentObject = parent end return parent or nil end --[==[Returns the script code of the parent of the script, such as {"Arab"} for {"fa-Arab"}. It returns {nil} for scripts without a parent, like {"Latn"}, {"Grek"}, etc.]==] function Script:getParentCode() local parent = self._parentCode if parent == nil then -- If the value is nil, it's cached as false. parent = self._data.parent or false self._parentCode = parent end return parent or nil end function Script:getSystemCodes() if not self._systemCodes then local system_codes = self._data[3] if type(system_codes) == "table" then self._systemCodes = system_codes elseif type(system_codes) == "string" then self._systemCodes = split(system_codes, ",", true, true) else self._systemCodes = {} end end return self._systemCodes end function Script:getSystems() if not self._systemObjects then self._systemObjects = {} for _, system in ipairs(self:getSystemCodes()) do insert(self._systemObjects, get_writing_system(system)) end end return self._systemObjects end --[==[Check whether the script is of type `system`, which can be a writing system code or object. If multiple systems are passed, return true if the script is any of the specified systems.]==] function Script:isSystem(...) for _, system in ipairs{...} do if type(system) == "table" then system = system:getCode() end for _, s in ipairs(self:getSystemCodes()) do if system == s then return true end end end return false end --[==[Returns a table of types as a lookup table (with the types as keys). Currently, the only possible type is {script}.]==] function Script:getTypes() local types = self._types if types == nil then types = {script = true} local rawtypes = self._data.type if rawtypes then for t in gmatch(rawtypes, "[^,]+") do types[t] = true end end self._types = types end return types end --[==[Given a list of types as strings, returns true if the script has all of them. Use {{lua|hasType("script")}} to determine if an object that may be a language, family or script is a script.]==] function Script:hasType(...) Script.hasType = require(language_like_module).hasType return self:hasType(...) end --[==[ Return the name of the main category of that script. Example: {"Cyrillic script"} for Cyrillic, whose category is at [[:Category:Cyrillic script]]. Unless optional argument `nocap` is given, the script name at the beginning of the returned value will be capitalized. This capitalization is correct for category names, but not if the script name is lowercase and the returned value of this function is used in the middle of a sentence. (For example, the script with the code `Semap` has the name {"flag semaphore"}, which should remain lowercase when used as part of the category name [[:Category:Translingual letters in flag semaphore]] but should be capitalized in [[:Category:Flag semaphore templates]].) If you are considering using {getCategoryName("nocap")}, use {getDisplayForm()} instead. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:getCategoryName(nocap, lang) local name = self:getCanonicalName(lang) if category_name_has_suffix(name, scripts_suffixes or get_scripts_suffixes()) then name = name .. " script" end if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end --[==[ Return a link to the appropriate category for the script, displaying using the display form of the script. For example, `Cyrl` returns `[[:Category:Cyrillic script|Cyrillic script]]`. The display form is not automatically capitalized, so e.g. the script code `Semap` will return `[[:Category:Flag semaphore|flag semaphore]]`. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:makeCategoryLink(lang) return "[[:Category:" .. self:getCategoryName(lang) .. "|" .. self:getDisplayForm(lang) .. "]]" end --[==[Returns the Wikidata item id for the script or <code>nil</code>. This corresponds to the the second field in the data modules.]==] function Script:getWikidataItem() Script.getWikidataItem = require(language_like_module).getWikidataItem return self:getWikidataItem() end --[==[ Returns the name of the Wikipedia article for the script. `project` specifies the language and project to retrieve the article from, defaulting to {"enwiki"} for the English Wikipedia. Normally if specified it should be the project code for a specific-language Wikipedia e.g. "zhwiki" for the Chinese Wikipedia, but it can be any project, including non-Wikipedia ones. If the project is the English Wikipedia and the property {wikipedia_article} is present in the data module it will be used first. In all other cases, a sitelink will be generated from {:getWikidataItem} (if set). The resulting value (or lack of value) is cached so that subsequent calls are fast. If no value could be determined, and `noCategoryFallback` is {false}, {:getCategoryName} is used as fallback; otherwise, {nil} is returned. Note that if `noCategoryFallback` is {nil} or omitted, it defaults to {false} if the project is the English Wikipedia, otherwise to {true}. In other words, under normal circumstances, if the English Wikipedia article couldn't be retrieved, the return value will fall back to a link to the script's category, but this won't normally happen for any other project. ]==] function Script:getWikipediaArticle(noCategoryFallback, project) Script.getWikipediaArticle = require(language_like_module).getWikipediaArticle return self:getWikipediaArticle(noCategoryFallback, project) end --[==[Returns the name of the Wikimedia Commons category page for the script.]==] function Script:getCommonsCategory() Script.getCommonsCategory = require(language_like_module).getCommonsCategory return self:getCommonsCategory() end --[==[Returns the charset defining the script's characters from the script's data file. This can be used to search for words consisting only of this script, but see the warning above.]==] function Script:getCharacters() return self.characters or nil end --[==[Returns the number of characters in the text that are part of this script. '''Note:''' You should never assume that text consists entirely of the same script. Strings may contain spaces, punctuation and even wiki markup or HTML tags. HTML tags will skew the counts, as they contain Latin-script characters. So it's best to avoid them.]==] function Script:countCharacters(text) local charset = self._data.characters if charset == nil then return 0 end return select(2, ugsub(text, "[" .. charset .. "]", "")) end function Script:hasCapitalization() return not not self._data.capitalized end --[==[Returns the {caret_capitalization} value from this script or a parent, or {nil} if none is set. {true} means unescaped {^} capitalizes the next transliteration letter; {false} means it is an error; {nil} means the default (enabled when the script is unicameral and transliteratable).]==] function Script:getCaretCapitalization() local sc = self while sc do local setting = sc._data.caret_capitalization if setting ~= nil then return not not setting end sc = sc:getParent() end return nil end --[==[Returns {true} if unescaped {^} should capitalize transliterations for this script.]==] function Script:hasCaretCapitalization() local setting = self:getCaretCapitalization() if setting ~= nil then return setting end return not self:hasCapitalization() and self:isTransliterated() end --[==[Returns {true} if unescaped {^} is forbidden ({caret_capitalization = false} on this script or a parent).]==] function Script:forbidsCaretCapitalization() return self:getCaretCapitalization() == false end function Script:hasSpaces() return self._data.spaces ~= false end function Script:isTransliterated() return self._data.translit ~= false end --[==[Returns true if the script is (sometimes) sorted by scraping page content, meaning that it is sensitive to changes in capitalization during sorting.]==] function Script:sortByScraping() return not not self._data.sort_by_scraping end --[==[Returns the text direction. Horizontal scripts return {{lua|"ltr"}} (left-to-right) or {{lua|"rtl"}} (right-to-left), while vertical scripts return {{lua|"vertical-ltr"}} (vertical left-to-right) or {{lua|"vertical-rtl"}} (vertical right-to-left).]==] function Script:getDirection() return self._data.direction or "ltr" end function Script:getData() return self._data end --[==[Returns the name of the module containing the script's data. Currently, this is always [[Module:scripts/data]].]==] function Script:getDataModuleName() return scripts_data_module end --[==[Returns {{lua|true}} if the script contains characters that require fixes to Unicode normalization under certain circumstances, {{lua|false}} if it doesn't.]==] function Script:hasNormalizationFixes() return not not self._data.normalizationFixes end --[==[Corrects discouraged sequences of Unicode characters to the encouraged equivalents.]==] function Script:fixDiscouragedSequences(text) if self:hasNormalizationFixes() then local norm_fixes = self._data.normalizationFixes local to = norm_fixes.to if to then for i, v in ipairs(norm_fixes.from) do text = ugsub(text, v, to[i] or "") end end end return text end do local combining_classes -- Obtain the list of default combining classes. local function get_combining_classes() combining_classes, get_combining_classes = load_data(combining_classes_module), nil return combining_classes end -- Implements a modified form of Unicode normalization for instances where there are identified deficiencies in the default Unicode combining classes. local function fixNormalization(text, self) if not self:hasNormalizationFixes() then return text end local norm_fixes = self._data.normalizationFixes local new_classes = norm_fixes.combiningClasses if not (new_classes and umatch(text, "[" .. norm_fixes.combiningClassCharacters .. "]")) then return text end text = explode(text) -- Manual sort based on new combining classes. -- We can't use table.sort, as it compares the first/last values in an array as a shortcut, which messes things up. for i = 2, #text do local char = text[i] local class = new_classes[char] or (combining_classes or get_combining_classes())[char] if class then repeat i = i - 1 local prev = text[i] if (new_classes[prev] or (combining_classes or get_combining_classes())[prev] or 0) < class then break end text[i], text[i + 1] = char, prev until i == 1 end end return concat(text) end function Script:toFixedNFC(text) return fixNormalization(toNFC(text), self) end function Script:toFixedNFD(text) return fixNormalization(toNFD(text), self) end function Script:toFixedNFKC(text) return fixNormalization(toNFKC(text), self) end function Script:toFixedNFKD(text) return fixNormalization(toNFKD(text), self) end end function Script:toJSON(opts) local ret = { canonicalName = self:getCanonicalName(), canonicalNameTable = self:getCanonicalNameTable(), categoryName = self:getCategoryName("nocap"), code = self:getCode(), parent = self:getParentCode(), systems = self:getSystemCodes(), aliases = self:getAliases(), varieties = self:getVarieties(), otherNames = self:getOtherNames(), type = keys_to_list(self:getTypes()), direction = self:getDirection(), characters = self:getCharacters(), ietfSubtag = self:getIETFSubtag(), wikidataItem = self:getWikidataItem(), wikipediaArticle = self:getWikipediaArticle(true), } -- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`. return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts) end function export.makeObject(code, data) local data_type = type(data) if data_type ~= "table" then error(("bad argument #2 to 'makeObject' (table expected, got %s)"):format(data_type)) end return setmetatable({_data = data, _code = code, characters = data.characters}, Script) end make_object = export.makeObject local scripts_to_track = { ["fa-Arab"] = true, ["kk-Arab"] = true, ["ks-Arab"] = true, ["ku-Arab"] = true, ["ms-Arab"] = true, ["mzn-Arab"] = true, ["ota-Arab"] = true, ["pa-Arab"] = true, ["ps-Arab"] = true, ["sd-Arab"] = true, ["tt-Arab"] = true, ["ug-Arab"] = true, ["ur-Arab"] = true, } --[==[ Finds the script whose code matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}.]==] function export.getByCode(code) if scripts_to_track[code] then track(code) end local data = (scripts_data or get_scripts_data())[code] return data ~= nil and make_object(code, data) or nil end get_by_code = export.getByCode --[==[ Look for the script whose canonical name (the name used to represent that script on Wiktionary) matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}. The canonical name of scripts should always be unique (it is an error for two scripts on Wiktionary to share the same canonical name), so this is guaranteed to give at most one result.]==] function export.getByCanonicalName(name) if name == nil then return nil end local code = (scripts_canonical_names or get_scripts_canonical_names())[name] if code == nil then return nil end return get_by_code(code) end --[==[ Look for the script whose category name (the name used in categories for that script) matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}. In almost all cases, the category name for a script is its canonical name plus the word "script", e.g. "Cyrillic" has the category name "Cyrillic script". Where a canonical name ends with "script", "code" or "semaphore", the category name is identical to the canonical name. ]==] function export.getByCategoryName(name) if name == nil then return nil end local code, canonical_name = category_name_to_code( name, " script", scripts_canonical_names or get_scripts_canonical_names(), scripts_suffixes or get_scripts_suffixes() ) if code == nil then return nil, nil end return get_by_code(code), canonical_name end --[==[ Convert a canonical name to the corresponding category name. Unless optional argument `nocap` is given, the script name at the beginning of the returned value will be capitalized. See {:getCategoryName()} for more discussion. ]==] function export.canonicalNameToCategoryName(name, nocap) if category_name_has_suffix(name, scripts_suffixes or get_scripts_suffixes()) then name = name .. " script" end if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end --[==[ Takes a codepoint or a character and finds the script code (if any) that is appropriate for it based on the codepoint, using the data module [[Module:scripts/recognition data]]. The data module was generated from the patterns in [[Module:scripts/data]] using [[Module:User:Erutuon/script recognition]]. Converts the character to a codepoint. Returns a script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to, else returns "None". ]==] function export.charToScript(char) export.charToScript = require(scripts_chartoscript_module).charToScript return export.charToScript(char) end --[==[ Returns the code for the script that has the greatest number of characters in `text`. Useful for script tagging text that is unspecified for language. Uses [[Module:scripts/recognition data]] to determine a script code for a character language-agnostically. Specifically, it works as follows: Convert each character to a codepoint. Increment the counter for the script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to. Each script has a two-part counter, for primary and secondary matches. Primary matches are when the script is the first one listed; otherwise, it's a secondary match. When comparing scripts, first the total of both are compared (i.e. the overall number of matches). If these are the same, the number of primary and then secondary matches are used as tiebreakers. For example, this is used to ensure that `Grek` takes priority over `Polyt` if no characters which exclusively match `Polyt` are found, as `Grek` is a subset of `Polyt`. If `none_is_last_resort_only` is specified, this will never return {"None"} if any characters in `text` belong to a script. Otherwise, it will return {"None"} if there are more characters that don't belong to a script than belong to any individual script. (FIXME: This behavior is probably wrong, and `none_is_last_resort_only` should probably become the default.) ]==] function export.findBestScriptWithoutLang(text, none_is_last_resort_only) export.findBestScriptWithoutLang = require(scripts_chartoscript_module).findBestScriptWithoutLang return export.findBestScriptWithoutLang(text, none_is_last_resort_only) end return export 391jugwei8ugmbatc3z2z8ddqthugox 239376 239375 2026-11-22T04:39:17Z Lee 19 [[:en:Module:scripts]] වෙතින් එක් සංශෝධනයක් 239375 Scribunto text/plain local export = {} local combining_classes_module = "Module:Unicode data/combining classes" local debug_track_module = "Module:debug/track" local json_module = "Module:JSON" local language_like_module = "Module:language-like" local load_module = "Module:load" local scripts_canonical_names_module = "Module:scripts/canonical names" local scripts_chartoscript_module = "Module:scripts/charToScript" local scripts_data_module = "Module:scripts/data" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local writing_systems_module = "Module:writing systems" local writing_systems_data_module = "Module:writing systems/data" local concat = table.concat local get_by_code -- Defined below. local gmatch = string.gmatch local insert = table.insert local make_object -- Defined below. local match = string.match local require = require local select = select local setmetatable = setmetatable local toNFC = mw.ustring.toNFC local toNFD = mw.ustring.toNFD local toNFKC = mw.ustring.toNFKC local toNFKD = mw.ustring.toNFKD local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function category_name_has_suffix(...) category_name_has_suffix = require(language_like_module).categoryNameHasSuffix return category_name_has_suffix(...) end local function category_name_to_code(...) category_name_to_code = require(language_like_module).categoryNameToCode return category_name_to_code(...) end local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) end local function explode(...) explode = require(string_utilities_module).explode_utf8 return explode(...) end local function get_writing_system(...) get_writing_system = require(writing_systems_module).getByCode return get_writing_system(...) end local function keys_to_list(...) keys_to_list = require(table_module).keysToList return keys_to_list(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function to_json(...) to_json = require(json_module).toJSON return to_json(...) end local function track(page) debug_track("scripts/" .. page) return true end local function ugsub(...) ugsub = require(string_utilities_module).gsub return ugsub(...) end local function umatch(...) umatch = require(string_utilities_module).match return umatch(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local scripts_canonical_names local function get_scripts_canonical_names() scripts_canonical_names, get_scripts_canonical_names = load_data(scripts_canonical_names_module), nil return scripts_canonical_names end local scripts_data local function get_scripts_data() scripts_data, get_scripts_data = load_data(scripts_data_module), nil return scripts_data end local scripts_suffixes local function get_scripts_suffixes() scripts_suffixes, get_scripts_suffixes = { "script", "code", "notation", "letters", "numerals", "semaphore", }, nil for _, v in pairs(load_data(writing_systems_data_module)) do insert(scripts_suffixes, v[1]) end return scripts_suffixes end local Script = {} Script.__index = Script --[==[Returns the script code of the script. Example: {{lua|"Cyrl"}} for Cyrillic.]==] function Script:getCode() return self._code end --[==[ Return the canonical name of the script. This is the name used to represent that script on Wiktionary. Example: {"Cyrillic"} for Cyrillic. If `lang` is specified and the script has a language-specific name, return that (e.g. {"Shahmukhi"} for script `Aran` with Punjabi and certain related languages); otherwise, return the default name (if the script has different names in different languages, e.g. {"Arabic"} for `Aran`), or the only name if there is only one. ]==] function Script:getCanonicalName(lang) local rawdata = self._data[1] if type(rawdata) == "string" then return rawdata end local name if lang then name = rawdata[lang:getCode()] if name then return name end name = rawdata[lang:getFullCode()] if name then return name end end name = rawdata.default if not name then error(("Internal error: no default key in script name table for script %s"):format(self:getCode())) end return name end --[==[ Return the table mapping languages to names for the script. If the script has only one name (as most scripts do), return a string consisting of that name. Otherwise, return a table mapping language codes to names, where the key named `default` contains the default name used for languages not specified in the table. ]==] function Script:getCanonicalNameTable() return self._data[1] end --[==[ Return all canonical names of the script. The default name is first. ]==] function Script:getCanonicalNames() local rawdata = self._data[1] if type(rawdata) == "string" then return {rawdata} end local names = {} for lang, name in pairs(rawdata) do if lang ~= "default" then require(table_module).insertIfNot(names, name) end end table.sort(names) require(table_module).insertIfNot(names, rawdata.default, {pos = 1}) return names end --[==[ Return the display form of the script. For scripts, this is the same as the value returned by {:getCategoryName("nocap")}, i.e. it reads <code>"<var>NAME</var> script"</code> (e.g. {"Arabic script"}). The displayed text used in {:makeCategoryLink()} is always the same as the display form. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:getDisplayForm(lang) return self:getCategoryName("nocap", lang) end function Script:getAliases() Script.getAliases = require(language_like_module).getAliases return self:getAliases() end function Script:getVarieties(flatten) Script.getVarieties = require(language_like_module).getVarieties return self:getVarieties(flatten) end function Script:getOtherNames() Script.getOtherNames = require(language_like_module).getOtherNames return self:getOtherNames() end function Script:getAllNames() Script.getAllNames = require(language_like_module).getAllNames return self:getAllNames() end --[==[Returns the {{w|IETF language tag#Syntax of language tags|IETF subtag}} used for the script, which should always be a valid {{w|ISO 15924}} script code. This is used when constructing HTML {{code|html|lang{{=}}}} tags. The {{lua|ietf_subtag}} value from the script's data file is used, if present; otherwise, the script code is used. For script codes which contain a hyphen, only the part after the hyphen is used (e.g. {{lua|"fa-Arab"}} becomes {{lua|"Arab"}}).]==] function Script:getIETFSubtag() local code = self._ietf_subtag if code == nil then code = self._data.ietf_subtag or match(self:getCode(), "[^%-]+$") self._ietf_subtag = code end return code end --[==[Returns a script object for the parent of the script, such as {"Arab"} for {"fa-Arab"}. It returns {nil} for scripts without a parent, like {"Latn"}, {"Grek"}, etc.]==] function Script:getParent() local parent = self._parentObject if parent == nil then parent = self:getParentCode() -- If the value is nil, it's cached as false. parent = parent and get_by_code(parent) or false self._parentObject = parent end return parent or nil end --[==[Returns the script code of the parent of the script, such as {"Arab"} for {"fa-Arab"}. It returns {nil} for scripts without a parent, like {"Latn"}, {"Grek"}, etc.]==] function Script:getParentCode() local parent = self._parentCode if parent == nil then -- If the value is nil, it's cached as false. parent = self._data.parent or false self._parentCode = parent end return parent or nil end function Script:getSystemCodes() if not self._systemCodes then local system_codes = self._data[3] if type(system_codes) == "table" then self._systemCodes = system_codes elseif type(system_codes) == "string" then self._systemCodes = split(system_codes, ",", true, true) else self._systemCodes = {} end end return self._systemCodes end function Script:getSystems() if not self._systemObjects then self._systemObjects = {} for _, system in ipairs(self:getSystemCodes()) do insert(self._systemObjects, get_writing_system(system)) end end return self._systemObjects end --[==[Check whether the script is of type `system`, which can be a writing system code or object. If multiple systems are passed, return true if the script is any of the specified systems.]==] function Script:isSystem(...) for _, system in ipairs{...} do if type(system) == "table" then system = system:getCode() end for _, s in ipairs(self:getSystemCodes()) do if system == s then return true end end end return false end --[==[Returns a table of types as a lookup table (with the types as keys). Currently, the only possible type is {script}.]==] function Script:getTypes() local types = self._types if types == nil then types = {script = true} local rawtypes = self._data.type if rawtypes then for t in gmatch(rawtypes, "[^,]+") do types[t] = true end end self._types = types end return types end --[==[Given a list of types as strings, returns true if the script has all of them. Use {{lua|hasType("script")}} to determine if an object that may be a language, family or script is a script.]==] function Script:hasType(...) Script.hasType = require(language_like_module).hasType return self:hasType(...) end --[==[ Return the name of the main category of that script. Example: {"Cyrillic script"} for Cyrillic, whose category is at [[:Category:Cyrillic script]]. Unless optional argument `nocap` is given, the script name at the beginning of the returned value will be capitalized. This capitalization is correct for category names, but not if the script name is lowercase and the returned value of this function is used in the middle of a sentence. (For example, the script with the code `Semap` has the name {"flag semaphore"}, which should remain lowercase when used as part of the category name [[:Category:Translingual letters in flag semaphore]] but should be capitalized in [[:Category:Flag semaphore templates]].) If you are considering using {getCategoryName("nocap")}, use {getDisplayForm()} instead. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:getCategoryName(nocap, lang) local name = self:getCanonicalName(lang) if category_name_has_suffix(name, scripts_suffixes or get_scripts_suffixes()) then name = name .. " script" end if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end --[==[ Return a link to the appropriate category for the script, displaying using the display form of the script. For example, `Cyrl` returns `[[:Category:Cyrillic script|Cyrillic script]]`. The display form is not automatically capitalized, so e.g. the script code `Semap` will return `[[:Category:Flag semaphore|flag semaphore]]`. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:makeCategoryLink(lang) return "[[:Category:" .. self:getCategoryName(lang) .. "|" .. self:getDisplayForm(lang) .. "]]" end --[==[Returns the Wikidata item id for the script or <code>nil</code>. This corresponds to the the second field in the data modules.]==] function Script:getWikidataItem() Script.getWikidataItem = require(language_like_module).getWikidataItem return self:getWikidataItem() end --[==[ Returns the name of the Wikipedia article for the script. `project` specifies the language and project to retrieve the article from, defaulting to {"enwiki"} for the English Wikipedia. Normally if specified it should be the project code for a specific-language Wikipedia e.g. "zhwiki" for the Chinese Wikipedia, but it can be any project, including non-Wikipedia ones. If the project is the English Wikipedia and the property {wikipedia_article} is present in the data module it will be used first. In all other cases, a sitelink will be generated from {:getWikidataItem} (if set). The resulting value (or lack of value) is cached so that subsequent calls are fast. If no value could be determined, and `noCategoryFallback` is {false}, {:getCategoryName} is used as fallback; otherwise, {nil} is returned. Note that if `noCategoryFallback` is {nil} or omitted, it defaults to {false} if the project is the English Wikipedia, otherwise to {true}. In other words, under normal circumstances, if the English Wikipedia article couldn't be retrieved, the return value will fall back to a link to the script's category, but this won't normally happen for any other project. ]==] function Script:getWikipediaArticle(noCategoryFallback, project) Script.getWikipediaArticle = require(language_like_module).getWikipediaArticle return self:getWikipediaArticle(noCategoryFallback, project) end --[==[Returns the name of the Wikimedia Commons category page for the script.]==] function Script:getCommonsCategory() Script.getCommonsCategory = require(language_like_module).getCommonsCategory return self:getCommonsCategory() end --[==[Returns the charset defining the script's characters from the script's data file. This can be used to search for words consisting only of this script, but see the warning above.]==] function Script:getCharacters() return self.characters or nil end --[==[Returns the number of characters in the text that are part of this script. '''Note:''' You should never assume that text consists entirely of the same script. Strings may contain spaces, punctuation and even wiki markup or HTML tags. HTML tags will skew the counts, as they contain Latin-script characters. So it's best to avoid them.]==] function Script:countCharacters(text) local charset = self._data.characters if charset == nil then return 0 end return select(2, ugsub(text, "[" .. charset .. "]", "")) end function Script:hasCapitalization() return not not self._data.capitalized end --[==[Returns the {caret_capitalization} value from this script or a parent, or {nil} if none is set. {true} means unescaped {^} capitalizes the next transliteration letter; {false} means it is an error; {nil} means the default (enabled when the script is unicameral and transliteratable).]==] function Script:getCaretCapitalization() local sc = self while sc do local setting = sc._data.caret_capitalization if setting ~= nil then return not not setting end sc = sc:getParent() end return nil end --[==[Returns {true} if unescaped {^} should capitalize transliterations for this script.]==] function Script:hasCaretCapitalization() local setting = self:getCaretCapitalization() if setting ~= nil then return setting end return not self:hasCapitalization() and self:isTransliterated() end --[==[Returns {true} if unescaped {^} is forbidden ({caret_capitalization = false} on this script or a parent).]==] function Script:forbidsCaretCapitalization() return self:getCaretCapitalization() == false end function Script:hasSpaces() return self._data.spaces ~= false end function Script:isTransliterated() return self._data.translit ~= false end --[==[Returns true if the script is (sometimes) sorted by scraping page content, meaning that it is sensitive to changes in capitalization during sorting.]==] function Script:sortByScraping() return not not self._data.sort_by_scraping end --[==[Returns the text direction. Horizontal scripts return {{lua|"ltr"}} (left-to-right) or {{lua|"rtl"}} (right-to-left), while vertical scripts return {{lua|"vertical-ltr"}} (vertical left-to-right) or {{lua|"vertical-rtl"}} (vertical right-to-left).]==] function Script:getDirection() return self._data.direction or "ltr" end function Script:getData() return self._data end --[==[Returns the name of the module containing the script's data. Currently, this is always [[Module:scripts/data]].]==] function Script:getDataModuleName() return scripts_data_module end --[==[Returns {{lua|true}} if the script contains characters that require fixes to Unicode normalization under certain circumstances, {{lua|false}} if it doesn't.]==] function Script:hasNormalizationFixes() return not not self._data.normalizationFixes end --[==[Corrects discouraged sequences of Unicode characters to the encouraged equivalents.]==] function Script:fixDiscouragedSequences(text) if self:hasNormalizationFixes() then local norm_fixes = self._data.normalizationFixes local to = norm_fixes.to if to then for i, v in ipairs(norm_fixes.from) do text = ugsub(text, v, to[i] or "") end end end return text end do local combining_classes -- Obtain the list of default combining classes. local function get_combining_classes() combining_classes, get_combining_classes = load_data(combining_classes_module), nil return combining_classes end -- Implements a modified form of Unicode normalization for instances where there are identified deficiencies in the default Unicode combining classes. local function fixNormalization(text, self) if not self:hasNormalizationFixes() then return text end local norm_fixes = self._data.normalizationFixes local new_classes = norm_fixes.combiningClasses if not (new_classes and umatch(text, "[" .. norm_fixes.combiningClassCharacters .. "]")) then return text end text = explode(text) -- Manual sort based on new combining classes. -- We can't use table.sort, as it compares the first/last values in an array as a shortcut, which messes things up. for i = 2, #text do local char = text[i] local class = new_classes[char] or (combining_classes or get_combining_classes())[char] if class then repeat i = i - 1 local prev = text[i] if (new_classes[prev] or (combining_classes or get_combining_classes())[prev] or 0) < class then break end text[i], text[i + 1] = char, prev until i == 1 end end return concat(text) end function Script:toFixedNFC(text) return fixNormalization(toNFC(text), self) end function Script:toFixedNFD(text) return fixNormalization(toNFD(text), self) end function Script:toFixedNFKC(text) return fixNormalization(toNFKC(text), self) end function Script:toFixedNFKD(text) return fixNormalization(toNFKD(text), self) end end function Script:toJSON(opts) local ret = { canonicalName = self:getCanonicalName(), canonicalNameTable = self:getCanonicalNameTable(), categoryName = self:getCategoryName("nocap"), code = self:getCode(), parent = self:getParentCode(), systems = self:getSystemCodes(), aliases = self:getAliases(), varieties = self:getVarieties(), otherNames = self:getOtherNames(), type = keys_to_list(self:getTypes()), direction = self:getDirection(), characters = self:getCharacters(), ietfSubtag = self:getIETFSubtag(), wikidataItem = self:getWikidataItem(), wikipediaArticle = self:getWikipediaArticle(true), } -- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`. return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts) end function export.makeObject(code, data) local data_type = type(data) if data_type ~= "table" then error(("bad argument #2 to 'makeObject' (table expected, got %s)"):format(data_type)) end return setmetatable({_data = data, _code = code, characters = data.characters}, Script) end make_object = export.makeObject local scripts_to_track = { ["fa-Arab"] = true, ["kk-Arab"] = true, ["ks-Arab"] = true, ["ku-Arab"] = true, ["ms-Arab"] = true, ["mzn-Arab"] = true, ["ota-Arab"] = true, ["pa-Arab"] = true, ["ps-Arab"] = true, ["sd-Arab"] = true, ["tt-Arab"] = true, ["ug-Arab"] = true, ["ur-Arab"] = true, } --[==[ Finds the script whose code matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}.]==] function export.getByCode(code) if scripts_to_track[code] then track(code) end local data = (scripts_data or get_scripts_data())[code] return data ~= nil and make_object(code, data) or nil end get_by_code = export.getByCode --[==[ Look for the script whose canonical name (the name used to represent that script on Wiktionary) matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}. The canonical name of scripts should always be unique (it is an error for two scripts on Wiktionary to share the same canonical name), so this is guaranteed to give at most one result.]==] function export.getByCanonicalName(name) if name == nil then return nil end local code = (scripts_canonical_names or get_scripts_canonical_names())[name] if code == nil then return nil end return get_by_code(code) end --[==[ Look for the script whose category name (the name used in categories for that script) matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}. In almost all cases, the category name for a script is its canonical name plus the word "script", e.g. "Cyrillic" has the category name "Cyrillic script". Where a canonical name ends with "script", "code" or "semaphore", the category name is identical to the canonical name. ]==] function export.getByCategoryName(name) if name == nil then return nil end local code, canonical_name = category_name_to_code( name, " script", scripts_canonical_names or get_scripts_canonical_names(), scripts_suffixes or get_scripts_suffixes() ) if code == nil then return nil, nil end return get_by_code(code), canonical_name end --[==[ Convert a canonical name to the corresponding category name. Unless optional argument `nocap` is given, the script name at the beginning of the returned value will be capitalized. See {:getCategoryName()} for more discussion. ]==] function export.canonicalNameToCategoryName(name, nocap) if category_name_has_suffix(name, scripts_suffixes or get_scripts_suffixes()) then name = name .. " script" end if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end --[==[ Takes a codepoint or a character and finds the script code (if any) that is appropriate for it based on the codepoint, using the data module [[Module:scripts/recognition data]]. The data module was generated from the patterns in [[Module:scripts/data]] using [[Module:User:Erutuon/script recognition]]. Converts the character to a codepoint. Returns a script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to, else returns "None". ]==] function export.charToScript(char) export.charToScript = require(scripts_chartoscript_module).charToScript return export.charToScript(char) end --[==[ Returns the code for the script that has the greatest number of characters in `text`. Useful for script tagging text that is unspecified for language. Uses [[Module:scripts/recognition data]] to determine a script code for a character language-agnostically. Specifically, it works as follows: Convert each character to a codepoint. Increment the counter for the script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to. Each script has a two-part counter, for primary and secondary matches. Primary matches are when the script is the first one listed; otherwise, it's a secondary match. When comparing scripts, first the total of both are compared (i.e. the overall number of matches). If these are the same, the number of primary and then secondary matches are used as tiebreakers. For example, this is used to ensure that `Grek` takes priority over `Polyt` if no characters which exclusively match `Polyt` are found, as `Grek` is a subset of `Polyt`. If `none_is_last_resort_only` is specified, this will never return {"None"} if any characters in `text` belong to a script. Otherwise, it will return {"None"} if there are more characters that don't belong to a script than belong to any individual script. (FIXME: This behavior is probably wrong, and `none_is_last_resort_only` should probably become the default.) ]==] function export.findBestScriptWithoutLang(text, none_is_last_resort_only) export.findBestScriptWithoutLang = require(scripts_chartoscript_module).findBestScriptWithoutLang return export.findBestScriptWithoutLang(text, none_is_last_resort_only) end return export 391jugwei8ugmbatc3z2z8ddqthugox 239377 239376 2026-11-22T04:40:23Z Lee 19 පැරණි සංස්කරණයකින් ගත් කොටස්... 239377 Scribunto text/plain local export = {} local combining_classes_module = "Module:Unicode data/combining classes" local debug_track_module = "Module:debug/track" local json_module = "Module:JSON" local language_like_module = "Module:language-like" local load_module = "Module:load" local scripts_canonical_names_module = "Module:scripts/canonical names" local scripts_chartoscript_module = "Module:scripts/charToScript" local scripts_data_module = "Module:scripts/data" local string_utilities_module = "Module:string utilities" local table_module = "Module:table" local writing_systems_module = "Module:writing systems" local writing_systems_data_module = "Module:writing systems/data" local concat = table.concat local get_by_code -- Defined below. local gmatch = string.gmatch local insert = table.insert local make_object -- Defined below. local match = string.match local require = require local select = select local setmetatable = setmetatable local toNFC = mw.ustring.toNFC local toNFD = mw.ustring.toNFD local toNFKC = mw.ustring.toNFKC local toNFKD = mw.ustring.toNFKD local type = type --[==[ Loaders for functions in other modules, which overwrite themselves with the target function when called. This ensures modules are only loaded when needed, retains the speed/convenience of locally-declared pre-loaded functions, and has no overhead after the first call, since the target functions are called directly in any subsequent calls.]==] local function category_name_has_suffix(...) category_name_has_suffix = require(language_like_module).categoryNameHasSuffix return category_name_has_suffix(...) end local function category_name_to_code(...) category_name_to_code = require(language_like_module).categoryNameToCode return category_name_to_code(...) end local function debug_track(...) debug_track = require(debug_track_module) return debug_track(...) end local function deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) end local function explode(...) explode = require(string_utilities_module).explode_utf8 return explode(...) end local function get_writing_system(...) get_writing_system = require(writing_systems_module).getByCode return get_writing_system(...) end local function keys_to_list(...) keys_to_list = require(table_module).keysToList return keys_to_list(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) end local function split(...) split = require(string_utilities_module).split return split(...) end local function to_json(...) to_json = require(json_module).toJSON return to_json(...) end local function track(page) debug_track("scripts/" .. page) return true end local function ugsub(...) ugsub = require(string_utilities_module).gsub return ugsub(...) end local function umatch(...) umatch = require(string_utilities_module).match return umatch(...) end --[==[ Loaders for objects, which load data (or some other object) into some variable, which can then be accessed as "foo or get_foo()", where the function get_foo sets the object to "foo" and then returns it. This ensures they are only loaded when needed, and avoids the need to check for the existence of the object each time, since once "foo" has been set, "get_foo" will not be called again.]==] local scripts_canonical_names local function get_scripts_canonical_names() scripts_canonical_names, get_scripts_canonical_names = load_data(scripts_canonical_names_module), nil return scripts_canonical_names end local scripts_data local function get_scripts_data() scripts_data, get_scripts_data = load_data(scripts_data_module), nil return scripts_data end local scripts_suffixes local function get_scripts_suffixes() scripts_suffixes, get_scripts_suffixes = { "script", "code", "notation", "letters", "numerals", "සංඥා", }, nil for _, v in pairs(load_data(writing_systems_data_module)) do insert(scripts_suffixes, v[1]) end return scripts_suffixes end local Script = {} Script.__index = Script --[==[Returns the script code of the script. Example: {{lua|"Cyrl"}} for Cyrillic.]==] function Script:getCode() return self._code end --[==[ Return the canonical name of the script. This is the name used to represent that script on Wiktionary. Example: {"Cyrillic"} for Cyrillic. If `lang` is specified and the script has a language-specific name, return that (e.g. {"Shahmukhi"} for script `Aran` with Punjabi and certain related languages); otherwise, return the default name (if the script has different names in different languages, e.g. {"Arabic"} for `Aran`), or the only name if there is only one. ]==] function Script:getCanonicalName(lang) local rawdata = self._data[1] if type(rawdata) == "string" then return rawdata end local name if lang then name = rawdata[lang:getCode()] if name then return name end name = rawdata[lang:getFullCode()] if name then return name end end name = rawdata.default if not name then error(("Internal error: no default key in script name table for script %s"):format(self:getCode())) end return name end --[==[ Return the table mapping languages to names for the script. If the script has only one name (as most scripts do), return a string consisting of that name. Otherwise, return a table mapping language codes to names, where the key named `default` contains the default name used for languages not specified in the table. ]==] function Script:getCanonicalNameTable() return self._data[1] end --[==[ Return all canonical names of the script. The default name is first. ]==] function Script:getCanonicalNames() local rawdata = self._data[1] if type(rawdata) == "string" then return {rawdata} end local names = {} for lang, name in pairs(rawdata) do if lang ~= "default" then require(table_module).insertIfNot(names, name) end end table.sort(names) require(table_module).insertIfNot(names, rawdata.default, {pos = 1}) return names end --[==[ Return the display form of the script. For scripts, this is the same as the value returned by {:getCategoryName("nocap")}, i.e. it reads <code>"<var>NAME</var> script"</code> (e.g. {"Arabic script"}). The displayed text used in {:makeCategoryLink()} is always the same as the display form. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:getDisplayForm(lang) return self:getCategoryName("nocap", lang) end function Script:getAliases() Script.getAliases = require(language_like_module).getAliases return self:getAliases() end function Script:getVarieties(flatten) Script.getVarieties = require(language_like_module).getVarieties return self:getVarieties(flatten) end function Script:getOtherNames() Script.getOtherNames = require(language_like_module).getOtherNames return self:getOtherNames() end function Script:getAllNames() Script.getAllNames = require(language_like_module).getAllNames return self:getAllNames() end --[==[Returns the {{w|IETF language tag#Syntax of language tags|IETF subtag}} used for the script, which should always be a valid {{w|ISO 15924}} script code. This is used when constructing HTML {{code|html|lang{{=}}}} tags. The {{lua|ietf_subtag}} value from the script's data file is used, if present; otherwise, the script code is used. For script codes which contain a hyphen, only the part after the hyphen is used (e.g. {{lua|"fa-Arab"}} becomes {{lua|"Arab"}}).]==] function Script:getIETFSubtag() local code = self._ietf_subtag if code == nil then code = self._data.ietf_subtag or match(self:getCode(), "[^%-]+$") self._ietf_subtag = code end return code end --[==[Returns a script object for the parent of the script, such as {"Arab"} for {"fa-Arab"}. It returns {nil} for scripts without a parent, like {"Latn"}, {"Grek"}, etc.]==] function Script:getParent() local parent = self._parentObject if parent == nil then parent = self:getParentCode() -- If the value is nil, it's cached as false. parent = parent and get_by_code(parent) or false self._parentObject = parent end return parent or nil end --[==[Returns the script code of the parent of the script, such as {"Arab"} for {"fa-Arab"}. It returns {nil} for scripts without a parent, like {"Latn"}, {"Grek"}, etc.]==] function Script:getParentCode() local parent = self._parentCode if parent == nil then -- If the value is nil, it's cached as false. parent = self._data.parent or false self._parentCode = parent end return parent or nil end function Script:getSystemCodes() if not self._systemCodes then local system_codes = self._data[3] if type(system_codes) == "table" then self._systemCodes = system_codes elseif type(system_codes) == "string" then self._systemCodes = split(system_codes, ",", true, true) else self._systemCodes = {} end end return self._systemCodes end function Script:getSystems() if not self._systemObjects then self._systemObjects = {} for _, system in ipairs(self:getSystemCodes()) do insert(self._systemObjects, get_writing_system(system)) end end return self._systemObjects end --[==[Check whether the script is of type `system`, which can be a writing system code or object. If multiple systems are passed, return true if the script is any of the specified systems.]==] function Script:isSystem(...) for _, system in ipairs{...} do if type(system) == "table" then system = system:getCode() end for _, s in ipairs(self:getSystemCodes()) do if system == s then return true end end end return false end --[==[Returns a table of types as a lookup table (with the types as keys). Currently, the only possible type is {script}.]==] function Script:getTypes() local types = self._types if types == nil then types = {script = true} local rawtypes = self._data.type if rawtypes then for t in gmatch(rawtypes, "[^,]+") do types[t] = true end end self._types = types end return types end --[==[Given a list of types as strings, returns true if the script has all of them. Use {{lua|hasType("script")}} to determine if an object that may be a language, family or script is a script.]==] function Script:hasType(...) Script.hasType = require(language_like_module).hasType return self:hasType(...) end --[==[ Return the name of the main category of that script. Example: {"Cyrillic script"} for Cyrillic, whose category is at [[:Category:Cyrillic script]]. Unless optional argument `nocap` is given, the script name at the beginning of the returned value will be capitalized. This capitalization is correct for category names, but not if the script name is lowercase and the returned value of this function is used in the middle of a sentence. (For example, the script with the code `Semap` has the name {"flag semaphore"}, which should remain lowercase when used as part of the category name [[:Category:Translingual letters in flag semaphore]] but should be capitalized in [[:Category:Flag semaphore templates]].) If you are considering using {getCategoryName("nocap")}, use {getDisplayForm()} instead. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:getCategoryName(nocap, lang) local name = self:getCanonicalName(lang) if category_name_has_suffix(name, scripts_suffixes or get_scripts_suffixes()) then name = name .. " අක්ෂරක්‍රමය" end if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end --[==[ Return a link to the appropriate category for the script, displaying using the display form of the script. For example, `Cyrl` returns `[[:Category:Cyrillic script|Cyrillic script]]`. The display form is not automatically capitalized, so e.g. the script code `Semap` will return `[[:Category:Flag semaphore|flag semaphore]]`. If the script has different names in different languages (e.g. `Aran`, which is called {"Shahmukhi"} in Punjabi and certain related languages but otherwise {"Arabic"}), and `lang` is given, return the language-specific name; otherwise return the default or only name. ]==] function Script:makeCategoryLink(lang) return "[[:Category:" .. self:getCategoryName(lang) .. "|" .. self:getDisplayForm(lang) .. "]]" end --[==[Returns the Wikidata item id for the script or <code>nil</code>. This corresponds to the the second field in the data modules.]==] function Script:getWikidataItem() Script.getWikidataItem = require(language_like_module).getWikidataItem return self:getWikidataItem() end --[==[ Returns the name of the Wikipedia article for the script. `project` specifies the language and project to retrieve the article from, defaulting to {"enwiki"} for the English Wikipedia. Normally if specified it should be the project code for a specific-language Wikipedia e.g. "zhwiki" for the Chinese Wikipedia, but it can be any project, including non-Wikipedia ones. If the project is the English Wikipedia and the property {wikipedia_article} is present in the data module it will be used first. In all other cases, a sitelink will be generated from {:getWikidataItem} (if set). The resulting value (or lack of value) is cached so that subsequent calls are fast. If no value could be determined, and `noCategoryFallback` is {false}, {:getCategoryName} is used as fallback; otherwise, {nil} is returned. Note that if `noCategoryFallback` is {nil} or omitted, it defaults to {false} if the project is the English Wikipedia, otherwise to {true}. In other words, under normal circumstances, if the English Wikipedia article couldn't be retrieved, the return value will fall back to a link to the script's category, but this won't normally happen for any other project. ]==] function Script:getWikipediaArticle(noCategoryFallback, project) Script.getWikipediaArticle = require(language_like_module).getWikipediaArticle return self:getWikipediaArticle(noCategoryFallback, project) end --[==[Returns the name of the Wikimedia Commons category page for the script.]==] function Script:getCommonsCategory() Script.getCommonsCategory = require(language_like_module).getCommonsCategory return self:getCommonsCategory() end --[==[Returns the charset defining the script's characters from the script's data file. This can be used to search for words consisting only of this script, but see the warning above.]==] function Script:getCharacters() return self.characters or nil end --[==[Returns the number of characters in the text that are part of this script. '''Note:''' You should never assume that text consists entirely of the same script. Strings may contain spaces, punctuation and even wiki markup or HTML tags. HTML tags will skew the counts, as they contain Latin-script characters. So it's best to avoid them.]==] function Script:countCharacters(text) local charset = self._data.characters if charset == nil then return 0 end return select(2, ugsub(text, "[" .. charset .. "]", "")) end function Script:hasCapitalization() return not not self._data.capitalized end --[==[Returns the {caret_capitalization} value from this script or a parent, or {nil} if none is set. {true} means unescaped {^} capitalizes the next transliteration letter; {false} means it is an error; {nil} means the default (enabled when the script is unicameral and transliteratable).]==] function Script:getCaretCapitalization() local sc = self while sc do local setting = sc._data.caret_capitalization if setting ~= nil then return not not setting end sc = sc:getParent() end return nil end --[==[Returns {true} if unescaped {^} should capitalize transliterations for this script.]==] function Script:hasCaretCapitalization() local setting = self:getCaretCapitalization() if setting ~= nil then return setting end return not self:hasCapitalization() and self:isTransliterated() end --[==[Returns {true} if unescaped {^} is forbidden ({caret_capitalization = false} on this script or a parent).]==] function Script:forbidsCaretCapitalization() return self:getCaretCapitalization() == false end function Script:hasSpaces() return self._data.spaces ~= false end function Script:isTransliterated() return self._data.translit ~= false end --[==[Returns true if the script is (sometimes) sorted by scraping page content, meaning that it is sensitive to changes in capitalization during sorting.]==] function Script:sortByScraping() return not not self._data.sort_by_scraping end --[==[Returns the text direction. Horizontal scripts return {{lua|"ltr"}} (left-to-right) or {{lua|"rtl"}} (right-to-left), while vertical scripts return {{lua|"vertical-ltr"}} (vertical left-to-right) or {{lua|"vertical-rtl"}} (vertical right-to-left).]==] function Script:getDirection() return self._data.direction or "ltr" end function Script:getData() return self._data end --[==[Returns the name of the module containing the script's data. Currently, this is always [[Module:scripts/data]].]==] function Script:getDataModuleName() return scripts_data_module end --[==[Returns {{lua|true}} if the script contains characters that require fixes to Unicode normalization under certain circumstances, {{lua|false}} if it doesn't.]==] function Script:hasNormalizationFixes() return not not self._data.normalizationFixes end --[==[Corrects discouraged sequences of Unicode characters to the encouraged equivalents.]==] function Script:fixDiscouragedSequences(text) if self:hasNormalizationFixes() then local norm_fixes = self._data.normalizationFixes local to = norm_fixes.to if to then for i, v in ipairs(norm_fixes.from) do text = ugsub(text, v, to[i] or "") end end end return text end do local combining_classes -- Obtain the list of default combining classes. local function get_combining_classes() combining_classes, get_combining_classes = load_data(combining_classes_module), nil return combining_classes end -- Implements a modified form of Unicode normalization for instances where there are identified deficiencies in the default Unicode combining classes. local function fixNormalization(text, self) if not self:hasNormalizationFixes() then return text end local norm_fixes = self._data.normalizationFixes local new_classes = norm_fixes.combiningClasses if not (new_classes and umatch(text, "[" .. norm_fixes.combiningClassCharacters .. "]")) then return text end text = explode(text) -- Manual sort based on new combining classes. -- We can't use table.sort, as it compares the first/last values in an array as a shortcut, which messes things up. for i = 2, #text do local char = text[i] local class = new_classes[char] or (combining_classes or get_combining_classes())[char] if class then repeat i = i - 1 local prev = text[i] if (new_classes[prev] or (combining_classes or get_combining_classes())[prev] or 0) < class then break end text[i], text[i + 1] = char, prev until i == 1 end end return concat(text) end function Script:toFixedNFC(text) return fixNormalization(toNFC(text), self) end function Script:toFixedNFD(text) return fixNormalization(toNFD(text), self) end function Script:toFixedNFKC(text) return fixNormalization(toNFKC(text), self) end function Script:toFixedNFKD(text) return fixNormalization(toNFKD(text), self) end end function Script:toJSON(opts) local ret = { canonicalName = self:getCanonicalName(), canonicalNameTable = self:getCanonicalNameTable(), categoryName = self:getCategoryName("nocap"), code = self:getCode(), parent = self:getParentCode(), systems = self:getSystemCodes(), aliases = self:getAliases(), varieties = self:getVarieties(), otherNames = self:getOtherNames(), type = keys_to_list(self:getTypes()), direction = self:getDirection(), characters = self:getCharacters(), ietfSubtag = self:getIETFSubtag(), wikidataItem = self:getWikidataItem(), wikipediaArticle = self:getWikipediaArticle(true), } -- Use `deep_copy` when returning a table, so that there are no editing restrictions imposed by `mw.loadData`. return opts and opts.lua_table and deep_copy(ret) or to_json(ret, opts) end function export.makeObject(code, data) local data_type = type(data) if data_type ~= "table" then error(("bad argument #2 to 'makeObject' (table expected, got %s)"):format(data_type)) end return setmetatable({_data = data, _code = code, characters = data.characters}, Script) end make_object = export.makeObject local scripts_to_track = { ["fa-Arab"] = true, ["kk-Arab"] = true, ["ks-Arab"] = true, ["ku-Arab"] = true, ["ms-Arab"] = true, ["mzn-Arab"] = true, ["ota-Arab"] = true, ["pa-Arab"] = true, ["ps-Arab"] = true, ["sd-Arab"] = true, ["tt-Arab"] = true, ["ug-Arab"] = true, ["ur-Arab"] = true, } --[==[ Finds the script whose code matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}.]==] function export.getByCode(code) if scripts_to_track[code] then track(code) end local data = (scripts_data or get_scripts_data())[code] return data ~= nil and make_object(code, data) or nil end get_by_code = export.getByCode --[==[ Look for the script whose canonical name (the name used to represent that script on Wiktionary) matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}. The canonical name of scripts should always be unique (it is an error for two scripts on Wiktionary to share the same canonical name), so this is guaranteed to give at most one result.]==] function export.getByCanonicalName(name) if name == nil then return nil end local code = (scripts_canonical_names or get_scripts_canonical_names())[name] if code == nil then return nil end return get_by_code(code) end --[==[ Look for the script whose category name (the name used in categories for that script) matches the one provided. If it exists, it returns a {Script} object representing the script. Otherwise, it returns {nil}. In almost all cases, the category name for a script is its canonical name plus the word "script", e.g. "Cyrillic" has the category name "Cyrillic script". Where a canonical name ends with "script", "code" or "semaphore", the category name is identical to the canonical name. ]==] function export.getByCategoryName(name) if name == nil then return nil end local code, canonical_name = category_name_to_code( name, " අක්ෂරක්‍රමය", scripts_canonical_names or get_scripts_canonical_names(), scripts_suffixes or get_scripts_suffixes() ) if code == nil then return nil, nil end return get_by_code(code), canonical_name end --[==[ Convert a canonical name to the corresponding category name. Unless optional argument `nocap` is given, the script name at the beginning of the returned value will be capitalized. See {:getCategoryName()} for more discussion. ]==] function export.canonicalNameToCategoryName(name, nocap) if category_name_has_suffix(name, scripts_suffixes or get_scripts_suffixes()) then name = name .. " script" end if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end --[==[ Takes a codepoint or a character and finds the script code (if any) that is appropriate for it based on the codepoint, using the data module [[Module:scripts/recognition data]]. The data module was generated from the patterns in [[Module:scripts/data]] using [[Module:User:Erutuon/script recognition]]. Converts the character to a codepoint. Returns a script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to, else returns "None". ]==] function export.charToScript(char) export.charToScript = require(scripts_chartoscript_module).charToScript return export.charToScript(char) end --[==[ Returns the code for the script that has the greatest number of characters in `text`. Useful for script tagging text that is unspecified for language. Uses [[Module:scripts/recognition data]] to determine a script code for a character language-agnostically. Specifically, it works as follows: Convert each character to a codepoint. Increment the counter for the script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to. Each script has a two-part counter, for primary and secondary matches. Primary matches are when the script is the first one listed; otherwise, it's a secondary match. When comparing scripts, first the total of both are compared (i.e. the overall number of matches). If these are the same, the number of primary and then secondary matches are used as tiebreakers. For example, this is used to ensure that `Grek` takes priority over `Polyt` if no characters which exclusively match `Polyt` are found, as `Grek` is a subset of `Polyt`. If `none_is_last_resort_only` is specified, this will never return {"None"} if any characters in `text` belong to a script. Otherwise, it will return {"None"} if there are more characters that don't belong to a script than belong to any individual script. (FIXME: This behavior is probably wrong, and `none_is_last_resort_only` should probably become the default.) ]==] function export.findBestScriptWithoutLang(text, none_is_last_resort_only) export.findBestScriptWithoutLang = require(scripts_chartoscript_module).findBestScriptWithoutLang return export.findBestScriptWithoutLang(text, none_is_last_resort_only) end return export cvj99t0pums1sdch866u7tamckxb39x Module:affix 828 13847 239391 239024 2026-11-22T11:49:18Z Lee 19 අත් හැරී තිබූ කොටසක් එකතු කිරීම. 239391 Scribunto text/plain local m_sinhala = require("Module:sinhala") local export = {} local debug_force_cat = false -- if set to true, always display categories even on userspace pages local m_links = require("Module:links") local m_str_utils = require("Module:string utilities") local m_table = require("Module:table") local decorations_module = "Module:decorations" local en_utilities_module = "Module:en-utilities" local etymology_module = "Module:etymology" local scripts_module = "Module:scripts" local utilities_module = "Module:utilities" -- Export this so the category code in [[Module:category tree/etymology]] can access it. export.affix_lang_data_module_prefix = "Module:affix/lang-data/" local ulen = m_str_utils.len local ufind = m_str_utils.find local umatch = m_str_utils.match local pluralize = require(en_utilities_module).pluralize local singularize = require(en_utilities_module).singularize local u = m_str_utils.char local ucfirst = m_str_utils.ucfirst local concat = table.concat local insert = table.insert local unpack = unpack or table.unpack -- Lua 5.2 compatibility function export.affix_variants(canonical, variants) local mappings = {} for _, variant in ipairs(variants) do mappings[variant] = canonical end return mappings end function export.id_mapping(default, ids) local mapping = { default = default } if ids then for id, target in pairs(ids) do mapping[id] = target end end return mapping end function export.id_mapping_with_affix_variants(base, id_variants) local mappings = {} for id, variants in pairs(id_variants) do for _, variant in ipairs(variants) do mappings[variant] = export.id_mapping(base, {[id] = base}) end end return mappings end function export.merge_tables(...) local result = {} for i = 1, select('#', ...) do local t = select(i, ...) if t then for k, v in pairs(t) do result[k] = v end end end return result end -- Export this so the category code in [[Module:category tree/etymology]] can access it. export.langs_with_lang_specific_data = { ["az"] = true, ["fi"] = true, ["fr"] = true, ["izh"] = true, ["la"] = true, ["sah"] = true, ["tr"] = true, ["trk-pro"] = true, } local default_pos = "term" local function pluralize_pos(pos) return pluralize(singularize(pos)) end --[==[ intro: ===About different types of hyphens ("template", "display" and "lookup"):=== * The "template hyphen" is the per-script hyphen character that is used in template calls to indicate that a term is an affix. This is always a single Unicode char, but there may be multiple possible hyphens for a given script. Normally this is just the regular hyphen character "-", but for some non-Latin-script languages (currently only right-to-left languages), it is different. * The "display hyphen" is the string (which might be an empty string) that is added onto a term as displayed and linked, to indicate that a term is an affix. Currently this is always either the same as the template hyphen or an empty string, but the code below is written generally enough to handle arbitrary display hyphens. Specifically: *# For East Asian languages, the display hyphen is always blank. *# For Arabic-script languages, either tatweel (ـ) or ZWNJ (zero-width non-joiner) are allowed as template hyphens, where ZWNJ is supported primarily for Farsi, because some suffixes have non-joining behavior. The display hyphen corresponding to tatweel is also tatweel, but the display hyphen corresponding to ZWNJ is blank (tatweel is also the default display hyphen, for calls to {{tl|prefix}}/{{tl|suffix}}/etc. that don't include an explicit hyphen). * The "lookup hyphen" is the hyphen that is used when looking up language-specific affix mappings. (These mappings are discussed in more detail below when discussing link affixes.) It depends only on the script of the affix in question. Most scripts (including East Asian scripts) use a regular hyphen "-" as the lookup hyphen, but Hebrew and Arabic have their own lookup hyphens (respectively maqqef and tatweel). Note that for Arabic in particular, there are three possible template hyphens that are recognized (tatweel, ZWNJ and regular hyphen), but mappings must use tatweel. ===About different types of affixes ("template", "display", "link", "lookup" and "category"):=== * A "template affix" is an affix in its source form as it appears in a template call. Generally, a template affix has an attached template hyphen (see above) to indicate that it is an affix and indicate what type of affix it is (prefix, suffix, interfix or circumfix), but some of the older-style templates such as {{tl|suffix}}, {{tl|prefix}}, {{tl|confix}}, etc. have "positional" affixes where the presence of the affix in a certain position (e.g. the second or third parameter) indicates that it is a certain type of affix, whether or not it has an attached template hyphen. * A "display affix" is the corresponding affix as it is actually displayed to the user. The display affix may differ from the template affix for various reasons: *# The display affix may be specified explicitly using the {{para|alt<var>N</var>}} parameter, the `<alt:...>` inline modifier or a piped link of the form e.g. `<nowiki>[[-kas|-käs]]</nowiki>` (here indicating that the affix should display as `-käs` but be linked as `-kas`). Here, the template affix is arguably the entire piped link, while the display affix is `-käs`. *# Even in the absence of {{para|alt<var>N</var>}} parameters, `<alt:...>` inline modifiers and piped links, certain languages have differences between the "template hyphen" specified in the template (which always needs to be specified somehow or other in templates like {{tl|affix}}, to indicate that the term is an affix and what type of affix it is) and the display hyphen (see above), with corresponding differences between template and display affixes. * A (regular) "link affix" is the affix that is linked to when the affix is shown to the user. The link affix is usually the same as the display affix, but will differ in one of three circumstances: *# The display and link affixes are explicitly made different using {{para|alt<var>N</var>}} parameters, `<alt:...>` inline modifiers or piped links, as described above under "display affix". *# For certain languages, certain affixes are mapped to canonical form using language-specific mappings. For example, in Finnish, the adjective-forming suffix {{m|fi|-kas}} appears as {{m|fi|-käs}} after front vowels, but logically both forms are the same suffix and should be linked and categorized the same. Similarly, in Latin, the negative and intensive prefixes spelled {{m|la|in-}} (etymologically two distinct prefixes) appear variously as {{m|la|il-}}, {{m|la|im-}} or {{m|la|ir-}} before certain consonants. Mappings are supplied in [[Module:affix/lang-data/LANGCODE]] to convert Finnish {{m|fi|-käs}} to {{m|fi|-kas}} for linking and categorization purposes. Note that the affixes in the mappings use "lookup hyphens" to indicate the different types of affixes, which is usually the same as the template hyphen but differs for Arabic scripts, because there are multiple possible template hyphens recognized but only one lookup hyphen (tatweel). The form of the affix as used to look up in the mapping tables is called the "lookup affix"; see below. * A "stripped link affix" is a link affix that has been passed through the language's `stripDiacritics()` function, which may strip certain diacritics: e.g. macrons in Latin and Old English (indicating length); acute and grave accents in Russian and various other Slavic languages (indicating stress); vowel diacritics in most Arabic-script languages; and also tatweel in some Arabic-script languages (currently, for example, Persian, Arabic and Urdu strip tatweel, but Ottoman Turkish does not). Stripped link affixes are currently what are used in category names. * A "lookup affix" is the form of the affix as it is looked up in the language-specific lookup mappings described above under link affixes. There are actually two lookup stages: *# First, the affix is looked up in a modified display form (specifically, the same as the display affix but using lookup hyphens). Note that this lookup does not occur if an explicit display form is given using {{para|alt<var>N</var>}} or an `<alt:...>` inline modifier, or if the template affix contains a piped or embedded link. *# If no entry is found, the affix is then looked up in a modified link form (specifically, the modified display form passed through the language's `stripDiacritics()` function, which strips out certain diacritics, but with the lookup hyphen re-added if it was stripped out, as in the case of tatweel in many Arabic-script languages). The reason for this double lookup procedure is to allow for mappings that are sensitive to the extra diacritics, but also allow for mappings that are not sensitive in this fashion (e.g. Russian {{m|ru|-ливый}} occurs both stressed and unstressed, but is the same prefix either way). * A "category affix" is the affix as it appears in categories such as [[:Category:Finnish terms suffixed with -kas| Category:Finnish terms suffixed with ''-kas'']]. The category affix is currently always the same as the stripped link affix. This means that for Arabic-script languages, it may or may not have a tatweel, even if the correponding display affix and regular link affix have a tatweel. As mentioned above, stripDiacritics() strips tatweel for Arabic, Persian and Urdu, but not for Ottoman Turkish. Hence affix categories for Arabic, Persian and Urdu will be missing the tatweel, but affix categories for Ottoman Turkish will have it. An additional complication is that if the template affix contains a ZWNJ, the display (and hence the link and category affixes) will have no hyphen attached in any case. ]==] ----------------------------------------------------------------------------------------- -- Template and display hyphens -- ----------------------------------------------------------------------------------------- --[=[ Per-script template hyphens. The template hyphen is what appears in the {{affix}}/{{prefix}}/{{suffix}}/etc. template (in the wikicode). See above. They key below is a script code, after removing a hyphen and anything preceding. Hence, script codes like 'mnc-Mong' and 'xwo-Mong' will match 'Mong'. The value below is a string consisting of one or more hyphen characters. If there is more than one character, the default hyphen must come last and a non-default function must be specified for the script in display_hyphens[] so the correct display hyphen will be specified when no template hyphen is given (in {{suffix}}/{{prefix}}/etc.). Script detection is normally done when linking, but we need to do it earlier. However, under most circumstances we don't need to do script detection. Specifically, we only need to do script detection for a given language if (a) the language has multiple scripts; and (b) at least one of those scripts is listed below or in display_hyphens. ]=] local ZWNJ = u(0x200C) -- zero-width non-joiner local template_hyphens = { -- This covers all Arabic scripts. See above. ["Arab"] = "ـ" .. ZWNJ .. "-", -- tatweel + zero-width non-joiner + regular hyphen ["Aran"] = "ـ" .. ZWNJ .. "-", -- tatweel + zero-width non-joiner + regular hyphen ["Hebr"] = "־", -- Hebrew-specific hyphen termed "maqqef" ["Mong"] = "᠊", -- FIXME! What about the following right-to-left scripts? -- Adlm (Adlam) -- Armi (Imperial Aramaic) -- Avst (Avestan) -- Cprt (Cypriot) -- Khar (Kharoshthi) -- Mand (Mandaic/Mandaean) -- Mani (Manichaean) -- Mend (Mende/Mende Kikakui) -- Narb (Old North Arabian) -- Nbat (Nabataean/Nabatean) -- Nkoo (N'Ko) -- Orkh (Orkhon runes) -- Phli (Inscriptional Pahlavi) -- Phlp (Psalter Pahlavi) -- Phlv (Book Pahlavi) -- Phnx (Phoenician) -- Prti (Inscriptional Parthian) -- Rohg (Hanifi Rohingya) -- Samr (Samaritan) -- Sarb (Old South Arabian) -- Sogd (Sogdian) -- Sogo (Old Sogdian) -- Syrc (Syriac) -- Thaa (Thaana) } -- Hyphens used when looking up an affix in a lang-specific affix mapping. Defaults to regular hyphen (-). The keys -- are script codes, after removing a hyphen and anything preceding. Hence, script codes like 'mnc-Mong' and 'xwo-Mong' -- will match 'Mong'. The value should be a single character. local lookup_hyphens = { ["Hebr"] = "־", -- This covers all Arabic scripts. See above. ["Arab"] = "ـ", ["Aran"] = "ـ", } -- Default display-hyphen function. local function default_display_hyphen(script, hyph) if not hyph then return template_hyphens[script] or "-" end return hyph end local function arab_get_display_hyphen(_script, hyph) if not hyph then return "ـ" -- tatweel elseif hyph == ZWNJ then return "" else return hyph end end local function no_display_hyphen(_script, _hyph) return "" end -- Per-script function to return the correct display hyphen given the script and template hyphen. The function should -- also handle the case where the passed-in template hyphen is nil, corresponding to the situation in -- {{prefix}}/{{suffix}}/etc. where no template hyphen is specified. The key is the script code after removing a hyphen -- and anything preceding, so 'mnc-Mong', 'xwo-Mong' etc. will match 'Mong'. local display_hyphens = { -- This covers all Arabic scripts. See above. ["Arab"] = arab_get_display_hyphen, ["Aran"] = arab_get_display_hyphen, ["Bopo"] = no_display_hyphen, ["Hani"] = no_display_hyphen, ["Hans"] = no_display_hyphen, ["Hant"] = no_display_hyphen, -- The following is a mixture of several scripts. Hopefully the specs here are correct! ["Jpan"] = no_display_hyphen, ["Jurc"] = no_display_hyphen, ["Kitl"] = no_display_hyphen, ["Kits"] = no_display_hyphen, ["Laoo"] = no_display_hyphen, ["Nshu"] = no_display_hyphen, ["Shui"] = no_display_hyphen, ["Tang"] = no_display_hyphen, ["Thaa"] = no_display_hyphen, ["Thai"] = no_display_hyphen, ["Tibt"] = no_display_hyphen, } ----------------------------------------------------------------------------------------- -- Basic Utility functions -- ----------------------------------------------------------------------------------------- local function glossary_link(entry, text) text = text or entry return "[[Appendix:Glossary#" .. entry .. "|" .. text .. "]]" end local function track(page) if type(page) == "table" then for i, pg in ipairs(page) do page[i] = "affix/" .. pg end else page = "affix/" .. page end require("Module:debug/track")(page) end local function ine(val) return val ~= "" and val or nil end ----------------------------------------------------------------------------------------- -- Compound types -- ----------------------------------------------------------------------------------------- local function make_compound_type(typ, alttext) return { text = glossary_link(typ, alttext) .. " compound", cat = typ .. " compounds", } end -- Make a compound type entry with a simple rather than glossary link. -- These should be replaced with a glossary link when the entry in the glossary -- is created. local function make_non_glossary_compound_type(typ, alttext) local link = alttext and "[[" .. typ .. "|" .. alttext .. "]]" or "[[" .. typ .. "]]" return { text = link .. " compound", cat = typ .. " compounds", } end local function make_raw_compound_type(typ, alttext) return { text = glossary_link(typ, alttext), cat = pluralize(typ), } end local function make_borrowing_type(typ, alttext) return { text = glossary_link(typ, alttext), borrowing_type = pluralize(typ), } end export.etymology_types = { ["adapted borrowing"] = make_borrowing_type("adapted borrowing"), ["adap"] = "adapted borrowing", ["abor"] = "adapted borrowing", ["alliterative"] = make_non_glossary_compound_type("alliterative"), ["allit"] = "alliterative", ["antonymous"] = make_non_glossary_compound_type("antonymous"), ["ant"] = "antonymous", ["bahuvrihi"] = make_compound_type("bahuvrihi", "bahuvrīhi"), ["bahu"] = "bahuvrihi", ["bv"] = "bahuvrihi", ["coordinative"] = make_compound_type("coordinative"), ["coord"] = "coordinative", ["descriptive"] = make_compound_type("descriptive"), ["desc"] = "descriptive", ["determinative"] = make_compound_type("determinative"), ["det"] = "determinative", ["dvandva"] = make_compound_type("dvandva"), ["dva"] = "dvandva", ["dvigu"] = make_compound_type("dvigu"), ["dvi"] = "dvigu", ["endocentric"] = make_compound_type("endocentric"), ["endo"] = "endocentric", ["exocentric"] = make_compound_type("exocentric"), ["exo"] = "exocentric", ["izafet I"] = make_compound_type("izafet I"), ["iz1"] = "izafet I", ["izafet II"] = make_compound_type("izafet II"), ["iz2"] = "izafet II", ["izafet III"] = make_compound_type("izafet III"), ["iz3"] = "izafet III", ["karmadharaya"] = make_compound_type("karmadharaya", "karmadhāraya"), ["karma"] = "karmadharaya", ["kd"] = "karmadharaya", ["kenning"] = make_raw_compound_type("kenning"), ["ken"] = "kenning", ["rhyming"] = make_non_glossary_compound_type("rhyming"), ["rhy"] = "rhyming", ["synonymous"] = make_non_glossary_compound_type("synonymous"), ["syn"] = "synonymous", ["tatpurusa"] = make_compound_type("tatpurusa", "tatpuruṣa"), ["tat"] = "tatpurusa", ["tp"] = "tatpurusa", } local function process_etymology_type(typ, nocap, notext, has_parts) local text_sections = {} local categories = {} local borrowing_type if typ then local typdata = export.etymology_types[typ] if type(typdata) == "string" then typdata = export.etymology_types[typdata] end if not typdata then error("Internal error: Unrecognized type '" .. typ .. "'") end local text = typdata.text if not nocap then text = ucfirst(text) end local cat = typdata.cat borrowing_type = typdata.borrowing_type local oftext = typdata.oftext or " of" if not notext then insert(text_sections, text) if has_parts then insert(text_sections, oftext) insert(text_sections, " ") end end if cat then insert(categories, cat) end end return text_sections, categories, borrowing_type end ----------------------------------------------------------------------------------------- -- Utility functions -- ----------------------------------------------------------------------------------------- -- Iterate an array up to the greatest integer index found. local function ipairs_with_gaps(t) local indices = m_table.numKeys(t) local max_index = #indices > 0 and math.max(unpack(indices)) or 0 local i = 0 return function() if i < max_index then i = i + 1 return i, t[i] end end end export.ipairs_with_gaps = ipairs_with_gaps --[==[ Join formatted parts together with any overall {{para|lit}} spec, overall left and/or right qualifiers and labels, and categories. On input, `data` is a structure with the following fields: * `affixdata`: The affix data passed into an entry point such as `##show_affix()`; the code in this function examines the `lang`, `lit`, `force_cat`, `nocat`, `sort_key`, `q`, `qq`, `l` and `ll` fields of this structure, which represent overall values for these properties (as opposed to per-part values, which are found inside the list of per-part objects in `parts`, which are not examined); * `parts_formatted`: List of formatted parts, each a string; * `separator_already_added`: If true, any separators have already been included in `parts_formatted`, so the values should be concatenated with nothing in between; otherwise, the separator {" +&lrm; "} will be used, i.e. a `+` sign surrounded by spaces along with a Unicode left-to-right character to ensure that the parts appear in left-to-right order even if they contain right-to-left text; * `categories`: List of category strings or category objects; category strings are formatted using the `sort_key` field in the affix data structure in `affixdata`, while category objects, which are of the form `{ {cat=``category``, sort_key=``sort_key``, sort_base=``sort_base``}`, specify their own sort key and sort base; if `affixdata.nocat` is given, no categories are added; otherwise, `affixdata.force_cat` or global variable `debug_force_cat` causes categories to be added even on userspace pages. ]==] function export.join_formatted_parts(data) local cattext local affixdata = data.affixdata local lang = affixdata.lang local force_cat = affixdata.force_cat or debug_force_cat if affixdata.nocat then cattext = "" else for i, cat in ipairs(data.categories) do if type(cat) == "table" then data.categories[i] = require(utilities_module).format_categories(lang:getFullName() .. " " .. cat.cat, lang, cat.sort_key, cat.sort_base, force_cat) else data.categories[i] = require(utilities_module).format_categories(lang:getFullName() .. " " .. cat, lang, affixdata.sort_key, nil, force_cat) end end cattext = concat(data.categories) end local result = concat(data.parts_formatted, not data.separator_already_added and " +&lrm; " or nil) .. (affixdata.lit and ", literally " .. m_links.mark(affixdata.lit, "gloss") or "") local q = affixdata.q local qq = affixdata.qq local l = affixdata.l local ll = affixdata.ll if q and q[1] or qq and qq[1] or l and l[1] or ll and ll[1] then result = require(decorations_module).format_decorations { lang = lang, text = result, q = q, qq = qq, l = l, ll = ll, } end return result .. cattext end -- Remove links and call lang:stripDiacritics(term). local function strip_diacritics_no_links(lang, term) return lang:stripDiacritics(m_links.remove_links(term)) end --[=[ Convert a raw part as passed into an entry point into a part ready for linking. `lang` and `sc` are the overall language and script objects. This uses the overall language and script objects as defaults for the part and parses off any fragment from the term. We need to do the latter so that fragments don't end up in categories and so that we correctly do affix mapping even in the presence of fragments. ]=] local function canonicalize_part(part, lang, sc) if not part then return end -- Save the original (user-specified, part-specific) value of `lang`. If such a value is specified, we don't insert -- a '*fixed with' category, and we format the part using format_derived() in [[Module:etymology]] rather than -- full_link() in [[Module:links]]. part.part_lang = part.lang part.lang = part.lang or lang part.sc = part.sc or sc local term = part.term if not term then return elseif not part.fragment then part.term, part.fragment = m_links.get_fragment(term) else part.term = m_links.get_fragment(term) end end --[==[ Construct a single linked part based on the information in `part`, for use by `show_affix()` and other entry points. This should be called after `canonicalize_part()` is called on the part. This is a thin wrapper around `full_link()` in [[Module:links]] unless `part.part_lang` is specified (indicating that a part-specific language was given), in which case `format_derived()` in [[Module:etymology]] is called to display a term in a language other than the language of the overall term (specified in `data.lang`). `data` contains the entire object passed into the entry point and is used to access information for constructing the categories added by `format_derived()`. ]==] function export.link_term(part, data, include_separator) local result if part.part_lang then result = require(etymology_module).format_derived { lang = data.lang, terms = {part}, sources = {part.lang}, sort_key = data.sort_key, nocat = data.nocat, template_name = "affix", decorations_on_outside = true, borrowing_type = data.borrowing_type, force_cat = data.force_cat or debug_force_cat, } else result = m_links.full_link(part, "term") end if include_separator and part.separator then return part.separator .. result else return result end end local function canonicalize_script_code(scode) -- Convert 'mnc-Mong', 'xwo-Mong' etc. to 'Mong'. return (scode:gsub("^.*%-", "")) end ----------------------------------------------------------------------------------------- -- Affix-handling functions -- ----------------------------------------------------------------------------------------- -- Figure out the appropriate script for the given affix and language (unless the script is explicitly passed in), and -- return the values of template_hyphens[], display_hyphens[] and lookup_hyphens[] for that script, substituting -- default values as appropriate. Four values are returned: -- DETECTED_SCRIPT, TEMPLATE_HYPHEN, DISPLAY_HYPHEN, LOOKUP_HYPHEN local function detect_script_and_hyphens(text, lang, sc) local scode -- 1. If the script is explicitly passed in, use it. if sc then scode = sc:getCode() else local possible_script_codes = lang:getScriptCodes() -- YUCK! `possible_script_codes` comes from loadData() so #possible_scripts doesn't work (always returns 0). local num_possible_script_codes = m_table.length(possible_script_codes) if num_possible_script_codes == 0 then -- This shouldn't happen; if the language has no script codes, -- the list {"None"} should be returned. error("Something is majorly wrong! Language " .. lang:getCanonicalName() .. " has no script codes.") end if num_possible_script_codes == 1 then -- 2. If the language has only one possible script, use it. scode = possible_script_codes[1] else -- 3. Check if any of the possible scripts for the language have non-default values for template_hyphens[] -- or display_hyphens[]. If so, we need to do script detection on the text. If not, just use "Latn", -- which may not be technically correct but produces the right results because Latn has all default -- values for template_hyphens[] and display_hyphens[]. local may_have_nondefault_hyphen = false for _, script_code in ipairs(possible_script_codes) do script_code = canonicalize_script_code(script_code) if template_hyphens[script_code] or display_hyphens[script_code] then may_have_nondefault_hyphen = true break end end if not may_have_nondefault_hyphen then scode = "Latn" else scode = lang:findBestScript(text):getCode() end end end scode = canonicalize_script_code(scode) local template_hyphen = template_hyphens[scode] or "-" local lookup_hyphen = lookup_hyphens[scode] or "-" local display_hyphen = display_hyphens[scode] or default_display_hyphen return scode, template_hyphen, display_hyphen, lookup_hyphen end --[=[ Given a template affix `term` and an affix type `affix_type`, change the relevant template hyphen(s) in the affix to the display or lookup hyphen specified in `new_hyphen`, or add them if they are missing. `new_hyphen` can be a string, specifying a fixed hyphen, or a function of two arguments (the script code `scode` and the discovered template hyphen, or nil of no relevant template hyphen is present). `thyph_re` is a Lua pattern (which must be enclosed in parens) that matches the possible template hyphens. Note that not all template hyphens present in the affix are changed, but only the "relevant" ones (e.g. for a prefix, a relevant template hyphen is one coming at the end of the affix). ]=] local function reconstruct_term_per_hyphens(term, affix_type, scode, thyph_re, new_hyphen) local function get_hyphen(hyph) if type(new_hyphen) == "string" then return new_hyphen end return new_hyphen(scode, hyph) end if affix_type == "non-affix" then return term elseif affix_type == "circumfix" then local before, before_hyphen, after_hyphen, after = umatch(term, "^(.*)" .. thyph_re .. " " .. thyph_re .. "(.*)$") if not before or ulen(term) <= 3 then -- Unlike with other types of affixes, don't try to add hyphens in the middle of the term to convert it to -- a circumfix. Also, if the term is just hyphen + space + hyphen, return it. return term end return before .. get_hyphen(before_hyphen) .. " " .. get_hyphen(after_hyphen) .. after elseif affix_type == "infix" or affix_type == "interfix" then local before_hyphen, middle, after_hyphen = umatch(term, "^" .. thyph_re .. "(.*)" .. thyph_re .. "$") if before_hyphen and ulen(term) <= 1 then -- If the term is just a hyphen, return it. return term end return get_hyphen(before_hyphen) .. (middle or term) .. get_hyphen(after_hyphen) elseif affix_type == "prefix" then local middle, after_hyphen = umatch(term, "^(.*)" .. thyph_re .. "$") if middle and ulen(term) <= 1 then -- If the term is just a hyphen, return it. return term end return (middle or term) .. get_hyphen(after_hyphen) elseif affix_type == "suffix" then local before_hyphen, middle = umatch(term, "^" .. thyph_re .. "(.*)$") if before_hyphen and ulen(term) <= 1 then -- If the term is just a hyphen, return it. return term end return get_hyphen(before_hyphen) .. (middle or term) else error(("Internal error: Unrecognized affix type '%s'"):format(affix_type)) end end --[=[ Look up a mapping from a given affix variant to the canonical form used in categories and links. The lookup tables are language-specific according to `lang`, and may be ID-specific according to `affix_id`. The affixes as they appear in the lookup tables (both the variant and the canonical form) are in "lookup affix" format (approximately speaking, they use a regular hyphen for most scripts, but a tatweel for Arabic-script entries and a maqqef for Hebrew-script entries), but the passed-in `affix` param is in "template affix" format (which differs from the lookup affix for Arabic-script entries, because more types of hyphens are allowed in template affixes; see the comments at the top of the file). The remaining parameters to this function are used to convert from template affixes to lookup affixes; see the reconstruct_term_per_hyphens() function above. If the affix contains brackets, no lookup is done. Otherwise, a two-stage process is used, first looking up the affix directly and then stripping diacritics and looking it up again. The reason for this is documented above in the comments at the top of the file (specifically, the comments describing lookup affixes). The value of a mapping can either be a string (do the mapping regardless of affix ID) or a table indexed by affix ID (where the special value `false` indicates no affix ID). The values of entries in this table can also be strings, or tables with keys `affix` and `id` (again, use `false` to indicate no ID). This allows an affix mapping to map from one ID to another (for example, this is used in English to map the [[an-]] prefix with no ID to the [[a-]] prefix with the ID 'not'). The Given a template affix `term` and an affix type `affix_type`, change the relevant template hyphen(s) in the affix to the display or lookup hyphen specified in `new_hyphen`, or add them if they are missing. `new_hyphen` can be a string, specifying a fixed hyphen, or a function of two arguments (the script code `scode` and the discovered template hyphen, or nil of no relevant template hyphen is present). `thyph_re` is a Lua pattern (which must be enclosed in parens) that matches the possible template hyphens. Note that not all template hyphens present in the affix are changed, but only the "relevant" ones (e.g. for a prefix, a relevant template hyphen is one coming at the end of the affix). ]=] local function lookup_affix_mapping(affix, affix_type, lang, scode, thyph_re, lookup_hyph, affix_id) local function do_lookup(afx) -- Ensure that the affix uses lookup hyphens regardless of whether it used a different type of hyphens before -- or no hyphens. local lookup_affix = reconstruct_term_per_hyphens(afx, affix_type, scode, thyph_re, lookup_hyph) local function do_lookup_for_langcode(langcode) if export.langs_with_lang_specific_data[langcode] then local langdata = mw.loadData(export.affix_lang_data_module_prefix .. langcode) if langdata.affix_mappings then local mapping = langdata.affix_mappings[lookup_affix] if mapping then if type(mapping) == "table" then mapping = mapping[affix_id] or mapping.default or mapping[affix_id or false] if mapping then return mapping end else return mapping end end end end end -- If `lang` is an etymology-only language, look for a mapping both for it and its full parent. local langcode = lang:getCode() local mapping = do_lookup_for_langcode(langcode) if mapping then return mapping end local full_langcode = lang:getFullCode() if full_langcode ~= langcode then mapping = do_lookup_for_langcode(full_langcode) if mapping then return mapping end end return nil end if affix:find("%[%[") then return nil end return do_lookup(affix) or do_lookup(lang:stripDiacritics(affix)) or nil end --[==[ For a given template term in a given language (see the definition of "template affix" near the top of the file), possibly in an explicitly specified script `sc` (but usually nil), return the term's affix type ({"prefix"}, {"interfix"}, {"suffix"}, {"circumfix"} or {"non-affix"}) along with the corresponding link and display affixes (see definitions near the top of the file); also the corresponding lookup affix (if `return_lookup_affix` is specified). The term passed in should already have any fragment (after the # sign) parsed off of it. Four values are returned: `affix_type`, `link_term`, `display_term` and `lookup_term`. The affix type can be passed in instead of autodetected; in this case, the template term need not have any attached hyphens, and the appropriate hyphens will be added in the appropriate places. If `do_affix_mapping` is specified, look up the affix in the lang-specific affix mappings, as described in the comment at the top of the file; otherwise, the link and display terms will always be the same. (They will be the same in any case if the template term has a bracketed link in it or is not an affix.) If `return_lookup_affix` is given, the fourth return value contains the term with appropriate lookup hyphens in the appropriate places; otherwise, it is the same as the display term. (This functionality is used in [[Module:category tree/affixes and compounds]] to convert link affixes into lookup affixes so that they can be looked up in the affix mapping tables.) Exported because used by [[Module:headword utilities]] to determine the affix type of a given pagename. ]==] function export.parse_term_for_affixes(term, lang, sc, affix_type, do_affix_mapping, return_lookup_affix, affix_id) if not term then return "non-affix", nil, nil, nil end if term == "^" then -- Indicates a null term to emulate the behavior of {{suffix|foo||bar}}. term = nil return "non-affix", term, term, term end if term:find("^%^") then -- HACK! ^ at the beginning of Korean languages has a special meaning, triggering capitalization of the -- transliteration. Don't interpret it as "force non-affix" for those languages. local langcode = lang:getCode() if langcode ~= "ko" and langcode ~= "okm" and langcode ~= "jje" then -- Formerly we allowed ^ to force non-affix type; this is now handled using an inline modifier -- <naf>, <root>, etc. Throw an error for the moment when the old way is encountered. error("Use of ^ to force non-affix status is no longer supported; use an inline modifier <naf> or <root> " .. "after the component") end end -- Remove an asterisk if the morpheme is reconstructed and add it back at the end. local reconstructed = "" if term:find("^%*") then reconstructed = "*" term = term:gsub("^%*", "") end local scode, thyph, dhyph, lhyph = detect_script_and_hyphens(term, lang, sc) thyph = "([" .. thyph .. "])" if not affix_type then if ufind(term, thyph .. " " .. thyph) then affix_type = "circumfix" else local has_beginning_hyphen = ufind(term, "^" .. thyph) local has_ending_hyphen = ufind(term, thyph .. "$") if has_beginning_hyphen and has_ending_hyphen then affix_type = "interfix" elseif has_ending_hyphen then affix_type = "prefix" elseif has_beginning_hyphen then affix_type = "suffix" else affix_type = "non-affix" end end end local link_term, display_term, lookup_term if affix_type == "non-affix" then link_term = term display_term = term lookup_term = term else display_term = reconstruct_term_per_hyphens(term, affix_type, scode, thyph, dhyph) if do_affix_mapping then link_term = lookup_affix_mapping(term, affix_type, lang, scode, thyph, lhyph, affix_id) -- The return value of lookup_affix_mapping() may be an affix mapping with lookup hyphens if a mapping -- was found, otherwise nil if a mapping was not found. We need to convert to display hyphens in -- either case, but in the latter case we can reuse the display term, which has already been converted. if link_term then link_term = reconstruct_term_per_hyphens(link_term, affix_type, scode, thyph, dhyph) else link_term = display_term end else link_term = display_term end if return_lookup_affix then lookup_term = reconstruct_term_per_hyphens(term, affix_type, scode, thyph, lhyph) else lookup_term = display_term end end link_term = reconstructed .. link_term display_term = reconstructed .. display_term lookup_term = reconstructed .. lookup_term return affix_type, link_term, display_term, lookup_term end --[==[ Add a hyphen to a term in the appropriate place, based on the specified affix type, stripping off any existing hyphens in that place. For example, if `affix_type` == {"prefix"}, we'll add a hyphen onto the end if it's not already there (or is of the wrong type). Three values are returned: the link term, display term and lookup term. This function is a thin wrapper around `parse_term_for_affixes`; see the comments above that function for more information. Note that this function is exposed externally because it is called by [[Module:category tree/affixes and compounds]]; see the comment in `parse_term_for_affixes` for more information. ]==] function export.make_affix(term, lang, sc, affix_type, do_affix_mapping, return_lookup_affix, affix_id) if not (affix_type == "prefix" or affix_type == "suffix" or affix_type == "circumfix" or affix_type == "infix" or affix_type == "interfix" or affix_type == "non-affix") then error("Internal error: Invalid affix type " .. (affix_type or "(nil)")) end local _, link_term, display_term, lookup_term = export.parse_term_for_affixes(term, lang, sc, affix_type, do_affix_mapping, return_lookup_affix, affix_id) return link_term, display_term, lookup_term end ----------------------------------------------------------------------------------------- -- Categorization logic -- ----------------------------------------------------------------------------------------- local function insert_category(categories, cat, sort_key, sort_base) if sort_key or sort_base then insert(categories, {cat = cat, sort_key = sort_key, sort_base = sort_base}) else insert(categories, cat) end end --[=[ Insert a `*fixed with` category such as [[:Category:Welsh terms prefixed with gwe-]] into `categories`. The arguments are: * `categories`: List of category strings or objects to insert into. * `pos`: Part of speech in the category (which is often "terms" but may be something more specific). * `affix_type`: Affix type in the category (e.g. "prefix"); automatically has "ed" appended. * `link_term`: The term that appears in the category, e.g. "gwe-". If this is empty or missing, no category is inserted. * `part`: The part structure being processed. The `lang`, `part_lang`, `nocat` and `id` fields are fetched. * `sort_key`: The sort key for the specific category. If this or `sort_base` are non-nil, a category object is created holding the specified sort key and/or base, and inserted; otherwise, a cateory string is inserted. * `sort_base`: The sort base for the specific category. See `sort_key` just above. ]=] local function insert_affix_category(categories, pos, affix_type, link_term, part, sort_key, sort_base) -- Don't add a category if the link term is empty or is in a different language, or if <nocat:1> was specified for -- the part. if ine(link_term) and not part.part_lang and not part.nocat then local cat = m_sinhala.sinhala(pos) .. ", " .. strip_diacritics_no_links(part.lang, link_term) .. (part.id and " (" .. part.id .. ")" or "") .. " " .. m_sinhala.sinhala(affix_type .. "es") .. " සහිත" insert_category(categories, cat, sort_key, sort_base) end end --[=[ Generate the categories for a single part and insert into `categories`. The arguments are: * `categories` is the list to insert the categories into. * `data` is the overall affix data structure. * `part` is the per-part data structure. * `affix_type` is the type of affix (e.g. "prefix"), as appears in the `*fixed by` category. * `link_term` is the term that (prefix, suffix, etc.) mentioned in the `*fixed by` category. * `sort_key` and `sort_base` are the per-part sort keys and bases for categorization, or nil to use the overall sort key. ]=] local function generate_one_part_categories(categories, data, part, affix_type, link_term, sort_key, sort_base) if data.nocat or part.nocat then return end if part.pos and part.pos:find("patronym") then insert_category(categories, "patronymics", sort_key, sort_base) end if data.pos ~= "terms" and part.pos and part.pos:find("diminutive") then insert_category(categories, "diminutive " .. data.pos, sort_key, sort_base) end insert_affix_category(categories, data.pos, affix_type, link_term, part, sort_key, sort_base) end --[=[ Core categorization logic for affixes. This is shared between show_affix(), show_compound_like() and get_affix_categories_only(). Returns the categories array and other metadata needed for formatting. ]=] local function generate_affix_categories(data) data.pos = data.pos or default_pos data.pos = pluralize_pos(data.pos) local text_sections, categories, borrowing_type = process_etymology_type(data.type, data.surface_analysis or data.nocap, data.notext, #data.parts > 0) data.borrowing_type = borrowing_type -- Process each part local whole_words = 0 local is_affix_or_compound = false -- Canonicalize and generate links for all the parts first; then do categorization in a separate step, because when -- processing the first part for categorization, we may access the second part and need it already canonicalized. for i, part in ipairs_with_gaps(data.parts) do part = part or {} data.parts[i] = part canonicalize_part(part, data.lang, data.sc) -- Determine affix type and get link and display terms (see text at top of file). Store them in the part -- (in fields that won't clash with fields used by full_link() in [[Module:links]] or link_term()), so they -- can be used in the loop below when categorizing. part.affix_type, part.affix_link_term, part.affix_display_term = export.parse_term_for_affixes(part.term, part.lang, part.sc, part.type, not part.alt, nil, part.id) -- If link_term is an empty string, either a bare ^ was specified or an empty term was used along with inline -- modifiers. The intention in either case is not to link the term. part.term = ine(part.affix_link_term) -- If part.alt would be the same as part.term, make it nil, so that it isn't erroneously tracked as being -- redundant alt text. part.alt = part.alt or (part.affix_display_term ~= part.affix_link_term and part.affix_display_term) or nil end if not data.noaffixcat then -- Now do categorization. for i, part in ipairs_with_gaps(data.parts) do local affix_type = part.affix_type if affix_type ~= "non-affix" then is_affix_or_compound = true -- Make a sort key. For the first part, use the second part as the sort key; the intention is that if the -- term has a prefix, sorting by the prefix won't be very useful so we sort by what follows, which is -- presumably the root. local part_sort_base = nil local part_sort = part.sort or data.sort_key if i == 1 and data.parts[2] and data.parts[2].term then local part2 = data.parts[2] -- If the second-part link term is empty, the user requested an unlinked term; avoid a wikitext error -- by using the alt value if available. part_sort_base = ine(part2.affix_link_term) or ine(part2.alt) if part_sort_base then part_sort_base = strip_diacritics_no_links(part2.lang, part_sort_base) end end generate_one_part_categories(categories, data, part, affix_type, part.affix_link_term, part_sort, part_sort_base) else whole_words = whole_words + 1 if whole_words == 2 then is_affix_or_compound = true insert(categories, "සංයුක්ත " .. m_sinhala.sinhala(data.pos)) end end end -- Make sure there was either an affix or a compound (two or more non-affix terms). if not is_affix_or_compound and not data.allow_no_affixes_or_compounds then error("The parameters did not include any affixes, and the term is not a compound. Please provide at least one affix.") end end return text_sections, categories, borrowing_type end -- Return true if specified part has no term or alt and no modifiers. WARNING: Keep this up-to-date -- in case any other fields are added that are always present. local function part_is_empty(part) for k, v in pairs(part) do if k ~= "affix_type" and k ~= "lang" and k ~= "orig_index" and k ~= "itemno" and k ~= "separator" then return false end end return true end ----------------------------------------------------------------------------------------- -- Main entry points -- ----------------------------------------------------------------------------------------- --[==[ Implementation of {{tl|affix}} and {{tl|surface analysis}}. `data` contains all the information describing the affixes to be displayed, and contains the following: * `.lang` ('''required'''): Overall language object. Different from term-specific language objects (see `.parts` below). * `.sc`: Overall script object (usually omitted). Different from term-specific script objects. * `.parts` ('''required'''): List of objects describing the affixes to show. The general format of each object is as would be passed to `full_link()`, except that the `.lang` field should be missing unless the term is of a language different from the overall `.lang` value (in such a case, the language name is shown along with the term and an additional "derived from" category is added). '''WARNING''': The data in `.parts` will be destructively modified. * `.pos`: Overall part of speech (used in categories, defaults to {"terms"}). Different from term-specific part of speech. * `.sort_key`: Overall sort key. Normally omitted except e.g. in Japanese. * `.type`: Type of compound, if the parts in `.parts` describe a compound. Strictly optional, and if supplied, the compound type is displayed before the parts (normally capitalized, unless `.nocap` is given). * `.nocap`: Don't capitalize the first letter of text displayed before the parts (relevant only if `.type` or `.surface_analysis` is given). * `.notext`: Don't display any text before the parts (relevant only if `.type` or `.surface_analysis` is given). * `.nocat`: Disable all categorization. * `.noaffixcat`: Disable affix (and compound) categorization. Relevant for e.g. blends, which may otherwise be incorrectly categorized as compound terms. * `.lit`: Overall literal definition. Different from term-specific literal definitions. * `.force_cat`: Always display categories, even on userspace pages. * `.surface_analysis`: Implement {{surface analysis}}; adds `By surface analysis, ` before the parts. '''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`. ]==] function export.show_affix(data) local text_sections, categories, _ = generate_affix_categories(data) -- Process each part for display local parts_formatted = {} for i, part in ipairs_with_gaps(data.parts) do -- Make a link for the part if part_is_empty(part) then if part.separator then insert(parts_formatted, part.separator) end -- don't call full_link(); we allow this to emulate the behavior of {{suf}} and {{pre}} in such cases. else insert(parts_formatted, export.link_term(part, data, "include_separator")) end end if data.surface_analysis then local text = "by " .. glossary_link("surface analysis") .. ", " if not data.nocap then text = ucfirst(text) end insert(text_sections, 1, text) end insert(text_sections, export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories, separator_already_added = true }) return concat(text_sections) end --[==[ Get only the categories that would be generated by show_affix(), without any text output or formatting. This is used by Module:etymon to get affix categorization. Returns an array of category objects, where each entry is either a string (simple category name) or a table with keys `cat`, `sort_key`, and `sort_base` for more complex categorization. `data` should have the same structure as passed to show_affix(): * `.lang` (required): Overall language object * `.parts` (required): Array of affix part objects with `.term`, `.lang`, `.id`, etc. * `.pos`: Part of speech (defaults to "terms") * `.sort_key`: Overall sort key for categories '''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`. ]==] function export.get_affix_categories_only(data) local _, categories, _ = generate_affix_categories(data) return categories end function export.show_surface_analysis(data) data.surface_analysis = true data.allow_no_affixes_or_compounds = true return export.show_affix(data) end --[==[ Implementation of {{tl|compound}}. '''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`. ]==] function export.show_compound(data) data.pos = data.pos or default_pos data.pos = pluralize_pos(data.pos) local text_sections, categories, borrowing_type = process_etymology_type(data.type, data.nocap, data.notext, #data.parts > 0) data.borrowing_type = borrowing_type local parts_formatted = {} insert(categories, "සංයුක්ත " .. m_sinhala.sinhala(data.pos)) -- Make links out of all the parts local whole_words = 0 for i, part in ipairs(data.parts) do canonicalize_part(part, data.lang, data.sc) -- Determine affix type and get link and display terms (see text at top of file). local affix_type, link_term, display_term = export.parse_term_for_affixes(part.term, part.lang, part.sc, part.type, not part.alt, nil, part.id) -- If the term is an interfix or the type was explicitly given, recognize it as such (which means e.g. that we -- will display the term without hyphens for East Asian languages). Otherwise, ignore the fact that it looks -- like an affix and display as specified in the template (but pay attention to the detected affix type for -- certain tracking purposes). if affix_type == "interfix" or (part.type and part.type ~= "non-affix") then -- Add a `*fixed with` category. However, if link_term is an empty string, either a bare ^ was specified or -- an empty term was used along with inline modifiers. The intention in either case is not to link the term. -- Don't add a category in this case, or if the term is in a different language (or if overall nocat=1 was -- given, or part-specific <nocat:1>). if not data.nocat then -- FIXME, should we be specifying a sort base here? insert_affix_category(categories, data.pos, affix_type, link_term, part, part.sort or data.sort_key) end -- If part.alt would be the same as part.term, make it nil, so that it isn't erroneously tracked as being -- redundant alt text. part.term = link_term ~= "" and link_term or nil part.alt = part.alt or (display_term ~= link_term and display_term) or nil else if affix_type ~= "non-affix" then local langcode = data.lang:getCode() -- If `data.lang` is an etymology-only language, track both using its code and its full parent's code. track { affix_type, affix_type .. "/lang/" .. langcode } local full_langcode = data.lang:getFullCode() if langcode ~= full_langcode then track(affix_type .. "/lang/" .. full_langcode) end else whole_words = whole_words + 1 end end insert(parts_formatted, export.link_term(part, data, "include_separator")) end if whole_words == 1 then track("one whole word") elseif whole_words == 0 then track("looks like confix") end insert(text_sections, export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories, separator_already_added = true }) return concat(text_sections) end --[==[ Implementation of {{tl|blend}}, {{tl|univerbation}} and similar "compound-like" templates. '''WARNING''': This destructively modifies both `data` and the individual structures within `.parts`. ]==] function export.show_compound_like(data) data.allow_no_affixes_or_compounds = true local text_sections, categories, _ = generate_affix_categories(data) if data.cat then insert(categories, data.cat) end -- Process each part for display local parts_formatted = {} for i, part in ipairs_with_gaps(data.parts) do -- Make a link for the part insert(parts_formatted, export.link_term(part, data, "include_separator")) end if #data.parts > 0 and data.oftext then insert(text_sections, 1, " " .. data.oftext .. " ") end if data.text then insert(text_sections, 1, data.text) end insert(text_sections, export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories, separator_already_added = true }) return concat(text_sections) end --[==[ Make `part` (a structure holding information on an affix part) into an affix of type `affix_type`, and apply any relevant affix mappings. For example, if the desired affix type is "suffix", this will (in general) add a hyphen onto the beginning of the term, alt, tr and ts components of the part if not already present. The hyphen that's added is the "display hyphen" (see above) and may be script-specific. (In the case of East Asian scripts, the display hyphen is an empty string whereas the template hyphen is the regular hyphen, meaning that any regular hyphen at the beginning of the part will be effectively removed.) `lang` and `sc` hold overall language and script objects. Note that this also applies any language-specific affix mappings, so that e.g. if the language is Finnish and the user specified [[-käs]] in the affix and didn't specify an `.alt` value, `part.term` will contain [[-kas]] and `part.alt` will contain [[-käs]]. This function is used by the "legacy" templates ({{tl|prefix}}, {{tl|suffix}}, {{tl|confix}}, etc.) where the nature of the affix is specified by the template itself rather than auto-determined from the affix, as is the case with {{tl|affix}}. '''WARNING''': This destructively modifies `part`. ]==] local function make_part_into_affix(part, lang, sc, affix_type) canonicalize_part(part, lang, sc) local link_term, display_term = export.make_affix(part.term, part.lang, part.sc, affix_type, not part.alt, nil, part.id) part.term = link_term -- When we don't specify `do_affix_mapping` to make_affix(), link and display terms (first and second retvals of -- make_affix()) are the same. -- If part.alt would be the same as part.term, make it nil, so that it isn't erroneously tracked as being -- redundant alt text. part.alt = part.alt and export.make_affix(part.alt, part.lang, part.sc, affix_type) or (display_term ~= link_term and display_term) or nil local Latn = require(scripts_module).getByCode("Latn") part.tr = export.make_affix(part.tr, part.lang, Latn, affix_type) part.ts = export.make_affix(part.ts, part.lang, Latn, affix_type) end local function track_wrong_affix_type(template, part, expected_affix_type) if part and not part.type then local affix_type = export.parse_term_for_affixes(part.term, part.lang, part.sc) if affix_type ~= expected_affix_type then local part_name = expected_affix_type or "base" local langcode = part.lang:getCode() local full_langcode = part.lang:getFullCode() require("Module:debug/track") { template, template .. "/" .. part_name, template .. "/" .. part_name .. "/" .. (affix_type or "none"), template .. "/" .. part_name .. "/" .. (affix_type or "none") .. "/lang/" .. langcode } -- If `part.lang` is an etymology-only language, track both using its code and its full parent's code. if full_langcode ~= langcode then require("Module:debug/track")( template .. "/" .. part_name .. "/" .. (affix_type or "none") .. "/lang/" .. full_langcode ) end end end end --[==[ Implementation of {{tl|confix}}. '''WARNING''': This destructively modifies both `data` and `.prefix`, `.base` and `.suffix`. ]==] function export.show_confix(data) data.pos = data.pos or default_pos data.pos = pluralize_pos(data.pos) canonicalize_part(data.base, data.lang, data.sc) -- Hyphenate the affixes and apply any affix mappings. make_part_into_affix(data.prefix, data.lang, data.sc, "prefix") make_part_into_affix(data.suffix, data.lang, data.sc, "suffix") track_wrong_affix_type("confix", data.prefix, "prefix") track_wrong_affix_type("confix", data.base, nil) track_wrong_affix_type("confix", data.suffix, "suffix") -- Make links out of all the parts. local parts_formatted = {} local prefix_sort_base if data.base and data.base.term then prefix_sort_base = strip_diacritics_no_links(data.base.lang, data.base.term) elseif data.suffix.term then prefix_sort_base = strip_diacritics_no_links(data.suffix.lang, data.suffix.term) end -- Insert the categories and parts. local categories = {} insert(parts_formatted, export.link_term(data.prefix, data)) insert_affix_category(categories, data.pos, "prefix", data.prefix.term, data.prefix, data.sort_key, prefix_sort_base) if data.base then insert(parts_formatted, export.link_term(data.base, data)) end insert(parts_formatted, export.link_term(data.suffix, data)) -- FIXME, should we be specifying a sort base here? insert_affix_category(categories, data.pos, "suffix", data.suffix.term, data.suffix) return export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories } end --[==[ Implementation of {{tl|infix}}. '''WARNING''': This destructively modifies both `data` and `.base` and `.infix`. ]==] function export.show_infix(data) data.pos = data.pos or default_pos data.pos = pluralize_pos(data.pos) canonicalize_part(data.base, data.lang, data.sc) -- Hyphenate the affixes and apply any affix mappings. make_part_into_affix(data.infix, data.lang, data.sc, "infix") track_wrong_affix_type("infix", data.base, nil) track_wrong_affix_type("infix", data.infix, "infix") -- Make links out of all the parts. local parts_formatted = {} local categories = {} insert(parts_formatted, export.link_term(data.base, data)) insert(parts_formatted, export.link_term(data.infix, data)) -- Insert the categories. -- FIXME, should we be specifying a sort base here? insert_affix_category(categories, data.pos, "infix", data.infix.term, data.infix) return export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories } end --[==[ Implementation of {{tl|prefix}}. '''WARNING''': This destructively modifies both `data` and the structures within `.prefixes`, as well as `.base`. ]==] function export.show_prefix(data) data.pos = data.pos or default_pos data.pos = pluralize_pos(data.pos) canonicalize_part(data.base, data.lang, data.sc) -- Hyphenate the affixes and apply any affix mappings. for i, prefix in ipairs(data.prefixes) do make_part_into_affix(prefix, data.lang, data.sc, "prefix") end for i, prefix in ipairs(data.prefixes) do track_wrong_affix_type("prefix", prefix, "prefix") end track_wrong_affix_type("prefix", data.base, nil) -- Make links out of all the parts. local parts_formatted = {} local first_sort_base = nil local categories = {} if data.prefixes[2] then first_sort_base = ine(data.prefixes[2].term) or ine(data.prefixes[2].alt) if first_sort_base then first_sort_base = strip_diacritics_no_links(data.prefixes[2].lang, first_sort_base) end elseif data.base then first_sort_base = ine(data.base.term) or ine(data.base.alt) if first_sort_base then first_sort_base = strip_diacritics_no_links(data.base.lang, first_sort_base) end end for i, prefix in ipairs(data.prefixes) do insert(parts_formatted, export.link_term(prefix, data)) generate_one_part_categories(categories, data, prefix, "prefix", prefix.term, data.sort_key, i == 1 and first_sort_base or nil) end if data.base then insert(parts_formatted, export.link_term(data.base, data)) else insert(parts_formatted, "") end return export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories } end --[==[ Implementation of {{tl|suffix}}. '''WARNING''': This destructively modifies both `data` and the structures within `.suffixes`, as well as `.base`. ]==] function export.show_suffix(data) local categories = {} data.pos = data.pos or default_pos data.pos = pluralize_pos(data.pos) canonicalize_part(data.base, data.lang, data.sc) -- Hyphenate the affixes and apply any affix mappings. for i, suffix in ipairs(data.suffixes) do make_part_into_affix(suffix, data.lang, data.sc, "suffix") end track_wrong_affix_type("suffix", data.base, nil) for i, suffix in ipairs(data.suffixes) do track_wrong_affix_type("suffix", suffix, "suffix") end -- Make links out of all the parts. local parts_formatted = {} if data.base then insert(parts_formatted, export.link_term(data.base, data)) else insert(parts_formatted, "") end for i, suffix in ipairs(data.suffixes) do insert(parts_formatted, export.link_term(suffix, data)) end -- Insert the categories. for i, suffix in ipairs(data.suffixes) do -- FIXME, should we be specifying a sort base here? generate_one_part_categories(categories, data, suffix, "suffix", suffix.term) end return export.join_formatted_parts { affixdata = data, parts_formatted = parts_formatted, categories = categories } end return export 3xoiccciazq1mpcjkzhwdlu4797ddd8 ටියුනීසියාව 0 121937 239390 187969 2026-11-22T11:42:31Z Lee 19 239390 wikitext text/x-wiki == සිංහල == {{wikipedia}} [[File:Tunisia Locator.png|thumb|right|Tunisia]] === නිරුක්තිය === {{rfe|si}} === නාම පදය === {{si-noun}} # {{senseid|si|Q948}}{{place|si|country|r/North Africa|capital=Tunis}}. ## ඔටෝමාන් ටියුනීසියාව; 1534 සිට 1881 දක්වා ## ප්‍රංශ ටියුනීසියාව, 1881 සිට 1956 දක්වා ## ටියුනීසියා ජනරජය, 1956 සිට ==== පරිවර්තන ==== {{trans-top|පරිවර්තන}} * ඉංග්‍රීසි: {{t|en|Tunisia}} * අරාබි: {{t+|ar|تُونِس|f}}, {{t+|ar|تُونُس|f}} *: Hijazi Arabic: {{t|acw|تونِس|f|tr=tūnis}} * දිවෙහි: {{t|dv|ތޫނިސް}} * හින්දි: {{t+|hi|ट्यूनिशिया|m}}, {{t|hi|तूनिस|m}} * ජපන්: {{t+|ja|チュニジア|tr=Chunijia}} * කොරියානු: {{t+|ko|^튀니지}}, {{t+|ko|^뜌니지}} {{qualifier|North Korea}} * මරාථි: {{t|mr|ट्युनिसिया}} * රුසියානු: {{t+|ru|Туни́с|m}} * දෙමළ: {{t|ta|துனீசியா}} * තායි: {{t+|th|ตูนิเซีย}} {{trans-bottom}} === අමතර අවධානයට === * {{l|si|කර්තාජ්}} * [[Appendix:Countries of the world]] * {{list:countries of Africa/si}} dmev26wk95ewp7f02zwmlt1sl4quss9 Module:category tree/utilities 828 137607 239383 222115 2026-10-12T18:52:29Z en>Benwing2 0 +add_labels_from_specs(); fix some Luacheck issues 239383 Scribunto text/plain local export = {} local en_utilities_module = "Module:en-utilities" local m_string_utilities = require("Module:string utilities") local m_table = require("Module:table") local umatch = m_string_utilities.match local uupper = m_string_utilities.upper local ulower = m_string_utilities.lower local pattern_escape = m_string_utilities.pattern_escape local list_to_set = m_table.listToSet local dump = mw.dumpObject local insert = table.insert local unpack = unpack or table.unpack -- Lua 5.2 compatibility -- If true, output debugging information indicating which specs are being processed and which labels and label objects -- generated. local debug_add_labels_from_specs = false --[==[ Generate labels for inflection classes. `data` is a table with the following fields: * `labels`: The table into which the labels are written. * `pos`: The singular part of speech, e.g. "noun". * `stem_classes`: Table of possible stem classes and associated properties. See below. * `principal_parts`: List of the principal part fields and descriptions. Each list element is a two-element list consisting of {"FIELD", "DESCRIPTION"} where FIELD is the field in the element in `stem_classes` (e.g. "nom_sg", "gen_sg", "pl", "sup") containing the detailed description of what this principal part looks like, and DESCRIPTION is the corresponding English description of the principal part (e.g. "nominative singular"). * `mark_up_spec`: Optional function to add markup to a spec. Takes two arguments, the spec and a flag `nolink`; if the flag is true, links should not be present in the resulting markup. The default just converts literal text enclosed in <...> into italics. * `make_spec_bare`: Optional function to make a spec (stem class or sortkey) free of markup. The default just converts literal text enclosed in <...> into bare text. * `addl`: Optional additional text to be displayed in the footer of each category page. `stem_classes` is a table describing the various stem classes and how to format the category description of each. It is a table with keys specifying the stem classes and values consisting of an object containing properties of the stem class. If the stem class contains the word 'GENDER' in it, it expands into labels both for a parent category that subsumes several genders (obtained by removing the word 'GENDER' and following whitespace) as well as gender-specific children categories (obtained by replacing the word 'GENDER' with the genders specified in the `possible_genders` field). The stem class can contain literal text (e.g. suffixes), which will be marked up appropriately (e.g. italicized) in breadcrumbs and titles. The fields of the property object for a given stem class are as follows: * `gender`: The description of the gender(s) of the stem class. If preceded by ~, the description is preceded by "most commonly". This appears in the `additional` field of the label properties. It is not used in gender-specific children categories; instead the gender of that category is used. * `possible_genders`: The possible genders this class occurs in. If this is specified, the word 'GENDER' must occur in the stem class, and gender-specific variants of the stem class (with GENDER replaced by the possible genders) are handled along with a parent category subsuming all genders. * `PRINCIPAL_PART`: The ending for the specified principal part. Use <...> to enclose literal Latin-script text (e.g. suffixes), which will be italicized. There will be one field for each principal part listed in the `principal_parts` table described above. * `GENDER_PRINCIPAL_PART`: The ending for the GENDER variant of the specified principal part. If not specified, the value of `PRINCIPAL_PART` is used. * `breadcrumb`: The breadcrumb for the category, appearing in the trail of breadcrumbs at the top of the page. If this stem has gender-specific variants, the breadcrumb specified here is used only for the parent category, while the gender-specific child categories use the gender as the breadcrumb. If not specified, it defaults to `sortkey`. If that is also not specified, or if the breadcrumb has the value "+", the stem class (without the word 'GENDER') is used. (Use "+" when a sortkey is specified but the stem class should be used as the breadcrumb.) * `parent`: The parent category or categories. If specified, the actual category label is formed by appending the part of speech (e.g. "nouns"). Defaults to "POS by inflection type" where POS is the part of speech. Note that gender-specific child categories do not use this, but always have the gender-subsuming parent stem class category as their parent. * `sortkey`: The sort key used for sorting this category among its parent's children. Defaults to the stem class (without the word 'GENDER'). Note that gender-specific child categories do nto use this, but always use the gender as the sort key. * `addl`: Optional additional text to be displayed in the footer of the category page. * `GENDER_addl`: Optional additional text to be displayed in the footer of a gender-specific category page, defaulting to `addl`. Use the value `false` to cancel out a non-gender-specific value. ]==] function export.add_inflection_labels(data) for _, reqfield_spec in ipairs { {"labels", "table of labels"}, {"pos", "singular part of speech"}, {"stem_classes", "table of possible stem classes and associated properties"}, {"principal_parts", "list of principal part fields and names"}, } do local reqfield, gloss = unpack(reqfield_spec) if not data[reqfield] then error(("Internal error: Missing field '%s', which should containing the %s"):format(reqfield, gloss)) end end local function default_mark_up_spec(spec, _nolink) return (spec:gsub("<(.-)>", "''%1''")) end local function default_make_spec_bare(spec) return (spec:gsub("<(.-)>", "%1")) end local function mark_up_spec(spec, nolink) return (data.mark_up_spec or default_mark_up_spec)(spec, nolink) end local function make_spec_bare(spec) return (data.make_spec_bare or default_make_spec_bare)(spec) end local plpos = require(en_utilities_module).pluralize(data.pos) for full_infl, spec in pairs(data.stem_classes) do local subgenders = spec.possible_genders -- Get the stem type. local infl if subgenders then if not full_infl:find("GENDER") then error(("Internal error: Declension spec '%s' needs to have the word 'GENDER' in it, in all caps"):format(full_infl)) end infl = full_infl:gsub("GENDER ", "") else infl = full_infl end -- Get the breadcrumb. local breadcrumb = spec.breadcrumb or spec.sortkey or "+" if breadcrumb == "+" then breadcrumb = infl end -- Generate the parents. local parents = {} local spec_parents = spec.parent if type(spec_parents) == "string" then spec_parents = {spec_parents} end local parent_sort = make_spec_bare(spec.sortkey or infl) if spec_parents then for _, parent in ipairs(spec_parents) do table.insert(parents, {name = make_spec_bare(parent) .. " " .. plpos, sort = parent_sort}) end else table.insert(parents, {name = plpos .. " by inflection type", sort = parent_sort}) end -- Generate the additional text, including principal part descriptions and footer. local function create_addl(gender_spec, subgender_prefix) local addl_parts = {} local function ins(txt) table.insert(addl_parts, txt) end local function insert_header(gender_spec) if gender_spec then local most_commonly, gender = gender_spec:match("^(~)(.*)$") most_commonly = most_commonly and "most commonly " or "" gender = gender or gender_spec ins(("These %s are %s%s, typically with the following endings:\n"):format(plpos, most_commonly, mark_up_spec(gender))) else ins(("These %s typically have the following endings:\n"):format(plpos)) end end local function process_ending(field, desc, is_last) local ending_spec = spec[subgender_prefix .. field] or spec[field] if not ending_spec then error(("Internal error: for inflection '%s', field '%s' for principal part '%s' is missing"):format( full_infl, field, desc)) end return ("* in the %s: %s%s"):format(desc, mark_up_spec(ending_spec), is_last and "." or ";\n") end local function insert_principal_part_info() for i, ppart_spec in ipairs(data.principal_parts) do local ppart_field, ppart_desc = unpack(ppart_spec) ins(process_ending(ppart_field, ppart_desc, i == #data.principal_parts)) end end insert_header(gender_spec) insert_principal_part_info() local spec_addl = spec[subgender_prefix .. "addl"] if spec_addl == nil then spec_addl = spec.addl end if data.addl or spec_addl then local footer_parts = {} if data.addl then table.insert(footer_parts, mark_up_spec(data.addl)) end if spec_addl then table.insert(footer_parts, mark_up_spec(spec_addl)) end ins("\n" .. table.concat(footer_parts, " ")) end return table.concat(addl_parts) end data.labels[make_spec_bare(infl) .. " " .. plpos] = { description = "{{{langname}}} " .. mark_up_spec(infl) .. " " .. plpos .. ".", displaytitle = "{{{langname}}} " .. mark_up_spec(infl, "nolink") .. " " .. plpos, additional = create_addl(spec.gender, ""), breadcrumb = mark_up_spec(breadcrumb, "nolink"), parents = parents, } if subgenders then for _, subgender in ipairs(subgenders) do local gender_infl = full_infl:gsub("GENDER", subgender) data.labels[make_spec_bare(gender_infl) .. " " .. plpos] = { description = "{{{langname}}} " .. mark_up_spec(gender_infl) .. " " .. plpos .. ".", displaytitle = "{{{langname}}} " .. mark_up_spec(gender_infl, "nolink") .. " " .. plpos, additional = create_addl(subgender, subgender .. "_"), breadcrumb = subgender, parents = {{ name = make_spec_bare(infl) .. " " .. plpos, sort = subgender, }}, } end end end end local recognized_label_fields = list_to_set { "additional", "breadcrumb", "breadcrumb_base", "breadcrumb_key", "breadcrumb_and_first_sort_base", "breadcrumb_and_first_sort_key", "umbrella", "umbrella_parents", } --[==[ Add category labels to `labels` from the specs in `specs`. The intent is to allow easy specification of iteration over part-of-speech and similar variables to construct multiple similar labels. `specs` is a list of labels specs, each of which is a table with three positional fields and additional named fields. The positional fields are as follows: * `[1]` = the label itself; * `[2]` = the description, without any preceding `{{{langname}}}` or following period; * `[3]` = the value of `parents`. If the language name (i.e. `{{{langname}}}`) appears other than at the beginning of the description, include it in the description and it will not be prepended. Note that in such a case, `{{{langname}}}` should be in an appositive construction, e.g. `{{{langname}}} words`, because when constructing the umbrella description, a non-initial occurrence of `{{{langname}}}` will be replaced with `specific-language`. In addition, the table can contain named fields. There are three types of named fields: # Fields referring to other properties of the label. These are such as `additional`, `breadcrumb`, `breadcrumb_base`, `breadcrumb_key`, `umbrella`, etc. These will be stored directly the label, but will be processed for variable references (see below). # ''Iteration variables''. Any string anywhere in a positional or named field can contain ''variable references'', e.g. `{pos}`, which refer to variables that will be iterated over. The values to be iterated over are specified by ''variable-list'' fields, e.g. `pos = {"nouns", "verbs", "adjectives"}`. If there are multiple iteration variables, each will be iterated over, meaning that e.g. if there are three variables with respectively K, M and N values, there will be K*M*N labels. Each value of an iteration variable list is either a string (the actual value) or a table where the `[1]` (the first positional field) is the value and named fields specify values of ''ancillary'' variables, which are not iterated over but which are appropriately substituted when the variable being iterated over takes the specified value. For example, the field `sufpos = {{"prefixes", begin_end = "beginnings"}, {"suffixes", begin_end = "endings"}}` specifies that the iteration variable `sufpos` will be iterated over with the values `prefixes` and `suffixes`, and when this happens, the ancillary variable `begin_end` will have the value `beginnings` when `sufpos` has the value `prefixes`, and will have the value `endings` when `sufpos` has the value `suffixes`. Ancillary variables can be referred to in the same fashion as iteration variables, e.g. `{begin_end}` and `{sufpos}`. # Ancillary default values. Fields beginning with `default_` supply the default value for ancillary variables whose value is not explicitly given for a specific value of an iteration variable. For example, if the iteration variable `pos` is specified using `pos = {"nouns", "proper nouns", {"suffixes", posdesc = "suffixes that form nouns"}}`, the ancillary variable `posdesc` will have the value `suffixes that form nouns` when `pos` has the value `suffixes`, but is otherwise unspecified. The value for the other iteration values is specified through a default, such as `default_posdesc = "{pos}"`, which says that the value should be `"{pos}"` (i.e. the same as the iteration value) for other iteration values. Defaults can also be specified at top level using the `defaults` field. If an ancillary variable is left unspecified, and there is no default value either in the label spec or at top level, an error will be thrown if/when a reference to the specified ancillary variable occurs. ]==] function export.add_labels_from_specs(labels, specs) for _, spec in ipairs(specs.specs) do if debug_add_labels_from_specs then mw.log(("Processing spec: %s"):format(dump(spec))) end local label_spec = spec[1] local description_spec = spec[2] if not description_spec:find("{{{langname}}}") then description_spec = "{{{langname}}} " .. description_spec end description_spec = description_spec .. "." local parents_spec = spec[3] local additional_label_properties = {} local ancillary_defaults = {} local iteration_vars = {} for k, v in pairs(spec) do if type(k) == "number" then if k >= 1 and k <= 3 then -- OK else error(("Internal error: Unrecognized positional field %s=%s in spec %s"):format(k, dump(v), dump(spec))) end elseif recognized_label_fields[k] then additional_label_properties[k] = v elseif k:find("^default_") then local ancvar = k:gsub("^default_", "") ancillary_defaults[ancvar] = v else if not v[1] then error(("Internal error: Iteration variable %s=%s is not in list form in spec %s"):format(k, dump(v), dump(spec))) end insert(iteration_vars, {k, v}) end end local function expand_variables_in_string(str, iteration_values) if not str:find("{") then return str end str = str:gsub("{{{", "\1"):gsub("}}}", "\2"):gsub("{{", "\3"):gsub("}}", "\4") if str:find("{") then str = str:gsub("{([^{}]*)}", function(var) if iteration_values[var] then return expand_variables_in_string(iteration_values[var], iteration_values) else error(("Internal error: Unable to expand variable {%s} in %s in spec %s" ):format(var, dump(str), dump(spec))) end end) end str = str:gsub("\1", "{{{"):gsub("\2", "}}}"):gsub("\3", "{{"):gsub("\4", "}}") return str end local function expand_variables(val, iteration_values) if type(val) == "string" then return expand_variables_in_string(val, iteration_values) elseif type(val) ~= "table" then return val else local newval = {} for k, v in pairs(val) do newval[k] = expand_variables(v, iteration_values) end return newval end end local function construct_iteration_values(explicit_values) local iteration_values = {} local ancillary_values = {} for k, v in pairs(explicit_values) do if type(v) == "string" then iteration_values[k] = v else iteration_values[k] = v[1] for kk, vv in pairs(v) do if type(kk) == "number" then if kk == 1 then -- OK else error(("Internal error: Unrecognized positional field %s=%s in iteration value %s=%s in spec %s" ):format(kk, dump(vv), k, dump(v), dump(spec))) end elseif ancillary_values[kk] then error(("Trying to set ancillary variable %s=%s in iteration value %s=%s and encountered already-set variable; presumably set in different iteration variables; spec %s" ):format(kk, dump(vv), k, dump(v), dump(spec))) elseif type(vv) ~= "string" then error(("Internal error: Ancillary value %s=%s not a string in iteration value %s=%s; spec %s" ):format(kk, dump(vv), k, dump(v), dump(spec))) else ancillary_values[kk] = vv end end end end local merged_ancillary_values = {} -- First merge the overall defaults. if specs.defaults then for k, v in pairs(specs.defaults) do if type(v) ~= "string" then error(("Internal error: Top-level ancillary default %s=%s not a string"):format(k, dump(v))) end merged_ancillary_values[k] = v end end -- Now merge the per-spec defaults. for k, v in pairs(ancillary_defaults) do if type(v) ~= "string" then error(("Internal error: Ancillary default %s=%s not a string; spec %s"):format(k, dump(v), dump(spec))) end merged_ancillary_values[k] = v end -- Now merge the per-iteration-value values; we already checked above that they are strings. for k, v in pairs(ancillary_values) do merged_ancillary_values[k] = v end -- Now merge the ancillary values into the iteration values. for k, v in pairs(merged_ancillary_values) do if iteration_values[k] then error(("Trying to set ancillary variable %s=%s in iteration values structure and encountered already-set variable with value %s; naming clash between iteration and ancillary variables; spec %s" ):format(k, dump(v), dump(iteration_values[k]), dump(spec))) end iteration_values[k] = v end return iteration_values end local function add_label(explicit_values) local iteration_values = construct_iteration_values(explicit_values) local label_obj = { description = expand_variables(description_spec, iteration_values), parents = expand_variables(parents_spec, iteration_values), } for k, v in pairs(additional_label_properties) do label_obj[k] = expand_variables(v, iteration_values) end local label = expand_variables(label_spec, iteration_values) if debug_add_labels_from_specs then mw.log(("Adding label %s = %s"):format(dump(label), dump(label_obj))) end labels[label] = label_obj end local iteration_indices = {} local iteration_lengths = {} local num_vars = #iteration_vars if num_vars == 0 then add_label({}) else for i = 1, num_vars do insert(iteration_indices, 1) insert(iteration_lengths, #iteration_vars[i][2]) end -- Loop over the Cartesian product of all iteration variables. In each iteration through the loop, we -- process one set of indices. while true do local explicit_values = {} for i, iteration_var in ipairs(iteration_vars) do local var, values = unpack(iteration_var) explicit_values[var] = values[iteration_indices[i]] end add_label(explicit_values) -- Now increment the iteration indices using the odometer algorithm. local next_var_index = 1 while true do iteration_indices[next_var_index] = iteration_indices[next_var_index] + 1 if iteration_indices[next_var_index] > iteration_lengths[next_var_index] then iteration_indices[next_var_index] = 1 next_var_index = next_var_index + 1 if next_var_index > num_vars then break end else break end end if next_var_index > num_vars then break end end end end end --[==[ Set `breadcrumb_base` on the labels in `label` by chopping off the parent (or the parent's parent, etc.) from the beginning or end of the label, if possible. This will not override existing breadcrumbs (using any of the breadcrumb or breadcrumb-related settings). `addl_terms_to_remove_for_breadcrumb_base` is a list of additional terms that will be chopped off of either end of the label to form the `breadcrumb_base`. (For example, [[Module:category tree/affixes and compounds]] specifies { {"compounds"}} because the parent is {"compound terms"} but many children end in {"compounds"}, and [[Module:category tree/entry maintenance]] specifies { {"entries", "terms"}}, which occurs at the beginning of many entry-maintenance categories.) `addl_terms_to_remove_for_sort` is a list of additional terms to remove from the beginning of the computed `breadcrumb_base` to form the value of `sort` in the first parent. If such a term is removed, `sort` will be set in the first parent if not already set, which will override the sort base coming from `breadcrumb_base`. (For example, [[Module:category tree/entry maintenance]] specifies { {"with"}}. The effect of this combined with the above setting is that a label like {"entries with incorrect language header"} with first parent {"entry maintenance"} will have a breadcrumb {"with incorrect language header"} and a sort key {"incorrect language header"}. ]==] function export.add_partial_breadcrumbs(labels_cats, addl_terms_to_remove_for_breadcrumb_base, addl_terms_to_remove_for_sort) for label, data in pairs(labels_cats) do if data.breadcrumb == nil and data.breadcrumb_key == nil and data.breadcrumb_base == nil and data.breadcrumb_and_first_sort_key == nil and data.breadcrumb_and_first_sort_base == nil then local pardata = data local function make_anycase_term_to_remove(term) local first, rest = umatch(term, "^(.)(.*)$") return ("[%s%s%s]%s"):format(first, uupper(first), ulower(first), pattern_escape(rest)) end -- Check a term against the beginning and end of the label and if found, set the breadcrumb base -- accordingly. Return true if the breadcrumb_base was set, otherwise false. If additional terms to check -- for sortkey removal are given, we check those terms at the beginning of the chopped breadcrumb_base or -- the label (regardless of whether we were able to remove any terms from the breadcrumb), and if we were -- able to remove any terms, attempt to set the sortkey. local function check_breadcrumb_base_term(term_to_remove) local breadcrumb_base local term_to_remove_pattern = make_anycase_term_to_remove(term_to_remove) -- Check the end of the label for the term to remove. breadcrumb_base = umatch(label, ("^(.-) %s$"):format(term_to_remove_pattern)) if not breadcrumb_base then -- If not found, check the beginning of the label for the term to remove. breadcrumb_base = umatch(label, ("^%s (.-)$"):format(term_to_remove_pattern)) end local breadcrumb_base_set = not not breadcrumb_base breadcrumb_base = breadcrumb_base or label -- If additional terms to remove to form the sortkey, do it now. if addl_terms_to_remove_for_sort then for _, addl_term in ipairs(addl_terms_to_remove_for_sort) do local sort = umatch(breadcrumb_base, ("^(.-) %s$"):format(make_anycase_term_to_remove(addl_term))) if sort then -- Attempt to set the `sort` on the first parent, but don't override an existing value. local parents = data.parents if type(parents) == "string" or type(parents) == "table" and not parents[1] then parents = {parents} end if parents and parents[1] then local parent = parents[1] if type(parent) == "string" then parent = {name = parent} end if type(parent) == "table" and not parent.sort then parent.sort = sort parents[1] = parent data.parents = parents end end break end end end if breadcrumb_base_set then data.breadcrumb_base = breadcrumb_base return true end return false end while true do -- Loop over first parents and first parents of first parents until there are no more. local parents = pardata.parents if type(parents) == "string" or type(parents) == "table" and not parents[1] then parents = {parents} end if not parents or not parents[1] then break end local parent = parents[1] if type(parent) == "table" then parent = parent.name end if type(parent) == "string" then if check_breadcrumb_base_term(parent) then break end pardata = labels_cats[parent] if not pardata then break end else break end end -- Also check additional specified terms to remove from the label to form the breadcrumb. if addl_terms_to_remove_for_breadcrumb_base then for _, addl_term in ipairs(addl_terms_to_remove_for_breadcrumb_base) do if check_breadcrumb_base_term(addl_term) then break end end end end end end -- FIXME: Older entry point. export.add_partial_breadcrumbs_to_labels = export.add_partial_breadcrumbs --[==[ Finalize the labels in `labels` according to the specs in `data`. This does two things: # Set `breadcrumb_base` on the labels in `label` by chopping off the parent (or the parent's parent, etc.) from the beginning or end of the label, if possible. This will not override existing breadcrumbs (using any of the breadcrumb or breadcrumb-related settings). `data.addl_terms_to_remove_for_breadcrumb_base` is a list of additional terms that will be chopped off of either end of the label to form the `breadcrumb_base`. (For example, [[Module:category tree/affixes and compounds]] specifies { {"compounds"}} because the parent is {"compound terms"} but many children end in {"compounds"}, and [[Module:category tree/entry maintenance]] specifies { {"entries", "terms"}}, which occurs at the beginning of many entry-maintenance categories.) `data.addl_terms_to_remove_for_sort` is a list of additional terms to remove from the beginning of the computed `breadcrumb_base` to form the value of `sort` in the first parent. If such a term is removed, `sort` will be set in the first parent if not already set, which will override the sort base coming from `breadcrumb_base`. (For example, [[Module:category tree/entry maintenance]] specifies { {"with"}}. The effect of this combined with the above setting is that a label like {"entries with incorrect language header"} with first parent {"entry maintenance"} will have a breadcrumb {"with incorrect language header"} and a sort key {"incorrect language header"}. # Add an `umbrella_parents` key if not already present and `data.default_umbrella_parents` is specified. ]==] function export.finalize_labels(labels, data) data = data or {} export.add_partial_breadcrumbs(labels, data.addl_terms_to_remove_for_breadcrumb_base, data.addl_terms_to_remove_for_sort) if data.default_umbrella_parents then -- Add 'umbrella_parents' key if not already present. for label, labdat in pairs(labels) do if not labdat.umbrella_parents then labdat.umbrella_parents = data.default_umbrella_parents end end end end function export.finalize_raw_categories(raw_categories, data) data = data or {} export.add_partial_breadcrumbs(raw_categories, data.addl_terms_to_remove_for_breadcrumb_base, data.addl_terms_to_remove_for_sort) end return export d234ry6bei5t65m2qwyp6geh1342cfd 239384 239383 2026-11-22T09:24:15Z Lee 19 [[:en:Module:category_tree/utilities]] වෙතින් එක් සංශෝධනයක් 239383 Scribunto text/plain local export = {} local en_utilities_module = "Module:en-utilities" local m_string_utilities = require("Module:string utilities") local m_table = require("Module:table") local umatch = m_string_utilities.match local uupper = m_string_utilities.upper local ulower = m_string_utilities.lower local pattern_escape = m_string_utilities.pattern_escape local list_to_set = m_table.listToSet local dump = mw.dumpObject local insert = table.insert local unpack = unpack or table.unpack -- Lua 5.2 compatibility -- If true, output debugging information indicating which specs are being processed and which labels and label objects -- generated. local debug_add_labels_from_specs = false --[==[ Generate labels for inflection classes. `data` is a table with the following fields: * `labels`: The table into which the labels are written. * `pos`: The singular part of speech, e.g. "noun". * `stem_classes`: Table of possible stem classes and associated properties. See below. * `principal_parts`: List of the principal part fields and descriptions. Each list element is a two-element list consisting of {"FIELD", "DESCRIPTION"} where FIELD is the field in the element in `stem_classes` (e.g. "nom_sg", "gen_sg", "pl", "sup") containing the detailed description of what this principal part looks like, and DESCRIPTION is the corresponding English description of the principal part (e.g. "nominative singular"). * `mark_up_spec`: Optional function to add markup to a spec. Takes two arguments, the spec and a flag `nolink`; if the flag is true, links should not be present in the resulting markup. The default just converts literal text enclosed in <...> into italics. * `make_spec_bare`: Optional function to make a spec (stem class or sortkey) free of markup. The default just converts literal text enclosed in <...> into bare text. * `addl`: Optional additional text to be displayed in the footer of each category page. `stem_classes` is a table describing the various stem classes and how to format the category description of each. It is a table with keys specifying the stem classes and values consisting of an object containing properties of the stem class. If the stem class contains the word 'GENDER' in it, it expands into labels both for a parent category that subsumes several genders (obtained by removing the word 'GENDER' and following whitespace) as well as gender-specific children categories (obtained by replacing the word 'GENDER' with the genders specified in the `possible_genders` field). The stem class can contain literal text (e.g. suffixes), which will be marked up appropriately (e.g. italicized) in breadcrumbs and titles. The fields of the property object for a given stem class are as follows: * `gender`: The description of the gender(s) of the stem class. If preceded by ~, the description is preceded by "most commonly". This appears in the `additional` field of the label properties. It is not used in gender-specific children categories; instead the gender of that category is used. * `possible_genders`: The possible genders this class occurs in. If this is specified, the word 'GENDER' must occur in the stem class, and gender-specific variants of the stem class (with GENDER replaced by the possible genders) are handled along with a parent category subsuming all genders. * `PRINCIPAL_PART`: The ending for the specified principal part. Use <...> to enclose literal Latin-script text (e.g. suffixes), which will be italicized. There will be one field for each principal part listed in the `principal_parts` table described above. * `GENDER_PRINCIPAL_PART`: The ending for the GENDER variant of the specified principal part. If not specified, the value of `PRINCIPAL_PART` is used. * `breadcrumb`: The breadcrumb for the category, appearing in the trail of breadcrumbs at the top of the page. If this stem has gender-specific variants, the breadcrumb specified here is used only for the parent category, while the gender-specific child categories use the gender as the breadcrumb. If not specified, it defaults to `sortkey`. If that is also not specified, or if the breadcrumb has the value "+", the stem class (without the word 'GENDER') is used. (Use "+" when a sortkey is specified but the stem class should be used as the breadcrumb.) * `parent`: The parent category or categories. If specified, the actual category label is formed by appending the part of speech (e.g. "nouns"). Defaults to "POS by inflection type" where POS is the part of speech. Note that gender-specific child categories do not use this, but always have the gender-subsuming parent stem class category as their parent. * `sortkey`: The sort key used for sorting this category among its parent's children. Defaults to the stem class (without the word 'GENDER'). Note that gender-specific child categories do nto use this, but always use the gender as the sort key. * `addl`: Optional additional text to be displayed in the footer of the category page. * `GENDER_addl`: Optional additional text to be displayed in the footer of a gender-specific category page, defaulting to `addl`. Use the value `false` to cancel out a non-gender-specific value. ]==] function export.add_inflection_labels(data) for _, reqfield_spec in ipairs { {"labels", "table of labels"}, {"pos", "singular part of speech"}, {"stem_classes", "table of possible stem classes and associated properties"}, {"principal_parts", "list of principal part fields and names"}, } do local reqfield, gloss = unpack(reqfield_spec) if not data[reqfield] then error(("Internal error: Missing field '%s', which should containing the %s"):format(reqfield, gloss)) end end local function default_mark_up_spec(spec, _nolink) return (spec:gsub("<(.-)>", "''%1''")) end local function default_make_spec_bare(spec) return (spec:gsub("<(.-)>", "%1")) end local function mark_up_spec(spec, nolink) return (data.mark_up_spec or default_mark_up_spec)(spec, nolink) end local function make_spec_bare(spec) return (data.make_spec_bare or default_make_spec_bare)(spec) end local plpos = require(en_utilities_module).pluralize(data.pos) for full_infl, spec in pairs(data.stem_classes) do local subgenders = spec.possible_genders -- Get the stem type. local infl if subgenders then if not full_infl:find("GENDER") then error(("Internal error: Declension spec '%s' needs to have the word 'GENDER' in it, in all caps"):format(full_infl)) end infl = full_infl:gsub("GENDER ", "") else infl = full_infl end -- Get the breadcrumb. local breadcrumb = spec.breadcrumb or spec.sortkey or "+" if breadcrumb == "+" then breadcrumb = infl end -- Generate the parents. local parents = {} local spec_parents = spec.parent if type(spec_parents) == "string" then spec_parents = {spec_parents} end local parent_sort = make_spec_bare(spec.sortkey or infl) if spec_parents then for _, parent in ipairs(spec_parents) do table.insert(parents, {name = make_spec_bare(parent) .. " " .. plpos, sort = parent_sort}) end else table.insert(parents, {name = plpos .. " by inflection type", sort = parent_sort}) end -- Generate the additional text, including principal part descriptions and footer. local function create_addl(gender_spec, subgender_prefix) local addl_parts = {} local function ins(txt) table.insert(addl_parts, txt) end local function insert_header(gender_spec) if gender_spec then local most_commonly, gender = gender_spec:match("^(~)(.*)$") most_commonly = most_commonly and "most commonly " or "" gender = gender or gender_spec ins(("These %s are %s%s, typically with the following endings:\n"):format(plpos, most_commonly, mark_up_spec(gender))) else ins(("These %s typically have the following endings:\n"):format(plpos)) end end local function process_ending(field, desc, is_last) local ending_spec = spec[subgender_prefix .. field] or spec[field] if not ending_spec then error(("Internal error: for inflection '%s', field '%s' for principal part '%s' is missing"):format( full_infl, field, desc)) end return ("* in the %s: %s%s"):format(desc, mark_up_spec(ending_spec), is_last and "." or ";\n") end local function insert_principal_part_info() for i, ppart_spec in ipairs(data.principal_parts) do local ppart_field, ppart_desc = unpack(ppart_spec) ins(process_ending(ppart_field, ppart_desc, i == #data.principal_parts)) end end insert_header(gender_spec) insert_principal_part_info() local spec_addl = spec[subgender_prefix .. "addl"] if spec_addl == nil then spec_addl = spec.addl end if data.addl or spec_addl then local footer_parts = {} if data.addl then table.insert(footer_parts, mark_up_spec(data.addl)) end if spec_addl then table.insert(footer_parts, mark_up_spec(spec_addl)) end ins("\n" .. table.concat(footer_parts, " ")) end return table.concat(addl_parts) end data.labels[make_spec_bare(infl) .. " " .. plpos] = { description = "{{{langname}}} " .. mark_up_spec(infl) .. " " .. plpos .. ".", displaytitle = "{{{langname}}} " .. mark_up_spec(infl, "nolink") .. " " .. plpos, additional = create_addl(spec.gender, ""), breadcrumb = mark_up_spec(breadcrumb, "nolink"), parents = parents, } if subgenders then for _, subgender in ipairs(subgenders) do local gender_infl = full_infl:gsub("GENDER", subgender) data.labels[make_spec_bare(gender_infl) .. " " .. plpos] = { description = "{{{langname}}} " .. mark_up_spec(gender_infl) .. " " .. plpos .. ".", displaytitle = "{{{langname}}} " .. mark_up_spec(gender_infl, "nolink") .. " " .. plpos, additional = create_addl(subgender, subgender .. "_"), breadcrumb = subgender, parents = {{ name = make_spec_bare(infl) .. " " .. plpos, sort = subgender, }}, } end end end end local recognized_label_fields = list_to_set { "additional", "breadcrumb", "breadcrumb_base", "breadcrumb_key", "breadcrumb_and_first_sort_base", "breadcrumb_and_first_sort_key", "umbrella", "umbrella_parents", } --[==[ Add category labels to `labels` from the specs in `specs`. The intent is to allow easy specification of iteration over part-of-speech and similar variables to construct multiple similar labels. `specs` is a list of labels specs, each of which is a table with three positional fields and additional named fields. The positional fields are as follows: * `[1]` = the label itself; * `[2]` = the description, without any preceding `{{{langname}}}` or following period; * `[3]` = the value of `parents`. If the language name (i.e. `{{{langname}}}`) appears other than at the beginning of the description, include it in the description and it will not be prepended. Note that in such a case, `{{{langname}}}` should be in an appositive construction, e.g. `{{{langname}}} words`, because when constructing the umbrella description, a non-initial occurrence of `{{{langname}}}` will be replaced with `specific-language`. In addition, the table can contain named fields. There are three types of named fields: # Fields referring to other properties of the label. These are such as `additional`, `breadcrumb`, `breadcrumb_base`, `breadcrumb_key`, `umbrella`, etc. These will be stored directly the label, but will be processed for variable references (see below). # ''Iteration variables''. Any string anywhere in a positional or named field can contain ''variable references'', e.g. `{pos}`, which refer to variables that will be iterated over. The values to be iterated over are specified by ''variable-list'' fields, e.g. `pos = {"nouns", "verbs", "adjectives"}`. If there are multiple iteration variables, each will be iterated over, meaning that e.g. if there are three variables with respectively K, M and N values, there will be K*M*N labels. Each value of an iteration variable list is either a string (the actual value) or a table where the `[1]` (the first positional field) is the value and named fields specify values of ''ancillary'' variables, which are not iterated over but which are appropriately substituted when the variable being iterated over takes the specified value. For example, the field `sufpos = {{"prefixes", begin_end = "beginnings"}, {"suffixes", begin_end = "endings"}}` specifies that the iteration variable `sufpos` will be iterated over with the values `prefixes` and `suffixes`, and when this happens, the ancillary variable `begin_end` will have the value `beginnings` when `sufpos` has the value `prefixes`, and will have the value `endings` when `sufpos` has the value `suffixes`. Ancillary variables can be referred to in the same fashion as iteration variables, e.g. `{begin_end}` and `{sufpos}`. # Ancillary default values. Fields beginning with `default_` supply the default value for ancillary variables whose value is not explicitly given for a specific value of an iteration variable. For example, if the iteration variable `pos` is specified using `pos = {"nouns", "proper nouns", {"suffixes", posdesc = "suffixes that form nouns"}}`, the ancillary variable `posdesc` will have the value `suffixes that form nouns` when `pos` has the value `suffixes`, but is otherwise unspecified. The value for the other iteration values is specified through a default, such as `default_posdesc = "{pos}"`, which says that the value should be `"{pos}"` (i.e. the same as the iteration value) for other iteration values. Defaults can also be specified at top level using the `defaults` field. If an ancillary variable is left unspecified, and there is no default value either in the label spec or at top level, an error will be thrown if/when a reference to the specified ancillary variable occurs. ]==] function export.add_labels_from_specs(labels, specs) for _, spec in ipairs(specs.specs) do if debug_add_labels_from_specs then mw.log(("Processing spec: %s"):format(dump(spec))) end local label_spec = spec[1] local description_spec = spec[2] if not description_spec:find("{{{langname}}}") then description_spec = "{{{langname}}} " .. description_spec end description_spec = description_spec .. "." local parents_spec = spec[3] local additional_label_properties = {} local ancillary_defaults = {} local iteration_vars = {} for k, v in pairs(spec) do if type(k) == "number" then if k >= 1 and k <= 3 then -- OK else error(("Internal error: Unrecognized positional field %s=%s in spec %s"):format(k, dump(v), dump(spec))) end elseif recognized_label_fields[k] then additional_label_properties[k] = v elseif k:find("^default_") then local ancvar = k:gsub("^default_", "") ancillary_defaults[ancvar] = v else if not v[1] then error(("Internal error: Iteration variable %s=%s is not in list form in spec %s"):format(k, dump(v), dump(spec))) end insert(iteration_vars, {k, v}) end end local function expand_variables_in_string(str, iteration_values) if not str:find("{") then return str end str = str:gsub("{{{", "\1"):gsub("}}}", "\2"):gsub("{{", "\3"):gsub("}}", "\4") if str:find("{") then str = str:gsub("{([^{}]*)}", function(var) if iteration_values[var] then return expand_variables_in_string(iteration_values[var], iteration_values) else error(("Internal error: Unable to expand variable {%s} in %s in spec %s" ):format(var, dump(str), dump(spec))) end end) end str = str:gsub("\1", "{{{"):gsub("\2", "}}}"):gsub("\3", "{{"):gsub("\4", "}}") return str end local function expand_variables(val, iteration_values) if type(val) == "string" then return expand_variables_in_string(val, iteration_values) elseif type(val) ~= "table" then return val else local newval = {} for k, v in pairs(val) do newval[k] = expand_variables(v, iteration_values) end return newval end end local function construct_iteration_values(explicit_values) local iteration_values = {} local ancillary_values = {} for k, v in pairs(explicit_values) do if type(v) == "string" then iteration_values[k] = v else iteration_values[k] = v[1] for kk, vv in pairs(v) do if type(kk) == "number" then if kk == 1 then -- OK else error(("Internal error: Unrecognized positional field %s=%s in iteration value %s=%s in spec %s" ):format(kk, dump(vv), k, dump(v), dump(spec))) end elseif ancillary_values[kk] then error(("Trying to set ancillary variable %s=%s in iteration value %s=%s and encountered already-set variable; presumably set in different iteration variables; spec %s" ):format(kk, dump(vv), k, dump(v), dump(spec))) elseif type(vv) ~= "string" then error(("Internal error: Ancillary value %s=%s not a string in iteration value %s=%s; spec %s" ):format(kk, dump(vv), k, dump(v), dump(spec))) else ancillary_values[kk] = vv end end end end local merged_ancillary_values = {} -- First merge the overall defaults. if specs.defaults then for k, v in pairs(specs.defaults) do if type(v) ~= "string" then error(("Internal error: Top-level ancillary default %s=%s not a string"):format(k, dump(v))) end merged_ancillary_values[k] = v end end -- Now merge the per-spec defaults. for k, v in pairs(ancillary_defaults) do if type(v) ~= "string" then error(("Internal error: Ancillary default %s=%s not a string; spec %s"):format(k, dump(v), dump(spec))) end merged_ancillary_values[k] = v end -- Now merge the per-iteration-value values; we already checked above that they are strings. for k, v in pairs(ancillary_values) do merged_ancillary_values[k] = v end -- Now merge the ancillary values into the iteration values. for k, v in pairs(merged_ancillary_values) do if iteration_values[k] then error(("Trying to set ancillary variable %s=%s in iteration values structure and encountered already-set variable with value %s; naming clash between iteration and ancillary variables; spec %s" ):format(k, dump(v), dump(iteration_values[k]), dump(spec))) end iteration_values[k] = v end return iteration_values end local function add_label(explicit_values) local iteration_values = construct_iteration_values(explicit_values) local label_obj = { description = expand_variables(description_spec, iteration_values), parents = expand_variables(parents_spec, iteration_values), } for k, v in pairs(additional_label_properties) do label_obj[k] = expand_variables(v, iteration_values) end local label = expand_variables(label_spec, iteration_values) if debug_add_labels_from_specs then mw.log(("Adding label %s = %s"):format(dump(label), dump(label_obj))) end labels[label] = label_obj end local iteration_indices = {} local iteration_lengths = {} local num_vars = #iteration_vars if num_vars == 0 then add_label({}) else for i = 1, num_vars do insert(iteration_indices, 1) insert(iteration_lengths, #iteration_vars[i][2]) end -- Loop over the Cartesian product of all iteration variables. In each iteration through the loop, we -- process one set of indices. while true do local explicit_values = {} for i, iteration_var in ipairs(iteration_vars) do local var, values = unpack(iteration_var) explicit_values[var] = values[iteration_indices[i]] end add_label(explicit_values) -- Now increment the iteration indices using the odometer algorithm. local next_var_index = 1 while true do iteration_indices[next_var_index] = iteration_indices[next_var_index] + 1 if iteration_indices[next_var_index] > iteration_lengths[next_var_index] then iteration_indices[next_var_index] = 1 next_var_index = next_var_index + 1 if next_var_index > num_vars then break end else break end end if next_var_index > num_vars then break end end end end end --[==[ Set `breadcrumb_base` on the labels in `label` by chopping off the parent (or the parent's parent, etc.) from the beginning or end of the label, if possible. This will not override existing breadcrumbs (using any of the breadcrumb or breadcrumb-related settings). `addl_terms_to_remove_for_breadcrumb_base` is a list of additional terms that will be chopped off of either end of the label to form the `breadcrumb_base`. (For example, [[Module:category tree/affixes and compounds]] specifies { {"compounds"}} because the parent is {"compound terms"} but many children end in {"compounds"}, and [[Module:category tree/entry maintenance]] specifies { {"entries", "terms"}}, which occurs at the beginning of many entry-maintenance categories.) `addl_terms_to_remove_for_sort` is a list of additional terms to remove from the beginning of the computed `breadcrumb_base` to form the value of `sort` in the first parent. If such a term is removed, `sort` will be set in the first parent if not already set, which will override the sort base coming from `breadcrumb_base`. (For example, [[Module:category tree/entry maintenance]] specifies { {"with"}}. The effect of this combined with the above setting is that a label like {"entries with incorrect language header"} with first parent {"entry maintenance"} will have a breadcrumb {"with incorrect language header"} and a sort key {"incorrect language header"}. ]==] function export.add_partial_breadcrumbs(labels_cats, addl_terms_to_remove_for_breadcrumb_base, addl_terms_to_remove_for_sort) for label, data in pairs(labels_cats) do if data.breadcrumb == nil and data.breadcrumb_key == nil and data.breadcrumb_base == nil and data.breadcrumb_and_first_sort_key == nil and data.breadcrumb_and_first_sort_base == nil then local pardata = data local function make_anycase_term_to_remove(term) local first, rest = umatch(term, "^(.)(.*)$") return ("[%s%s%s]%s"):format(first, uupper(first), ulower(first), pattern_escape(rest)) end -- Check a term against the beginning and end of the label and if found, set the breadcrumb base -- accordingly. Return true if the breadcrumb_base was set, otherwise false. If additional terms to check -- for sortkey removal are given, we check those terms at the beginning of the chopped breadcrumb_base or -- the label (regardless of whether we were able to remove any terms from the breadcrumb), and if we were -- able to remove any terms, attempt to set the sortkey. local function check_breadcrumb_base_term(term_to_remove) local breadcrumb_base local term_to_remove_pattern = make_anycase_term_to_remove(term_to_remove) -- Check the end of the label for the term to remove. breadcrumb_base = umatch(label, ("^(.-) %s$"):format(term_to_remove_pattern)) if not breadcrumb_base then -- If not found, check the beginning of the label for the term to remove. breadcrumb_base = umatch(label, ("^%s (.-)$"):format(term_to_remove_pattern)) end local breadcrumb_base_set = not not breadcrumb_base breadcrumb_base = breadcrumb_base or label -- If additional terms to remove to form the sortkey, do it now. if addl_terms_to_remove_for_sort then for _, addl_term in ipairs(addl_terms_to_remove_for_sort) do local sort = umatch(breadcrumb_base, ("^(.-) %s$"):format(make_anycase_term_to_remove(addl_term))) if sort then -- Attempt to set the `sort` on the first parent, but don't override an existing value. local parents = data.parents if type(parents) == "string" or type(parents) == "table" and not parents[1] then parents = {parents} end if parents and parents[1] then local parent = parents[1] if type(parent) == "string" then parent = {name = parent} end if type(parent) == "table" and not parent.sort then parent.sort = sort parents[1] = parent data.parents = parents end end break end end end if breadcrumb_base_set then data.breadcrumb_base = breadcrumb_base return true end return false end while true do -- Loop over first parents and first parents of first parents until there are no more. local parents = pardata.parents if type(parents) == "string" or type(parents) == "table" and not parents[1] then parents = {parents} end if not parents or not parents[1] then break end local parent = parents[1] if type(parent) == "table" then parent = parent.name end if type(parent) == "string" then if check_breadcrumb_base_term(parent) then break end pardata = labels_cats[parent] if not pardata then break end else break end end -- Also check additional specified terms to remove from the label to form the breadcrumb. if addl_terms_to_remove_for_breadcrumb_base then for _, addl_term in ipairs(addl_terms_to_remove_for_breadcrumb_base) do if check_breadcrumb_base_term(addl_term) then break end end end end end end -- FIXME: Older entry point. export.add_partial_breadcrumbs_to_labels = export.add_partial_breadcrumbs --[==[ Finalize the labels in `labels` according to the specs in `data`. This does two things: # Set `breadcrumb_base` on the labels in `label` by chopping off the parent (or the parent's parent, etc.) from the beginning or end of the label, if possible. This will not override existing breadcrumbs (using any of the breadcrumb or breadcrumb-related settings). `data.addl_terms_to_remove_for_breadcrumb_base` is a list of additional terms that will be chopped off of either end of the label to form the `breadcrumb_base`. (For example, [[Module:category tree/affixes and compounds]] specifies { {"compounds"}} because the parent is {"compound terms"} but many children end in {"compounds"}, and [[Module:category tree/entry maintenance]] specifies { {"entries", "terms"}}, which occurs at the beginning of many entry-maintenance categories.) `data.addl_terms_to_remove_for_sort` is a list of additional terms to remove from the beginning of the computed `breadcrumb_base` to form the value of `sort` in the first parent. If such a term is removed, `sort` will be set in the first parent if not already set, which will override the sort base coming from `breadcrumb_base`. (For example, [[Module:category tree/entry maintenance]] specifies { {"with"}}. The effect of this combined with the above setting is that a label like {"entries with incorrect language header"} with first parent {"entry maintenance"} will have a breadcrumb {"with incorrect language header"} and a sort key {"incorrect language header"}. # Add an `umbrella_parents` key if not already present and `data.default_umbrella_parents` is specified. ]==] function export.finalize_labels(labels, data) data = data or {} export.add_partial_breadcrumbs(labels, data.addl_terms_to_remove_for_breadcrumb_base, data.addl_terms_to_remove_for_sort) if data.default_umbrella_parents then -- Add 'umbrella_parents' key if not already present. for label, labdat in pairs(labels) do if not labdat.umbrella_parents then labdat.umbrella_parents = data.default_umbrella_parents end end end end function export.finalize_raw_categories(raw_categories, data) data = data or {} export.add_partial_breadcrumbs(raw_categories, data.addl_terms_to_remove_for_breadcrumb_base, data.addl_terms_to_remove_for_sort) end return export d234ry6bei5t65m2qwyp6geh1342cfd ප්‍රවර්ගය:සිංහල etymology maintenance 14 145929 239381 2026-09-09T04:46:40Z en>FenaBot 0 Created page with "{{auto cat}}" 239381 wikitext text/x-wiki {{auto cat}} eomzlm5v4j7ond1phrju7cnue91g5qx 239382 239381 2026-11-22T09:22:11Z Lee 19 [[:en:Category:Sinhalese_etymology_maintenance]] වෙතින් එක් සංශෝධනයක් 239381 wikitext text/x-wiki {{auto cat}} eomzlm5v4j7ond1phrju7cnue91g5qx 239385 239382 2026-11-22T09:25:38Z Lee 19 Lee විසින් [[ප්‍රවර්ගය:Sinhalese etymology maintenance]] සිට [[ප්‍රවර්ගය:සිංහල etymology maintenance]] වෙත පිටුව ගෙන යන ලදී 239381 wikitext text/x-wiki {{auto cat}} eomzlm5v4j7ond1phrju7cnue91g5qx ප්‍රවර්ගය:Sinhalese etymology maintenance 14 145930 239386 2026-11-22T09:25:38Z Lee 19 Lee විසින් [[ප්‍රවර්ගය:Sinhalese etymology maintenance]] සිට [[ප්‍රවර්ගය:සිංහල etymology maintenance]] වෙත පිටුව ගෙන යන ලදී 239386 wikitext text/x-wiki #යළියොමුව [[:ප්‍රවර්ගය:සිංහල etymology maintenance]] jp7cwwzzfx4ain8jbnoaabsjinckp1k කප්පරවල්ලිය 0 145931 239388 2026-11-22T11:39:44Z Lee 19 '== සිංහල == === නිරුක්තිය === {{rfe|si}} === නාම පදය === {{si-noun}} # {{rfdef|si}} <!-- ==== පරිවර්තන ==== {{trans-top|පරිවර්තන}} * ඉංග්‍රීසි: {{t|en|<<ඉංග්‍රීසි වචනය>>}} {{trans-bottom}} === අමතර අවධානයට === * {{l|si|<<ආශ්‍රිත පවතින වෙනත් ව...' යොදමින් නව පිටුවක් තනන ලදි 239388 wikitext text/x-wiki == සිංහල == === නිරුක්තිය === {{rfe|si}} === නාම පදය === {{si-noun}} # {{rfdef|si}} <!-- ==== පරිවර්තන ==== {{trans-top|පරිවර්තන}} * ඉංග්‍රීසි: {{t|en|<<ඉංග්‍රීසි වචනය>>}} {{trans-bottom}} === අමතර අවධානයට === * {{l|si|<<ආශ්‍රිත පවතින වෙනත් වචන>>}} --> 37g9s13iio6w9i2yw7aw46v28viw7h4 239389 239388 2026-11-22T11:40:24Z Lee 19 239389 wikitext text/x-wiki == සිංහල == {{wp}} === නිරුක්තිය === {{rfe|si}} === නාම පදය === {{si-noun}} # මේ නමින් වන බෙහෙත් පැළාටිය. <!-- ==== පරිවර්තන ==== {{trans-top|පරිවර්තන}} * ඉංග්‍රීසි: {{t|en|<<ඉංග්‍රීසි වචනය>>}} {{trans-bottom}} === අමතර අවධානයට === * {{l|si|<<ආශ්‍රිත පවතින වෙනත් වචන>>}} --> be27k1wb1hyp6nas2m9u5b15ctj0d36