Module:User:Wpstatus/translations

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


function dump(o)
   if type(o) == 'table' then
      local s = '{ '
      for k,v in pairs(o) do
         if type(k) ~= 'number' then k = '"'..k..'"' end
         s = s .. ' = ' .. dump(v) .. ','
      end
      return s .. '} '
   else
      return tostring(o)
   end
end

local export = {}

-- Implements {{t}} and {{t+}}.
function export.show(frame)
	local m_languages = require("Module:User:Wpstatus/languages")
	
	local args = require("Module:parameters").process(frame:getParent().args, mw.loadData("Module:parameters/data").translations.show, nil, "translations", "show")
	
	local terminfo = {
		lang = m_languages.getByCode(args) or m_languages.err(args, 1),
		sc = (args and (require("Module:scripts").getByCode(args) or error("The script code \"" .. args .. "\" is not valid.")) or nil),
		term = args or (mw.title.getCurrentTitle().nsText == "Template" and "term") or nil,
		alt = args,
		id = args,
		genders = args,
		tr = args,
		ts = args,
		lit = args,
		interwiki = frame.args,
	}
	
	return export.show_terminfo(terminfo)
end

function export.show_terminfo(terminfo)
	local m_data = mw.loadData("Module:translations/data")
	local m_links = require("Module:User:Wpstatus/links")
	
	-- Translations must be for mainspace languages
	if not terminfo.lang:hasType("regular") then
		error("Translations must be for attested and approved main-namespace languages.")
	end
	
	-- Don't show the interwiki link if there is nothing to link to.
	if terminfo.term then
		-- Track translations for particular languages
		if m_data.tracked then
			require("Module:debug/track")("translations/" .. terminfo.lang:getCode())
		end
		
		local wmlangs = {}
		
		if m_data.interwiki_langs then
			wmlangs = {require("Module:wikimedia languages").getByCode(m_data.interwiki_langs)}
		else
			wmlangs = terminfo.lang:getWikimediaLanguages()
		end
		
		-- Don't show the interwiki link if the language is not recognised by Wikimedia
		-- or if the term contains links (for SOP translations)
		if terminfo.term:find("[[", nil, true) or #wmlangs == 0 then
			terminfo.interwiki = false
		end
		
		if wmlangs and m_data.ignore_caps:getCode()] then
			terminfo.term2 = terminfo.term:gsub("^%^", "")
		end
		
		if terminfo.interwiki then
			local target_page = m_links.getLinkPage(terminfo.term2 or terminfo.term, terminfo.lang, terminfo.sc)
			terminfo.interwiki = tostring(mw.html.create("span")
				:addClass("tpos")
				:wikitext(" " .. m_links.language_link({term = wmlangs:getCode() .. ":" .. target_page, alt = "(" .. wmlangs:getCode() .. ")", lang = terminfo.lang, sc = terminfo.sc, tr = "-"}))
			)
		end
	else
		-- Track what entries currently don't provide a term
		require("Module:debug/track")("translations/no term")
		require("Module:debug/track")("translations/no term/" .. terminfo.lang:getCode())
	end
	
	if terminfo.lang and m_data.need_super and terminfo.tr then
		terminfo.tr = terminfo.tr:gsub("(%-??)", "<sup>%1</sup>")
	end
	
	return m_links.full_link(terminfo, "translation", true)
end

-- Implements {{trans-top}}.
function export.top(frame)
	local args = require("Module:parameters").process(frame:getParent().args, mw.loadData("Module:parameters/data").translations.top, nil, "translations", "top")
	
	local title = args and require("Module:links").remove_links(args)
	
	local categories = {}
	
	if (not title) and mw.title.getCurrentTitle().nsText == "" then
		table.insert(categories, "Translation table header lacks gloss")
	end
	
	local pagename, translation_subpage = mw.loadData("Module:headword/data").encoded_pagename:gsub("/translations$", "")
	if translation_subpage == 1 then
		table.insert(categories, "Translation subpages")
	end
	
	if #categories > 0 then
		local lang = require("Module:languages").getByCode("en")
		categories = require("Module:utilities").format_categories(categories, lang, nil, pagename)
	else
		categories = ""
	end
	
	local id = args or title
	
	local column_width = (args == "wide" or args == "narrow") and "-" .. args or ""
	
	local div = mw.html.create("div")
		:addClass("NavFrame")
		:node(mw.html.create("div")
			:addClass("NavHead")
			:css("text-align", "left")
			:css("cursor", "pointer")
			:wikitext((title or "Translations"))
		)
		:node(mw.html.create("div")
			:addClass("NavContent")
			:node(mw.html.create("table")
				:addClass("translations")
				:attr("role", "presentation")
				:css("width", "100%")
				:attr("data-gloss", title or "")
				:node(mw.html.create("tr")
					:node(mw.html.create("td")
						:addClass("translations-cell multicolumn-list" .. column_width)
						:css("background-color", "#ffffe0")
						:css("vertical-align", "top")
						:css("text-align", "left")
						:attr("colspan", "3")
					)
				)
			)
		)
	div = id and div:attr("id", "Translations-" .. id) or div
	div = tostring(div)
	
	return div:gsub("</td></tr></table></div></div>$", "") .. categories
end

-- Implements {{trans-bottom}}.
function export.bottom(frame)
	-- Check nothing is being passed as a parameter.
	require("Module:parameters").process(frame:getParent().args, mw.loadData("Module:parameters/data").translations.bottom, nil, "translations", "bottom")
	return "</table></div></div>"
end

-- Implements {{trans-see}}.
function export.see(frame)
	local args = require("Module:parameters").process(frame:getParent().args, mw.loadData("Module:parameters/data").translations.see, nil, "translations", "see")
	
	local inner = mw.html.create("div")
		:addClass("NavHead")
		:css("text-align", "left")
		:wikitext(args .. " ")
		:node(mw.html.create("span")
			:css("font-weight", "normal")
			:wikitext("— ")
			:node(mw.html.create("i")
				:wikitext("see ")
			)
		)
	
	if #args == 0 then
		table.insert(args, args)
	end
	
	local data = {}
	
	data.id = args and "Translations-" .. args
	
	local terms = {}
	for i, term in ipairs(args) do
		data.term = args
		table.insert(terms, require("Module:links").plain_link(data, false))
	end
	
	inner = inner:wikitext(table.concat(terms, ",&lrm; "))
	
	return tostring(mw.html.create("div")
		:addClass("pseudo NavFrame")
		:node(inner)
	)
end
	
return export