Naar inhoud springen

Module:Wd/i18n

Uit Wikipedia, de vrije encyclopedie
Dit is een oude versie van deze pagina, bewerkt door Sjoerddebruin (overleg | bijdragen) op 6 sep 2024 om 21:02. (Sync met enwiki)
Deze versie kan sterk verschillen van de huidige versie van deze pagina.
Moduledocumentatie​[bekijk] [bewerk] [ververs] [geschiedenis]

Deze submodule wordt gebruikt door Module:Wd voor internationalisatiedoeleinden (internationalization, i18n) en is afgescheiden om het mogelijk te maken de modules logica te updaten onafhankelijk van de taalinstelling.

-- The values and functions in this submodule should be localized per wiki.

local p = {}

function p.init(aliasesP)
	p = {
		["version"] = "7",  -- increment this each time the below parameters are changed to avoid reference conflict errors
		["errors"] = {
			["unknown-data-type"]          = "datatype '%s' is onbekend of wordt niet ondersteund.",
			["missing-required-parameter"] = "geen verplichte parameters gedefinieerd, ten minste één benodigd.",
			["extra-required-parameter"]   = "parameter '%s' moet worden gedefinieerd als zijnde optioneel.",
			["no-function-specified"]      = "u moet een aan te roepen functie opgeven.",  -- equal to the standard module error message
			["main-called-twice"]          = 'de functie "main" kan niet twee keer worden aangeroepen.',
			["no-such-function"]           = 'de functie "%s" bestaat niet.',  -- equal to the standard module error message
            ["no-such-reference-template"] = 'Fout: het sjabloon "%s", welke is opgegeven in %s als het uitvoersjabloon voor het citaattype "%s", bestaat niet.',
            -- Parts of the error message signalling a malformed reference.
            ["malformed-reference-header"] = "<span style=\"color:#dd3333\">\nFout: Niet mogelijk om op basis van Wikidata een referentie te vormen. Technische details:\n",
            ["malformed-reference-footer"] = "</span>\n[[Categorie:Wikipedia:Pagina's met referentiefouten]]",
            ["template-failure-reason"]    = "* Reden voor de fout van {{tl|%s}}: %s\n",
            ["missing-mandatory-param"]    = 'Het uitvoersjabloon mist op deze manier de verplichte parameter <code>%s</code>.',
            ["unknown-property-in-ref"]    = 'De Wikidata-referentie bevat de eigenschap {{property|%s}}, welke niet toegewezen is aan een parameter van dit sjabloon.'
		},
		["info"] = {
			["edit-on-wikidata"] = "Bewerken op Wikidata"
		},
		["numeric"] = {
			["decimal-mark"] = ",",
			["delimiter"]    = "."
		},
		["datetime"] = {
			["prefixes"] = {
				["decade-period"] = "jaren "
			},
			["suffixes"] = {
				["decade-period"] = "",
				["millennium"]    = " millennium",
				["century"]       = " eeuw",
				["million-years"] = " miljoen jaar",
				["billion-years"] = " miljard jaar",
				["year"]          = " jaar",
				["years"]         = " jaar"
			},
			["julian-calendar"] = "Juliaanse kalender",  -- linked page title
			["julian"]          = "Juliaans",
			["BCE"]             = "v.g.j.",
			["CE"]              = "g.j.",
			["common-era"]      = "Gangbare jaartelling"  -- linked page title
		},
		["coord"] = {
			["latitude-north"] = "NB",
			["latitude-south"] = "ZB",
			["longitude-east"] = "OL",
			["longitude-west"] = "WL",
			["degrees"]        = "°",
			["minutes"]        = "'",
			["seconds"]        = '"',
			["separator"]      = ", "
		},
		["values"] = {
			["unknown"] = "onbekend",
			["none"]    = "geen"
		},
		["cite"] = {
			["output-types"] = {"web"},  -- In this order, the output types will be tried
			["param-mapping"] = {
				["web"] = {
					-- <= left side: all allowed reference properties for *web page sources* per https://www.wikidata.org/wiki/Help:Sources
					-- => right side: corresponding parameter names in (equivalent of) [[:en:Template:Cite web]] (if non-existent, keep empty i.e. "")
					[aliasesP.statedIn]                = "website",
					[aliasesP.referenceURL]            = "url",
					[aliasesP.publicationDate]         = "datum",
					[aliasesP.retrieved]               = "bezochtdatum",
					[aliasesP.title]                   = "titel",
					[aliasesP.archiveURL]              = "archiefurl",
					[aliasesP.archiveDate]             = "archiefdatum",
					[aliasesP.language]                = "",
					[aliasesP.author]                  = "auteur",
					[aliasesP.authorNameString]        = "auteur",
					[aliasesP.publisher]               = "uitgever",
					[aliasesP.quote]                   = "citaat",
					[aliasesP.pages]                   = "paginas",  -- extra option
					[aliasesP.publishedIn]             = "website",
					[aliasesP.sectionVerseOrParagraph] = ""
				},
				["q"] = {
					-- <= left side: all allowed reference properties for *sources other than web pages* per https://www.wikidata.org/wiki/Help:Sources
					-- => right side: corresponding parameter names in (equivalent of) [[:en:Template:Cite Q]] (if non-existent, keep empty i.e. "")
					[aliasesP.statedIn]                = "",
					[aliasesP.pages]                   = "",
					[aliasesP.column]                  = "",
					[aliasesP.chapter]                 = "",
					[aliasesP.sectionVerseOrParagraph] = "",
					["external-id"]                    = "",  -- used for any type of database property ID
					[aliasesP.title]                   = "",
					[aliasesP.publicationDate]         = "",
					[aliasesP.retrieved]               = ""
				}
			},
			["config"] = {
				-- supported fields:
				--     - template: name of the template used for output
				--     - numbered-params: citation params accepting an arbitrary number of values by numbering the params (e.g. author1, author2)
				--     - raw-value-params: params taking a raw value (which means the property is rendered with getValue with raw=true)
				--     - mandatory-params: params that are required be in the template call (after potentially appending numbers to params listed in numbered-params)
				-- Leaving out the "template" field causes the output type to be ignored.
				["web"] = {
					["template"] = "Citeer web",
					["numbered-params"] = {"auteur"},
					["mandatory-params"] = {"url", "titel"}
				},
				["q"] = {
					["template"] = "Citeer Q",
					["raw-value-params"] = {"1"},  -- the first, unnamed parameter of CiteQ takes a QID, not the name of the item cited
					["mandatory-params"] = {"1"}
				}
			}
		}
	}

	p.getOrdinalSuffix = function(num)
		if tostring(num):sub(-2,-2) == '1' then
			return "th"  -- 10th, 11th, 12th, 13th, ... 19th
		end

		num = tostring(num):sub(-1)

		if num == '1' then
			return "st"
		elseif num == '2' then
			return "nd"
		elseif num == '3' then
			return "rd"
		else
			return "th"
		end
	end

	p.addDelimiters = function(n)
		local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$")

		if left and num and right then
			return left .. (num:reverse():gsub("(%d%d%d)", "%1" .. p['numeric']['delimiter']):reverse()) .. right
		else
			return n
		end
	end

	return p
end

return p