Module:languages៖ ភាពខុសគ្នារវាងកំណែនានា

ខ្លឹមសារដែលបានលុបចោល ខ្លឹមសារដែលបានសរសេរបន្ថែម
No edit summary
No edit summary
បន្ទាត់ទី១០៖
 
function Language:getCanonicalName()
return self._rawData.names[1]canonicalName
end
 
 
-- Commented out; I don't think anything uses this, the presence/absence of script errors should confirm
--function Language:getAllNames()
-- return self._rawData.names
end
--end
 
 
function Language:getOtherNames()
return self._rawData.otherNames or {}
if not self._otherNames then
self._otherNames = {}
for i, val in ipairs(self._rawData.names) do
if i > 1 then
table.insert(self._otherNames, val)
end
end
end
return self._otherNames
end
 
 
function Language:getType()
return self._rawData.type or "regular"
end
 
Line ៥១ ⟶ ៤២:
return self._wikimediaLanguageObjects
end
 
 
function Language:getWikipediaArticle()
return self._rawData.wikipedia_article or self:getCategoryName()
end
 
Line ៥៩ ⟶ ៥៥:
self._scriptObjects = {}
for _, sc in ipairs(self._rawData.scripts or {"None"}) do
table.insert(self._scriptObjects, m_scripts.getByCode(sc))
end
Line ៦៩ ⟶ ៦៥:
 
function Language:getFamily()
if self._rawData.family and not self._familyObject then
self._familyObject = require("Module:families").getByCode(self._rawData.family)
end
Line ៨១ ⟶ ៧៧:
self._ancestorObjects = {}
forif _, ancestor in ipairs(self._rawData.ancestors or {}) dothen
for i_, valancestor in ipairs(self._rawData.namesancestors) do
table.insert(self._ancestorObjects, export.getByCode(ancestor) or require("Module:etymology languages").getByCode(ancestor))
end
else
local fam = self:getFamily()
local protoLang = fam and fam:getProtoLanguage() or nil
-- For the case where the current language is the proto-language
-- of its family, we need to step up a level higher right from the start.
if protoLang and protoLang:getCode() == self:getCode() then
fam = fam:getFamily()
protoLang = fam and fam:getProtoLanguage() or nil
end
while not protoLang and not (not fam or fam:getCode() == "qfa-not") do
fam = fam:getFamily()
protoLang = fam and fam:getProtoLanguage() or nil
end
table.insert(self._otherNames_ancestorObjects, valprotoLang)
end
end
Line ៨៩ ⟶ ១០៤:
end
 
local function iterateOverAncestorTree(node, func)
for _, ancestor in ipairs(node:getAncestors()) do
if ancestor then
local ret = func(ancestor) or iterateOverAncestorTree(ancestor, func)
if i > 1ret then
return ret
end
end
end
end
 
function Language:getAncestorChain()
Line ១០២ ⟶ ១២៧:
return self._ancestorChain
end
 
 
function Language:hasAncestor(otherlang)
local function compare(ancestor)
return ancestor:getCode() == otherlang:getCode()
end
return iterateOverAncestorTree(self, compare) or false
end
 
 
function Language:getCategoryName()
local name = self._rawData.names[1]canonicalName
-- If the name already has "language" in it, don't add it.
Line ១១៤ ⟶ ១៤៧:
return name .. " language"
end
end
 
 
function Language:getStandardCharacters()
return self._rawData.standardChars
end
 
Line ១១៩ ⟶ ១៥៧:
function Language:makeEntryName(text)
text = mw.ustring.gsub(text, "^[¿¡]", "")
text = mw.ustring.gsub(text, "(.)[؟?!;՛՜ ՞ ՟?!।॥။၊་།]$", "%1")
if self._rawData.entry_name then
Line ១៣៨ ⟶ ១៧៦:
name = mw.ustring.gsub(name, "^[-־ـ*]+(.)",
"%1")
-- Remove anything in parentheses, as long as they are either preceded or followed by something
name = mw.ustring.gsub(name, "(.)%([^()]+%)", "%1")
name = mw.ustring.gsub(name, "%([^()]+%)(.)", "%1")
-- If there are language-specific rules to generate the key, use those
Line ១៦៤ ⟶ ២០២:
return require("Module:" .. (module_override or self._rawData.translit_module)).tr(text, self:getCode(), sc and sc:getCode() or nil)
end
 
 
function Language:link_tr()
return self._rawData.link_tr and true or false
end
 
Line ២០៥ ⟶ ២៤៨:
 
 
local function export.getDataModuleName(code)
if code:find("^[a-z][a-z]$") then
return "languages/data2"
Line ២២០ ⟶ ២៦៣:
 
local function getRawLanguageData(code)
local modulename = export.getDataModuleName(code)
return modulename and mw.loadData("Module:" .. modulename)[code] or nil
end