Module:R:be:NNP
Appearance
- The following documentation is generated by Module:documentation. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module implements the reference template {{R:be:NNP}}
.
-- This module provides references to the books from the series
-- https://be.wikipedia.org/wiki/Назвы_населеных_пунктаў_Рэспублікі_Беларусь
local export = {}
local books = {
["Брэстчына"] = {
year = 2010,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Брэсцкая вобласць <t:Names of settlements of the Republic of Belarus: Brest region>",
isbn = "978-985-458-198-9",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Bierasciejskaja.djvu_"
},
["Гомельшчына"] = {
year = 2006,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Гомельская вобласць <t:Names of settlements of the Republic of Belarus: Homiel region>",
isbn = "985-458-131-4",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Homielskaja.djvu_"
},
["Гродзеншчына"] = {
year = 2004,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Гродзенская вобласць <t:Names of settlements of the Republic of Belarus: Hrodna region>",
isbn = "985-458-098-9",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Haradzienskaja.djvu_"
},
["Магілёўшчына"] = {
year = 2007,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Магілёўская вобласць <t:Names of settlements of the Republic of Belarus: Mahiloŭ region>",
isbn = "978-985-458-159-0",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Mahilouskaja.djvu_"
},
["Міншчына"] = {
year = 2003,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Мінская вобласць <t:Names of settlements of the Republic of Belarus: Minsk region>",
isbn = "985-458-054-7",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Mienskaja.djvu_"
},
["Віцебшчына"] = {
year = 2009,
title = "Назвы населеных пунктаў Рэспублікі Беларусь: Віцебская вобласць <t:Names of settlements of the Republic of Belarus: Viciebsk region>",
isbn = "978-985-458-192-7",
pageurl = "https://knihi.com/none/Nazvy_nasielenych_punktau_Respubliki_Bielarus_djvu.zip.html#NNP.Viciebskaja.djvu_"
}
}
-- For the sake of consistency, allow only one way to specify the region. But give a hint
-- to the editor about how to rename it correctly.
local rename_hints = {
["Brest"] = "Брэстчына",
["Mogilev"] = "Магілёўшчына", ["Mahilyow"] = "Магілёўшчына", ["Mahiloŭ"] = "Магілёўшчына", ["Mahilioŭ"] = "Магілёўшчына",
["Gomel"] = "Гомельшчына", ["Homel"] = "Гомельшчына", ["Homiel"] = "Гомельшчына",
["Minsk"] = "Міншчына", ["Miensk"] = "Міншчына", ["Mensk"] = "Міншчына",
["Viciebsk"] = "Віцебшчына", ["Vitsyebsk"] = "Віцебшчына", ["Vitebsk"] = "Віцебшчына",
["Hrodna"] = "Гродзеншчына", ["Grodno"] = "Гродзеншчына",
}
-- Prepare tables
local AC = require("Module:string/char")(0x0301) -- acute = ́
local consonants_set = {}
mw.ustring.gsub("БВГДЖЗКЛМНПРСТФХЦЧШбвгджзклмнпрстфхцчш", ".", function (c) consonants_set[c] = 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[c]
if jejojuja then
if consonants_set[prev_c] then
if lacinka and (prev_c == "Л" or prev_c == "л") then
jejojuja = jejojuja_after_l[c]
else
jejojuja = jejojuja_after_consonant[c]
end
end
prev_c = c
return jejojuja
end
prev_c = c
return tt[c] 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, "([Zz])([BbVvWwZzLlMmNnCc][" .. AC .. "i])", "%1" .. AC .. "%2")
s = mw.ustring.gsub(s, "([Zz])([Dd][Zz][" .. AC .. "i])", "%1" .. AC .. "%2")
s = mw.ustring.gsub(s, "([Ss])([BbVvWwLlMmNnPpFfCc][" .. AC .. "i])", "%1" .. AC .. "%2")
s = mw.ustring.gsub(s, "([Cc])([VvWwMm][" .. AC .. "i])", "%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", ["L"] = "Ł", ["Ĺ"] = "L"})
end
-- done
return s
end
function export.show(frame)
local parent_args = frame:getParent().args
local params = {
[1] = {alias_of = "region"},
[2] = {alias_of = "page"},
[3] = {alias_of = "name"},
["region"] = {required = true},
["page"] = {type = "number"},
["name"] = {},
}
local args = require("Module:parameters").process(parent_args, params)
if not books[args.region] then
if rename_hints[args.region] then
error("The name of the region needs to be changed to: " .. rename_hints[args.region])
end
local errmsg = "Invalid region name. Valid choices are:"
for k, v in pairs(books) do
errmsg = errmsg .. " " .. k
end
error(errmsg)
end
local citation_args = books[args.region]
-- 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.region == "Магілёўшчына" 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[1] = "be"
citation_args.editor = "[[w:be:Валянціна Пятроўна Лемцюгова|Valancina Lemciuhova]]"
citation_args.location = "w:Minsk"
citation_args.publisher = "[[w: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 name = frame.args.name or args.name
if name then
local name_lat = export.romanize(name, "be-Latn-tarask")
local name_geo = export.romanize(name, "UNGEGN")
if name_lat == name_geo then
prefix = "\"" .. name .. "\" aka \"" .. name_lat .. "\"<sup>[[w:Łacinka|Łacinka]] / [https://digitallibrary.un.org/record/4021251?v=pdf UNGEGN]</sup> in "
else
prefix = "\"" .. name .. "\" aka \"" .. name_lat .. "\"<sup>[[w:Łacinka|Łacinka]]</sup> or \"" .. name_geo .. "\"<sup>[https://digitallibrary.un.org/record/4021251?v=pdf UNGEGN]</sup> in "
end
end
return prefix .. frame:expandTemplate {title = "cite-book", args = citation_args}
end
return export