Po redaktohet
Moduli:wikimedia languages
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 languages_module = "Module:languages" local language_like_module = "Module:language-like" local load_module = "Module:load" local wm_languages_data_module = "Module:wikimedia languages/data" local get_by_code -- Defined below. local gmatch = string.gmatch local is_known_language_tag = mw.language.isKnownLanguageTag 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 get_lang(...) get_lang = require(languages_module).getByCode return get_lang(...) end local function get_lang_data_module_name(...) get_lang_data_module_name = require(languages_module).getDataModuleName return get_lang_data_module_name(...) end local function load_data(...) load_data = require(load_module).load_data return load_data(...) 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 wm_languages_data local function get_wm_languages_data() wm_languages_data, get_wm_languages_data = load_data(wm_languages_data_module), nil return wm_languages_data end local WikimediaLanguage = {} WikimediaLanguage.__index = WikimediaLanguage function WikimediaLanguage:getCode() return self._code end function WikimediaLanguage:getCanonicalName() return self._data[1] end --function WikimediaLanguage:getAllNames() -- return self._data.names --end --[==[Returns a table of types as a lookup table (with the types as keys). Currently, the only possible type is {Wikimedia language}.]==] function WikimediaLanguage:getTypes() local types = self._types if types == nil then types = {["Wikimedia language"] = 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 Wikimedia language has all of them.]==] function WikimediaLanguage:hasType(...) WikimediaLanguage.hasType = require(language_like_module).hasType return self:hasType(...) end function WikimediaLanguage:getWiktionaryLanguage() local object = self._wiktionaryLanguageObject if object == nil then object = get_lang(self._data.wiktionary_code, nil, "allow etym") self._wiktionaryLanguageObject = object end return object end -- Do NOT use this method! -- All uses should be pre-approved on the talk page! function WikimediaLanguage:getData() return self._data end --[==[Returns the name of the module containing the Wikimedia language's data (if any). Currently, this is always [[Module:wikimedia languages/data]].]==] function WikimediaLanguage:getDataModuleName() return wm_languages_data_module 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}, WikimediaLanguage) end make_object = export.makeObject function export.getByCode(code) -- Only accept codes the software recognises. if not is_known_language_tag(code) then return nil end local data = (wm_languages_data or get_wm_languages_data())[code] -- If there is no specific Wikimedia code, then "borrow" the information -- from the general Wiktionary language code. local name, wiktionary_code if data ~= nil then name, wiktionary_code = data[1], data.wiktionary_code if not (name == nil or wiktionary_code == nil) then return make_object(code, data) end end -- Get the associated Wiktionary language, using the wiktionary_code key or -- else the input code. if wiktionary_code == nil then wiktionary_code = code end local lang = get_lang(wiktionary_code, nil, "allow etym", "allow family") if lang ~= nil then return make_object(code, { name == nil and lang:getCanonicalName() or name, wiktionary_code = wiktionary_code, }) end -- If there's no Wiktionary language for the relevant code, throw an error. -- This should never happen. local msg, arg3 if data == nil then msg = "code '%s' is a valid Wikimedia language code, but there is no corresponding data in [[%s]], [[%s]] or [[Module:families/data]]" elseif wiktionary_code ~= code then msg = "code '%s' is a valid Wikimedia language code and has data in [[%s]], but its 'wiktionary_code' key '%s' is not valid" arg3 = wiktionary_code else msg = "code '%s' is a valid Wikimedia language code and has data in [[%s]], but no corresponding data in [[%s]] or [[Module:families/data]]" end error(msg:format(code, wm_languages_data_module, arg3 or get_lang_data_module_name(code))) end get_by_code = export.getByCode function export.getByCodeWithFallback(code) local object = get_by_code(code) if object ~= nil then return object end local lang = get_lang(code, nil, "allow etym") return lang ~= nil and lang:getWikimediaLanguages()[1] or nil end 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:wikimedia languages/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