Module:U:de:unadapted

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

This module powers {{U:de:unadapted}}.


local export = {}

local lang = require("Module:languages").getByCode("de")
local m_links = require("Module:links")

local function bind_second(f, second)
	return function (x) return f(x, second) end
end

local function discard(offset, iter, obj, index)
	return iter, obj, index + offset
end

local function get_link(target)
	return m_links.full_link({ term = target, lang = lang }, "term")
end

local function get_link_if_exists(target)
	local content = mw.title.new(target):getContent()
	-- White space before and after the language name is not supported.
	if content ~= nil and content:find("==" .. lang:getCanonicalName() .. "==", 1, true) then
		return m_links.full_link({ term = target, lang = lang }, "term")
	else
		return m_links.full_link({ alt = target, lang = lang }, "term")
	end
end

local function get_transformed_interfixed_form(parts, transform, interfix)
	local result = parts
	for i, part in discard(1, ipairs(parts)) do
		result = result .. interfix .. transform(part)
	end
	return result
end

local function get_solid_form(parts)
	return get_transformed_interfixed_form(parts, function (part) return part:gsub("^%u", string.lower) end, "")
end

local function get_capitalizer_or_id(capitalize)
	if capitalize then
		return function (part) return part:gsub("^%l", string.upper) end
	else
		return function (part) return part end
	end
end

local function get_hyphenated_form(parts, capitalize)
	return get_transformed_interfixed_form(parts, get_capitalizer_or_id(capitalize), "-")
end

local function get_spaced_form(parts, capitalize)
	return get_transformed_interfixed_form(parts, get_capitalizer_or_id(capitalize), " ")
end

function export.show(frame)
   	local args = require "Module:parameters".process(frame:getParent().args, {
		 = { required = true },
		 = {},
		 = { default = true, type = "boolean" },
	})

	local type = args
	local title = args or mw.title.getCurrentTitle().text
	local parts = {}
	for part in title:gmatch("+") do
		table.insert(parts, part)
	end

	local ref = ""
	if args then
		ref = frame:preprocess("<ref name=\"Duden Fremdwörter\">{{cite-web|de|title=Schreibung von Fremdwörtern aus dem Englischen|trans-title=Spelling of loan words from English|url=https://www.duden.de/sprachwissen/sprachratgeber/Schreibung-von-Fremdwortern-aus-dem-Englischen|archivedate=2023-01-20|archiveurl=https://web.archive.org/web/20230120090337/https://www.duden.de/sprachwissen/sprachratgeber/Schreibung-von-Fremdwortern-aus-dem-Englischen|work={{w|Duden}}|publisher={{w|Cornelsen Verlag GmbH|lang=de}}}}</ref>")
	end
	
	local types = {
		 = { -- noun+noun
			content = "consisting of two nouns be written solid$z or, if it improves legibility, hyphenated$h. The spaced spelling$S is ]",
			do_links = #parts == 2,
			capitalize = true,
		},
		 = { -- adj+noun with stress on the adjective
			content = "consisting of an adjective (that carries the stress) and a noun be written solid$z or, alternatively, spaced$s. The hyphenated spelling$H is ]",
			do_links = #parts == 2,
			capitalize = true,
		},
		 = { -- adj+noun with stress on the noun
			content = "consisting of an adjective and a noun (that carries the stress) be written spaced$s. The hyphenated$H and solid$Z spellings are ]",
			do_links = #parts == 2,
			capitalize = true,
		},
		 = { -- verb+particle/preposition
			content = "consisting of a verb and a particle be written solid$z or, alternatively, hyphenated$h. The spaced spelling$S is ]",
			do_links = #parts == 2,
			capitalize = false,
		},
	}
	
	local type_data = types
	if type_data == nil then
		local types_str = ""
		for type, _ in pairs(types) do
			types_str = types_str .. type .. ", "
		end
		error("Unrecognized type \"" .. type .. "\"; recognized types are: " .. types_str:sub(1, -3))
	end
	
	local content = type_data.content
	for _, t in ipairs({ { string.lower, get_link }, { string.upper, get_link_if_exists } }) do
		for c, g in pairs({  = get_solid_form,  = bind_second(get_hyphenated_form, type_data.capitalize),  = bind_second(get_spaced_form, type_data.capitalize) }) do
			content = content:gsub("%$" .. (t)(c), type_data.do_links and (" (" .. (t)(g(parts)) .. ")") or "")
		end
	end
	
	return "The ] prescribes that ] " .. content .. "." .. ref
end

return export