This module implements the reference template {{R:be:NNP}}
.
-- This module provides references to the books from the series
-- https://be.wikipedia.orghttps://dictious.com/en/Назвы_населеных_пунктаў_Рэспублікі_Беларусь
local export = {}
local books = {
= {
year = 2003,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Мінская вобласць <t:The names of the settlements of the Republic of Belarus: Minsk Oblast>",
isbn = "985-458-054-7",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Mienskaja.djvu_"
},
= {
year = 2004,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Гродзенская вобласць <t:The names of the settlements of the Republic of Belarus: Hrodna Oblast>",
isbn = "985-458-098-9",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Haradzienskaja.djvu_"
},
= {
year = 2006,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Гомельская вобласць <t:The names of the settlements of the Republic of Belarus: Homiel Oblast>",
isbn = "985-458-131-4",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Homielskaja.djvu_"
},
= {
year = 2007,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Магілёўская вобласць <t:The names of the settlements of the Republic of Belarus: Mahiloŭ Oblast>",
isbn = "978-985-458-159-0",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Mahilouskaja.djvu_"
},
= {
year = 2009,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Віцебская вобласць <t:The names of the settlements of the Republic of Belarus: Viciebsk Oblast>",
isbn = "978-985-458-192-7",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Viciebskaja.djvu_"
},
= {
year = 2010,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Брэсцкая вобласць <t:The names of the settlements of the Republic of Belarus: Brest Oblast>",
isbn = "978-985-458-198-9",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Bierasciejskaja.djvu_"
}
}
-- For the sake of consistency, allow only one way to specify the oblast. But give a hint
-- to the editor about how to rename it correctly.
local rename_hints = {
= "Брэстчына",
= "Магілёўшчына", = "Магілёўшчына", = "Магілёўшчына", = "Магілёўшчына",
= "Гомельшчына", = "Гомельшчына", = "Гомельшчына", = "Гомельшчына",
= "Міншчына", = "Міншчына", = "Міншчына",
= "Віцебшчына", = "Віцебшчына", = "Віцебшчына",
= "Гродзеншчына", = "Гродзеншчына",
}
-- Prepare tables
local AC = require("Module:string/char")(0x0301) -- acute = ́
local consonants_set = {}
mw.ustring.gsub("БВГДЖЗКЛМНПРСТФХЦЧШбвгджзклмнпрстфхцчш", ".", function (c) consonants_set = true end)
local jejojuja_default = {
= "je", = "jo", = "ju", = "ja",
= "Je", = "Jo", = "Ju", = "Ja",
}
local jejojuja_after_consonant = {
= "ie", = "io", = "iu", = "ia",
= "ie", = "io", = "iu", = "ia",
}
local jejojuja_after_l = {
= AC .. "e", = AC .. "o", = AC .. "u", = AC .. "a",
= AC .. "e", = AC .. "o", = AC .. "u", = AC .. "a",
}
-- The table from https://digitallibrary.un.org/record/4021251/files/E_CONF.101_CRP.2-EN.pdf
local tt = {
='A', ='a',
='B', ='b',
='V', ='v',
='H', ='h',
='D', ='d',
='Je', ='je',
='Jo', ='jo',
='Ž', ='ž',
='Z', ='z',
='I', ='i',
='J', ='j',
='K', ='k',
='L', ='l',
='M', ='m',
='N', ='n',
='O', ='o',
='P', ='p',
='R', ='r',
='S', ='s',
='T', ='t',
='U', ='u',
='Ŭ', ='ŭ',
='F', ='f',
='Ch', ='ch',
='C', ='c',
='Č', ='č',
='Š', ='š',
='Y', ='y',
=AC, =AC,
='E', ='e',
='Ju', ='ju',
='Ja', ='ja',
='', ='', = '',
-- Additional entries
='G', ='g',
='I', ='i', -- present for Old Belarusian; FIXME, remove when we have a separate language code for this lang
}
function export.romanize(s, rules)
local lacinka, palatalize
if rules == "be-Latn-tarask" then
lacinka = true
palatalize = true
elseif rules == "be-Latn-1959acad" then
lacinka = true
elseif rules == "UNGEGN" then
lacinka = false
else
error("Wrong romanization rules config: " .. rules)
end
local prev_c = "."
s = mw.ustring.gsub(s, ".", function(c)
local jejojuja = jejojuja_default
if jejojuja then
if consonants_set then
if lacinka and (prev_c == "Л" or prev_c == "л") then
jejojuja = jejojuja_after_l
else
jejojuja = jejojuja_after_consonant
end
end
prev_c = c
return jejojuja
end
prev_c = c
return tt or c
end)
-- recover the explicit palatalization where appropriate: https://knihi.com/storage/pravapis2005.html#texth2_8
-- FIXME: there are still more cases to handle, such as "суддзя" -> "sudździa"
if palatalize then
repeat
local old_s = s
s = mw.ustring.gsub(s, "()()", "%1" .. AC .. "%2")
s = mw.ustring.gsub(s, "()()", "%1" .. AC .. "%2")
s = mw.ustring.gsub(s, "()()", "%1" .. AC .. "%2")
s = mw.ustring.gsub(s, "()()", "%1" .. AC .. "%2")
until s == old_s
end
-- combine acute diacritics with their letters
s = mw.ustring.toNFC(s)
-- change "Ĺ" -> "L" and "L" -> "Ł"
if lacinka then
s = mw.ustring.gsub(s, ".", { = "ł", = "l", = "Ł", = "L"})
end
-- done
return s
end
function export.show(frame)
local parent_args = frame:getParent().args
local params = {
= {alias_of = "oblast"},
= {alias_of = "page"},
= {alias_of = "entry"},
= {required = true},
= {type = "number"},
= {},
}
local args = require("Module:parameters").process(parent_args, params)
if not books then
if rename_hints then
error("The name of the oblast needs to be changed to: " .. rename_hints)
end
local errmsg = "Invalid oblast name. Valid choices are:"
for k, v in pairs(books) do
errmsg = errmsg .. " " .. k
end
error(errmsg)
end
local citation_args = books
-- The difference between the page numbers in DjVu and page numbers in the paper books
local page_offs = 2
-- Some of the pages are missing for Mahilyow :-(
local Mahilyow_missing_pages = { 259, 262, 278, 279, 288, 295, 298, 299, 313, 321, 322 }
if args.oblast == "Магілёўшчына" then
for _, p in ipairs(Mahilyow_missing_pages) do
if args.page == p then
error("Page " .. tostring(args.page) .. " is missing in the scan of the book.")
end
if args.page > p then
page_offs = page_offs - 1
end
end
end
citation_args = "be"
citation_args.editor = "]"
citation_args.location = "be:]"
citation_args.publisher = "lw:be:]"
if args.page then
citation_args.page = args.page
citation_args.pageurl = citation_args.pageurl .. tostring(args.page + page_offs)
end
local prefix = ""
local entry = frame.args.entry or args.entry
if entry then
local entry_lat = export.romanize(entry, "be-Latn-tarask")
local entry_geo = export.romanize(entry, "UNGEGN")
if entry_lat == entry_geo then
prefix = "«" .. entry .. "» ''alias'' “" .. entry_lat .. "”<sup>] / </sup> in "
else
prefix = "«" .. entry .. "» ''alias'' “" .. entry_lat .. "”<sup>]</sup> or “" .. entry_geo .. "”<sup></sup> in "
end
end
return prefix .. frame:expandTemplate {title = "cite-book", args = citation_args}
end
return export