မေႃႇၵျူး:languages: လွင်ႈပႅၵ်ႇပိူင်ႈ ၼႂ်းၵႄႈ လွင်ႈၶူၼ်ႉၶႆႈ

Content deleted Content added
No edit summary
No edit summary
Tag: Reverted
ထႅဝ် 1:
--rev 00:14, 29 กรกฎาคม 2566‎
local export = {}
 
local function track(page, code)
local tracking_page = require("Module:debug/track")("languages/" .. page)
if code then
require("Module:debug/track"){tracking_page, tracking_page .. "/" .. code}
else
require("Module:debug/track")(tracking_page)
end
return true
end
Line 247 ⟶ 241:
end
--[==[Given a list of types as strings, returns true if the language has all of them. Possible types are explained in [[Module:languages/data/2]] and [[Module:etymology languages/data]].]==]
 
The possible types are
* {language}: This is a language, either full or etymology-only.
* {full}: This is a "full" (not etymology-only) language, i.e. the union of {regular}, {reconstructed} and
{appendix-constructed}. Note that the types {full} and {etymology-only} also exist for families, so if you
want to check specifically for a full language and you have an object that might be a family, you should
use {{lua|hasType("language", "full")}} and not simply {{lua|hasType("full")}}.
* {etymology-only}: This is an etymology-only (not full) language, whose parent is another etymology-only
language or a full language. Note that the types {full} and {etymology-only} also exist for
families, so if you want to check specifically for an etymology-only language and you have an
object that might be a family, you should use {{lua|hasType("language", "etymology-only")}}
and not simply {{lua|hasType("etymology-only")}}.
* {regular}: This indicates a full language that is attested according to [[WT:CFI]] and therefore permitted
in the main namespace. There may also be reconstructed terms for the language, which are placed in
the {Reconstruction} namespace and must be prefixed with * to indicate a reconstruction. Most full
languages are natural (not constructed) languages, but a few constructed languages (e.g. Esperanto
and Volapük, among others) are also allowed in the mainspace and considered regular languages.
* {reconstructed}: This language is not attested according to [[WT:CFI]], and therefore is allowed only in the
{Reconstruction} namespace. All terms in this language are reconstructed, and must be prefixed
with *. Languages such as Proto-Indo-European and Proto-Germanic are in this category.
* {appendix-constructed}: This language is attested but does not meet the additional requirements set out for
constructed languages ([[WT:CFI#Constructed languages]]). Its entries must therefore
be in the Appendix namespace, but they are not reconstructed and therefore should
not have * prefixed in links.
]==]
function Language:hasType(...)
if not self._type then
Line 289 ⟶ 308:
end
--[==[
--[==[Returns the name of the Wikipedia article for the language. If the property <code>wikipedia_article</code> is present in the data module it will be used first, otherwise a sitelink will be generated from <code>:getWikidataItem</code> (if set). Otherwise <code>:getCategoryName</code> is used as fallback.]==]
Returns the name of the Wikipedia article for the language. If the property {wikipedia_article} is present in the
function Language:getWikipediaArticle()
data module it will be used first, otherwise a sitelink will be generated from {:getWikidataItem} (if set). Otherwise
if not self._wikipedia_article then
{:getCategoryName} is used as fallback, unless `noCategoryFallback` is specified, in which case {nil} is returned.]==]
function Language:getWikipediaArticle(noCategoryFallback)
if self._wikipedia_article == nil then
if self._rawData.wikipedia_article then
self._wikipedia_article = self._rawData.wikipedia_article
elseif self:getWikidataItem() and mw.wikibase then
self._wikipedia_article = mw.wikibase.sitelink(self:getWikidataItem(), "thwiki") or mw.wikibase.sitelink(self:getWikidataItem(), "'enwiki"')
end
if not self._wikipedia_article then
self._wikipedia_article = self:getCategoryName():gsub("Creole language", "Creole")false
end
end
returnif not self._wikipedia_article and not noCategoryFallback then
return self:getCategoryName():gsub("Creole language", "Creole")
end
return self._wikipedia_article or nil
end
function Language:makeWikipediaLink()
return "[[w:" .. self:getWikipediaArticle() .. "|" .. self:getCategoryNamegetCanonicalName() .. "]]"
end
Line 724 ⟶ 749:
-- Only add " language" if a regular language.
if #self._stack == 1 then
--[[ If the name already has "language" in it, don't add it.
if not name:match("[Ll]anguage$") then
name = name .. " language"
end
--]]
if not name:match("^ၽႃႇသႃႇ") and name ~= "ข้ามภาษา" then
name = "ၽႃႇသႃႇ" .. name
end
end
Line 744 ⟶ 765:
--[==[Creates a link to the category; the link text is the canonical name.]==]
function Language:makeCategoryLink()
return "[[:Category:" .. self:getCategoryName() .. "|" .. self:getCanonicalNamegetDisplayForm() .. "]]"
end
Line 776 ⟶ 797:
-- Set `unsupported` as true if certain conditions are met.
local unsupported
-- Check if there's an unsupported character. \239\191\189 is the replacement character U+FFFD, which can't be typed directly here due to an abuse filter. Unix-style dot-slash notation is also unsupported, as it is used for relative paths in links, as are 3 or more consecutive tildes.
-- If there's an underscore.
if text:find("_") then
tracktext:find("underscore[#<>%[%]_{|}]") or
text:find("\239\191\189") or
text:find("%f[^%z/]%.%.?%f[%z/]") or
text:find("~~~")
) then
unsupported = true
-- If it looks like an interwiki link.
elseif text:find(":") and text ~= ":" then
local m_utildata = conditionalRequire("Module:utilities/data")
local prefix = text:gsub("^:*(.-):.*", string.ulower)
if (
if m_utildata.interwikis[prefix] or m_utildata.namespaces[prefix] then
conditionalRequire("Module:data/namespaces")[prefix] or
conditionalRequire("Module:data/interwikis")[prefix]
) then
unsupported = true
end
Line 792 ⟶ 819:
local unsupportedTitles = conditionalRequire("Module:links/data").unsupported_titles
if unsupportedTitles[text] then
return "ชื่อไม่รองรับUnsupported titles/" .. unsupportedTitles[text], nil, {}
end
Line 802 ⟶ 829:
text = mw.ustring.gsub(text, "^[¿¡]?([^%s%p]+)%s*[؟?!;՛՜ ՞ ՟?!︖︕।॥။၊་།]?$", "%1") or text
text = unsupported and "ชื่อไม่รองรับ/" .. text or text
-- Escape unsupported characters so they can be used in titles. ` is used as a delimiter for this, so a raw use of it in an unsupported title is also escaped here to prevent interference; this is only done with unsupported titles, though, so inclusion won't in itself mean a title is treated as unsupported (which is why it's excluded from the earlier test).
if unsupported then
local unsupported_characters = conditionalRequire("Module:links/data").unsupported_characters
text = text
:gsub("[#<>%[%]_`{|}\239]\191?\189?", unsupported_characters)
:gsub("%f[^%z/]%.%.?%f[%z/]", function(m)
return m:gsub("%.", "`period`")
end)
:gsub("~~~+", function(m)
return m:gsub("~", "`tilde`")
end)
text = "Unsupported titles/" .. text
end
return text, fail, cats
Line 894 ⟶ 935:
-- Remove any interwiki link prefixes (unless they have been escaped or this has been disabled).
if text:match(":") and not keepPrefixes then
local rep
local m_utildata, rep = conditionalRequire("Module:utilities/data")
repeat
text, rep = text:gsub("\\\\(\\*:)", "\3%1")
Line 908 ⟶ 949:
end
local lower_prefix = prefix:ulower()
if not (m_utildata.conditionalRequire("Module:data/interwikis")[lower_prefix] or prefix == "") then
break
end
Line 1,045 ⟶ 1,086:
table.insert(types, type)
end
 
