Po redaktohet
Moduli:writing systems
Kërceni tek navigimi
Kërceni tek kërkimi
Kujdes:
S’jeni i regjistruar. Adresa juaj IP do të jetë e dukshme publikisht, nëse bëni ndonjë redaktim. Nëse
hyni
ose
krijoni një llogari
, përveç përfitimesh të tjera, redaktimet tuaja do t’i atribuohen emrit tuaj të përdoruesit.
Kontrolli anti-spam.
Mos
e plotëso këtë!
local export = {} local en_utilities_module = "Module:en-utilities" local json_module = "Module:JSON" local language_like_module = "Module:language-like" local load_module = "Module:load" local table_module = "Module:table" local writing_systems_data_module = "Module:writing systems/data" local gmatch = string.gmatch local make_object -- Defined below. local require = require local setmetatable = setmetatable 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 deep_copy(...) deep_copy = require(table_module).deepCopy return deep_copy(...) 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 pluralize(...) pluralize = require(en_utilities_module).pluralize return pluralize(...) end local function to_json(...) to_json = require(json_module).toJSON return to_json(...) 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 writing_systems_data local function get_writing_systems_data() writing_systems_data, get_writing_systems_data = load_data(writing_systems_data_module), nil return writing_systems_data end local WritingSystem = {} WritingSystem.__index = WritingSystem function WritingSystem:getCode() return self._code end function WritingSystem:getCanonicalName() return self._data[1] end function WritingSystem:getDisplayForm(singular) return singular and (self._data.category or self:getCanonicalName()) or self:getCategoryName("nocap") end function WritingSystem:getAliases() WritingSystem.getAliases = require(language_like_module).getAliases return self:getAliases() end function WritingSystem:getVarieties(flatten) WritingSystem.getVarieties = require(language_like_module).getVarieties return self:getVarieties(flatten) end function WritingSystem:getOtherNames() WritingSystem.getOtherNames = require(language_like_module).getOtherNames return self:getOtherNames() end function WritingSystem:getAllNames() WritingSystem.getAllNames = require(language_like_module).getAllNames return self:getAllNames() end --[==[Returns a table of types as a lookup table (with the types as keys). Currently, the only possible type is {writing system}.]==] function WritingSystem:getTypes() local types = self._types if types == nil then types = {["writing system"] = 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 writing system has all of them.]==] function WritingSystem:hasType(...) WritingSystem.hasType = require(language_like_module).hasType return self:hasType(...) end function WritingSystem:getCategoryName(nocap) local name = pluralize(self._data.category or self:getCanonicalName()) if not nocap then name = mw.getContentLanguage():ucfirst(name) end return name end function WritingSystem:makeCategoryLink() return "[[:Category:" .. self:getCategoryName() .. "|" .. self:getDisplayForm() .. "]]" end --[==[Returns the Wikidata item id for the writing system or <code>nil</code>. This corresponds to the the second field in the data modules.]==] function WritingSystem:getWikidataItem() WritingSystem.getWikidataItem = require(language_like_module).getWikidataItem return self:getWikidataItem() end function WritingSystem:getWikipediaArticle(noCategoryFallback, project) WritingSystem.getWikipediaArticle = require(language_like_module).getWikipediaArticle return self:getWikipediaArticle(noCategoryFallback, project) end --[==[Returns the name of the Wikimedia Commons category page for the writing system.]==] function WritingSystem:getCommonsCategory() WritingSystem.getCommonsCategory = require(language_like_module).getCommonsCategory return self:getCommonsCategory() end function WritingSystem:getData() return self._data end --[==[Returns the name of the module containing the writing system's data. Currently, this is always [[Module:writing systems/data]].]==] function WritingSystem:getDataModuleName() return writing_systems_data_module end function WritingSystem:toJSON(opts) local ret = { canonicalName = self:getCanonicalName(), categoryName = self:getCategoryName("nocap"), code = self:getCode(), aliases = self:getAliases(), varieties = self:getVarieties(), otherNames = self:getOtherNames(), type = keys_to_list(self:getTypes()), 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}, WritingSystem) end make_object = export.makeObject function export.getByCode(code) local data = (writing_systems_data or get_writing_systems_data())[code] return data ~= nil and make_object(code, data) or nil end export.getByCanonicalName = export.getByCode return export
Përmbledhje:
Ju lutemi, vini re! Të gjitha kontributet në Enciklopedi Puro Shqiptare jepen për publikim sipas Creative Commons Attribution (shiko
Project:Të drejtat e autorit
për më shumë detaje). Nëse ju nuk dëshironi që shkrimet tuaja të redaktohen pa mëshirë dhe të shpërndahen sipas dëshirës, atëherë mos i vendosni këtu.
Gjithashtu, ju po na premtoni ne që gjithçka e keni shkruar vetë, ose e keni kopjuar nga një domain publik ose nga burime të tjera te hapura.
Mos vendosni material të mbrojtur nga e drejta e autorit pa leje!
Anuloje
Ndihmë për redaktim
(hapet në një dritare të re)
Stamp të përdorura në këtë faqe:
Moduli:writing systems/doc
(
redakto
)
Menu lëvizjesh
Mjetet e mia
Nuk keni hyrë brenda
Diskutimi
Kontribute
Krijo llogari
Hyni
Emërhapësira
Moduli
Diskutim
English
Shikime
Lexo
Përpunoni burim
Shihni historikun
Më shumë
Kërko
Lëvizje
Faqja kryesore
Ndryshimet e fundit
Faqe e rastit
Ndihmë rreth MediaWiki-t
Faqet e veçanta
Mjete
Lidhjet këtu
Ndryshime të ndërvarura
Informacioni i faqes