Module:User:Theknightwho/wikimedia languages

Hello, you have come here looking for the meaning of the word Module:User:Theknightwho/wikimedia languages. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Theknightwho/wikimedia languages, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Theknightwho/wikimedia languages in singular and plural. Everything you need to know about the word Module:User:Theknightwho/wikimedia languages you have here. The definition of the word Module:User:Theknightwho/wikimedia languages will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Theknightwho/wikimedia languages, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local export = {}

local WikimediaLanguage = {}

--function WikimediaLanguage:getAllNames()
--	return self._rawData.names
--end

function WikimediaLanguage:getWiktionaryLanguage()
	if not self._wiktionaryLanguageObject then
		self._wiktionaryLanguageObject = require("Module:languages").getByCode(self._rawData.wiktionary_code, nil, "allow etym")
	end
	return self._wiktionaryLanguageObject
end

require("Module:User:Theknightwho/objects").makePrototype(WikimediaLanguage, "Wikimedia language")

function export.getByCode(code)
	-- Only accept codes the software recognises
	if not mw.language.isKnownLanguageTag(code) then
		return nil
	end
	
	local rawData = mw.loadData("Module:wikimedia languages/data")
	
	-- If there is no specific Wikimedia code, then "borrow" the information
	-- from the general Wiktionary language code
	if not rawData then
		local lang = require("Module:languages").getByCode(code, nil, "allow etym")
		
		if not lang then
			return nil
		end
		
		rawData = {lang:getCanonicalName(), wiktionary_code = code}
	elseif not rawData then
		rawData = {
			require("Module:languages").getByCode(rawData.wiktionary_code, nil, "allow etym"):getCanonicalName(),
			wiktionary_code = rawData.wiktionary_code
		}
	end
	
	return setmetatable({_rawData = rawData, _code = code}, WikimediaLanguage)
end

function export.getByCodeWithFallback(code)
	local object = export.getByCode(code)
	
	if object then
		return object
	end
	
	local lang = require("Module:languages").getByCode(code, nil, "allow etym")
	
	if not lang then
		return nil
	end
	
	return lang:getWikimediaLanguages()
end

return export