-- Retrieve main code for aliases. This should only end up non-nil if dontCanonicalizeAliases is passed to
-- make_object().
local main_code = self._rawData.main_code
if main_code and main_code == self:getCode() then
main_code = nil
end
 
local ret = {
ancestors = self:getAncestorCodes(),
Line 1,051 ⟶ 1,099:
categoryName = self:getCategoryName("nocap"),
code = self:getCode(),
mainCode = main_code,
entryNamePatterns = entryNamePatterns,
entryNameRemoveDiacritics = entryNameRemoveDiacritics,
Line 1,129 ⟶ 1,178:
local function no_inherit(lang, t, k)
if (
k == 2 or -- wikidata item
k == "main_code" or
k == "aliases" or
k == "varieties" or
k == "otherNames"
) then
return lang._stack[#lang._stack][k], true
end
end
Line 1,144 ⟶ 1,195:
end
if type(parts[1]) == "string" then
return table.concat(parts, ", "), true
end
return nil, true
end
end
Line 1,156 ⟶ 1,208:
return lang._stack[i][k]
end
local ret, stop_now = no_inherit(lang, t, k) or
if not stop_now then
append_data(lang, t, k) or
inherit_dataret, stop_now = append_data(lang, t, k)
end
if not stop_now then
ret = inherit_data(lang, t, k)
end
if (
k == 4 or
Line 1,211 ⟶ 1,267:
end
 
function export.makeObject(code, data, useRequire, dontCanonicalizeAliases)
if not data then
return nil
end
 
if not dontCanonicalizeAliases then
code = data.main_code or code
code = data.main_code or code
end
 
if data.type:find("family") and not data[5] then
return require("Module:families").makeObject(code, data, useRequire)
Line 1,254 ⟶ 1,312:
end
end
 
-- FIXME: Temporary. Lists bad codes to track, so we can consider eliminating them.
-- We list them directly here rather than in a separate module (cf. [[Module:etymology languages/track-bad-etym-code]])
-- in the hope that this reduces memory usage as we have to do this for every invocation of getByCode() for every
-- language code.
local codes_to_track = {
["bsg"] = true,
["inc-kha"] = true,
["pka"] = true,
["inc-mgd"] = true,
["inc-psc"] = true,
["pmh"] = true,
["psu"] = true,
["elu-prk"] = true,
["rdb"] = true,
["tgf"] = true,
}
 
local function track_bad_code(code)
if codes_to_track[code] then
track(code)
end
return true
end
 
local modulename = export.getDataModuleName(code)
local data = modulename and
track_bad_code(code) and conditionalRequire("Module:" .. modulename)[code] or
(allowEtymLang and require("Module:etymology languages/track-bad-etym-code")(code) and conditionalRequire("Module:etymology languages/data")[code]) or
(allowFamily and conditionalRequire("Module:families/data")[code]) or
(allowEtymLang and allowFamily and require("Module:families/track-bad-etym-code")(code) and conditionalRequire("Module:families/data/etymology")[code])
local retval = code and data and export.makeObject(code, data, useRequire)
Line 1,273 ⟶ 1,355:
--[==[Like {{code|lua|getByCanonicalName()}}, except it also looks at the <code class="n">otherNames</code> listed in the non-etymology language data modules, and does not (currently) have options to look up etymology languages and families.]==]
function export.getByName(name, errorIfInvalid)
local byNamecode = mw.loadDatarequire("Module:languages/bycanonical namenames/serialized")
:match("%z" .. require("Module:utilities").pattern_escape(name) .. "\1(.-)%f[%z]")
local code = byName.all and byName.all[name] or byName[name]
if not code then
Line 1,310 ⟶ 1,392:
-- For etymology families like "ira-pro".
-- FIXME: This is not ideal, as it allows " languages" to be appended to any etymology-only language, too.
byName[name:match("^กลุ่มภาษา(.*) languages$")]
end
Line 1,316 ⟶ 1,398:
byName = conditionalRequire("Module:families/canonical names")
code = byName and byName[name] or
byName[name:match("^กลุ่มภาษา(.*) languages$")]
end
ဢဝ်ၶိုၼ်းမႃးတီႈ "https://shn.wiktionary.org/wiki/မေႃႇၵျူး:languages"