Jump to content

Module:Editnotice load/config loader

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Awesome Aasim (talk | contribs) at 21:20, 28 June 2025. The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local hasI18n, i18n = pcall(function()
	local i18n = require("Module:i18n").loadMessages("Editnotice load")
	return i18n
end)
local hasCfg, loadCfg = pcall(mw.loadData, "Module:Editnotice load/config")
if not hasI18n then i18n = {} end
if not hasCfg then loadCfg = {} end
if not hasI18n and not hasCfg then
	error("Internationalization and configuration files for [[Module:Editnotice load]] is missing!")
end
local currLang = mw.language.getContentLanguage().code
local function fetch(message, lang, fallback)
	return i18n:msg(message)
end

--[=[===========================================================================
LOAD THE CONFIGURATION FILE. WE WILL BE ASSUMING THE I18N IS PRESENT, IF IT IS 
NOT, THEN IT WILL THROW AN ERROR.

OPTIONAL CONFIGURATION WILL BE SET TO nil OR EMPTY STRING.
=============================================================================]=]
local cfg = {
	pseudo_ns_name = loadCfg.pseudo_ns_name or fetch("pseudo_ns_name", currLang, "en"),
	editnotice_classes = loadCfg.editnotice_classes or "",
	editnotice_types = {
		protection = loadCfg.editnotice_types.protection or fetch("editnotice_types_protection", currLang, "en"),
		protection_id = loadCfg.editnotice_types.protection_id or fetch("editnotice_types_protection_id", currLang, "en"),
		title = loadCfg.editnotice_types.title or fetch("editnotice_types_title", currLang, "en"),
		page = loadCfg.editnotice_types.page or fetch("editnotice_types_page", currLang, "en"),
		group = loadCfg.editnotice_types.group or fetch("editnotice_types_group", currLang, "en"),
		category = loadCfg.editnotice_types.category or fetch("editnotice_types_category", currLang, "en"),
		namespace = loadCfg.editnotice_types.namespace or fetch("editnotice_types_namespace", currLang, "en")
	},
	user_editnotice = loadCfg.user_editnotice or nil,
	links = loadCfg.links or fetch("links", currLang, "en"),
	editnotice_names = {
		protection = loadCfg.editnotice_names.protection or fetch("editnotice_names_protection", currLang, "en"),
		protection_id = loadCfg.editnotice_names.protection_id or fetch("editnotice_names_protection_id", currLang, "en"),
		title = loadCfg.editnotice_names.title or fetch("editnotice_names_title", currLang, "en"),
		page = loadCfg.editnotice_names.page or fetch("editnotice_names_page", currLang, "en"),
		group = loadCfg.editnotice_names.group or fetch("editnotice_names_group", currLang, "en"),
		category = loadCfg.editnotice_names.category or fetch("editnotice_names_category", currLang, "en"),
		namespace = loadCfg.editnotice_names.namespace or fetch("editnotice_names_namespace", currLang, "en")
	},
	noEditnoticePage = loadCfg.noEditnoticePage or fetch("noEditnoticePage", currLang, "en"),
	mainspace = loadCfg.mainspace or fetch("mainspace", currLang, "en"),
	templateStyles = loadCfg.templateStyles or ""
}

return cfg