Модуль:Infobox road/locations
Перейти к навигации
Перейти к поиску
Документация
Этому модулю не хватает документации. |
local p = {}
local roadDataModule = require('Module:Road data')
local format = mw.ustring.format
local frame = mw.getCurrentFrame()
local getArgs = require('Module:Arguments').getArgs
local function country(args)
local state = args.state or args.province
local country
local countryModule = mw.loadData("Module:Road data/countrymask")
local country = args.country or countryModule[state]
return country
end
local function state(args)
local state = args.state or args.province
local country = country(args)
return frame:expandTemplate ({title='Country name', args = { country .. "-" .. state}})
end
local function state2(args)
local state = args.state2 or args.province2
local country = country(args)
return frame:expandTemplate ({title='Country name', args = { country .. "-" .. state}})
end
local function spain(args)
local province = args.province or args.community
local communities = {
["AL"] = "AN",
["CA"] = "AN",
["CO"] = "AN",
["GR"] = "AN",
["H"] = "AN",
["J"] = "AN",
["MA"] = "AN",
["SE"] = "AN",
["HU"] = "AR",
["TE"] = "AR",
["Z"] = "AR",
["O"] = "AS",
["S"] = "CB",
["AV"] = "CL",
["BU"] = "CL",
["LE"] = "CL",
["P"] = "CL",
["SA"] = "CL",
["SG"] = "CL",
["SO"] = "CL",
["VA"] = "CL",
["ZA"] = "CL",
["AB"] = "CM",
["CR"] = "CM",
["CU"] = "CM",
["GU"] = "CM",
["TO"] = "CM",
["GC"] = "CN",
["TF"] = "CN",
["B"] = "CT",
["GI"] = "CT",
["L"] = "CT",
["T"] = "CT",
["BA"] = "EX",
["CC"] = "EX",
["C"] = "GA",
["LU"] = "GA",
["OR"] = "GA",
["PO"] = "GA",
["PM"] = "IB",
["MU"] = "MC",
["M"] = "MD",
["NA"] = "NC",
["VI"] = "PV",
["BI"] = "PV",
["SS"] = "PV",
["LO"] = "RI",
["A"] = "VC",
["CS"] = "VC",
["V"] = "VC",
}
local comm = communities[province]
local data = frame:expandTemplate ({title='Flagg', args = { "xx", frame:expandTemplate ({title='Country name', args = { "ESP-" .. comm}}) } })
return data
end
local function constituent(args)
local loc = country(args)
if loc == "GBR" then
return nil
else
local labels = {
["ENG"] = "Составная часть",
["NIR"] = "Составная часть",
["SCT"] = "Составная часть",
["WLS"] = "Составная часть",
["NLD"] = "Составная часть",
["ABW"] = "Составная часть",
["CUW"] = "Составная часть",
["SXM"] = "Составная часть",
["GGY"] = "Crown dependency",
["IMN"] = "Crown dependency",
["JEY"] = "Crown dependency",
["AIA"] = "Overseas territory",
["BMU"] = "Overseas territory",
["IOT"] = "Overseas territory",
["VGB"] = "Overseas territory",
["CYM"] = "Overseas territory",
["FLK"] = "Overseas territory",
["GIB"] = "Overseas territory",
["MSR"] = "Overseas territory",
["PCN"] = "Overseas territory",
["SHN"] = "Overseas territory",
["SGS"] = "Overseas territory",
["TCA"] = "Overseas territory",
}
local label = labels[loc]
local countryname = frame:expandTemplate ({title='Country name', args = { country(args)}})
local data = frame:expandTemplate ({title='Flagg', args = { "xx", countryname }})
return label, data
end
end
local function location(args)
local infobox_args = {}
infobox_args['название'] = 'Расположение'
infobox_args['стиль_тела'] = 'display:inline-table;'
infobox_args['внедрение'] = 'yes'
infobox_args['nocat'] = 'yes'
------------- EUROPE & ASIA --------------
if country(args) == "EUR" or country(args) == "ASIA" then
infobox_args['метка1'] = 'Страны'
infobox_args['текст1'] = args.countries
------------- ÅLAND --------------
elseif country(args) == "ALA" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Finland]]"
infobox_args['метка2'] = 'Autonomous region'
infobox_args['текст2'] = "[[Åland]]"
------------- AUSTRALIA --------------
elseif country(args) == "AUS" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Австралия]]"
local function lga(args)
local labels = {
SA = "[[Local government areas of South Australia|LGA(s)]]",
VIC = "[[Local government in Victoria|LGA(s)]]",
NSW = "[[Local government areas of New South Wales|LGA(s)]]",
QLD = "[[Local government areas of Queensland|LGA(s)]]",
NT = "[[Local government areas of the Northern Territory|LGA(s)]]",
WA = "[[Local government areas of Western Australia|LGA(s)]]",
TAS = "[[Local government areas of Tasmania|LGA(s)]]",
ACT = "District(s)"
}
local state = args.state or ''
local label = labels[state] or "[[Local government in Australia|LGA(s)]]"
return label, args.lga
end
local function locations(args)
local labels = {
highway = "Major settlements",
["rural road"] = "Major settlements",
freeway = "Major suburbs",
["city highway"] = "Major suburbs",
road = "Major suburbs",
street = "Suburb"
}
local type = args.type or ''
local label = labels[type] or "Основные<br>пункты следования"
return label, args.locations
end
if args.state then
if args.state == "NT" or args.state == "ACT" or args.state == "JBT" then
infobox_args['метка2'] = 'Территория'
else
infobox_args['метка2'] = 'State'
end
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
else
infobox_args['метка2'] = 'States'
infobox_args['текст2'] = args.states
end
infobox_args['метка3'], infobox_args['текст3'] = lga(args)
infobox_args['метка4'], infobox_args['текст4'] = locations(args)
------------- BRAZIL --------------
elseif country(args) == "BRA" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Brazil]]"
if args.state then
if args.state == "DF" then
infobox_args['метка2'] = 'Federal district'
else
infobox_args['метка2'] = 'State'
end
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
else
infobox_args['метка2'] = 'States'
infobox_args['текст2'] = args.states
end
------------- CANADA --------------
elseif country(args) == "CAN" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Canada]]"
if args.province then
if args.province == "YK" or args.province == "NT" or args.province == "NU" then
infobox_args['метка2'] = 'Территория'
else
infobox_args['метка2'] = 'Провинция'
end
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
else
infobox_args['метка2'] = 'Провинции'
infobox_args['текст2'] = args.provinces
end
if args.province == 'AB' then
infobox_args['метка3'] = "Specialized and rural municipalities"
infobox_args['текст3'] = args.rural_municipalities
infobox_args['метка4'] = "Special areas"
infobox_args['текст4'] = args.areas
infobox_args['метка5'] = "Improvement districts"
infobox_args['текст5'] = args.districts
elseif args.province == 'BC' then
infobox_args['метка3'] = "Regional districts"
infobox_args['текст3'] = args.districts or args.rural_municipalities
elseif args.province == 'MB' or args.province == 'SK' then
infobox_args['метка3'] = "Rural municipalities"
infobox_args['текст3'] = args.rural_municipalities
elseif args.province == 'NB' or args.province == 'PE' then
infobox_args['метка3'] = "Графства"
infobox_args['текст3'] = args.counties
infobox_args['метка4'] = "Parishes"
infobox_args['текст4'] = args.parishes
elseif args.province == 'NS' then
infobox_args['метка3'] = "Графства"
infobox_args['текст3'] = args.counties
elseif args.province == 'ON' then
infobox_args['метка3'] = "Municipalities"
infobox_args['текст3'] = args.rural_municipalities
infobox_args['метка4'] = "Графства"
infobox_args['текст4'] = args.counties
infobox_args['метка5'] = "Regions"
infobox_args['текст5'] = args.regions
infobox_args['метка6'] = "Districts"
infobox_args['текст6'] = args.districts
infobox_args['метка7'] = "Divisions"
infobox_args['текст7'] = args.divisions
elseif args.province == 'QC' then
infobox_args['метка3'] = "Regional county municipalities"
infobox_args['текст3'] = args.rural_municipalities
infobox_args['метка4'] = "Equivalent territories"
infobox_args['текст4'] = args.territories
elseif args.province == 'NT' or args.province == 'NU' then
infobox_args['метка3'] = "Regions"
infobox_args['текст3'] = args.regions
end
------------- CHINA --------------
elseif country(args) == "CHN" or country(args) == "HKG" or country(args) == "MAC" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[China]]"
if country(args) == "HKG" then
infobox_args['метка2'] = 'Special administrative region'
infobox_args['текст2'] = "[[Hong Kong]]"
infobox_args['метка3'] = 'Районы'
infobox_args['текст3'] = args.districts
elseif country(args) == "MAC" then
infobox_args['метка2'] = 'Special administrative region'
infobox_args['текст2'] = "[[Macau]]"
else
infobox_args['метка2'] = 'Провинции'
infobox_args['текст2'] = args.provinces
infobox_args['метка3'] = 'Autonomous regions'
infobox_args['текст3'] = args.regions
end
------------- FRANCE --------------
elseif country(args) == "FRA" or country(args) == "GUF" or country(args) == "GLP" or country(args) == "MTQ" or country(args) == "MYT" or country(args) == "REU" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[France]]"
if country(args) == "GUF" then
infobox_args['метка2'] = 'Overseas region'
infobox_args['текст2'] = "[[French Guiana]]"
infobox_args['метка3'] = 'Department'
infobox_args['текст3'] = "[[Guyane]]"
elseif country(args) == "GLP" then
infobox_args['метка2'] = 'Overseas region and department'
infobox_args['текст2'] = "[[Guadeloupe]]"
elseif country(args) == "MTQ" then
infobox_args['метка2'] = 'Overseas region and department'
infobox_args['текст2'] = "[[Martinique]]"
elseif country(args) == "MYT" then
infobox_args['метка2'] = 'Overseas region and department'
infobox_args['текст2'] = "[[Mayotte]]"
elseif country(args) == "REU" then
infobox_args['метка2'] = 'Overseas region'
infobox_args['текст2'] = "[[Réunion]]"
infobox_args['метка3'] = 'Department'
infobox_args['текст3'] = "[[La Réunion]]"
else
infobox_args['метка2'] = 'Regions'
infobox_args['текст2'] = args.regions
infobox_args['метка3'] = 'Departments'
infobox_args['текст3'] = args.departments
end
------------- INDIA --------------
elseif country(args) == "IND" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[India]]"
infobox_args['метка4'] = 'Районы'
infobox_args['текст4'] = args.districts
if args.state then
if args.state == "AN" or args.state == 'CH' or args.state == 'DH' or args.state == 'DL' or args.state == 'JK' or args.state == 'LA' or args.state == 'LD' or args.state == 'PY' then
infobox_args['метка2'] = 'Union territory'
else
infobox_args['метка2'] = 'State'
end
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
else
infobox_args['метка2'] = 'States'
infobox_args['текст2'] = args.states
infobox_args['метка3'] = 'Union territories'
infobox_args['текст3'] = args.territories
end
------------- MEXICO --------------
elseif country(args) == "MEX" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Mexico]]"
if args.state then
if args.state == "CMX" then
infobox_args['метка2'] = 'Autonomous city'
else
infobox_args['метка2'] = 'State'
end
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
else
infobox_args['метка2'] = 'States'
infobox_args['текст2'] = args.states
end
------------- NETHERLANDS --------------
elseif country(args) == "NLD" or country(args) == "ABW" or country(args) == "CUW" or country(args) == "SXM"then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Kingdom of the Netherlands]]"
infobox_args['метка2'], infobox_args['текст2'] = constituent(args)
if country(args) == "NLD" then
infobox_args['метка3'] = 'Провинции'
infobox_args['текст3'] = args.provinces
end
------------- RUSSIA --------------
elseif country(args) == "RUS" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Russia]]"
infobox_args['метка2'] = 'Oblasts'
infobox_args['текст2'] = args.oblasts
infobox_args['метка3'] = 'Republics'
infobox_args['текст3'] = args.republics
infobox_args['метка4'] = 'Autonomous okrugs'
infobox_args['текст4'] = args.okrugs
infobox_args['метка5'] = 'Krais'
infobox_args['текст5'] = args.krais
infobox_args['метка6'] = 'Federal cities'
infobox_args['текст6'] = args.federal_cities
------------- SPAIN --------------
elseif country(args) == "ESP" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Spain]]"
local province = args.province
if province and province ~= '' then
infobox_args['метка2'] = 'Autonomous<br>community'
infobox_args['текст2'] = spain(args)
if province == "O" or province == "S" or province == "PM" or province == "LO" or province == "M" or province == "MU" or province == "NA" then
return nil
else
infobox_args['метка3'] = 'Провинция'
infobox_args['текст3'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
end
elseif args.community then
infobox_args['метка2'] = 'Autonomous<br>community'
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , frame:expandTemplate ({title='country name', args = {"ESP-" .. args.community} }) } })
infobox_args['метка3'] = 'Провинции'
infobox_args['текст3'] = args.provinces
else
infobox_args['метка2'] = 'Autonomous<br>communities'
infobox_args['текст2'] = args.communities
infobox_args['метка3'] = 'Провинции'
infobox_args['текст3'] = args.provinces
end
------------- UNITED KINGDOM --------------
elseif country(args) == "GBR" or country(args) == "ENG" or country(args) == "NIR" or country(args) == "SCT" or country(args) == "WLS" or
country(args) == "GGY" or country(args) == "IMN" or country(args) == "JEY" or country(args) == "AIA" or country(args) == "BMU" or
country(args) == "IOT" or country(args) == "VGB" or country(args) == "CYM" or country(args) == "FLK" or country(args) == "GIB" or
country(args) == "MSR" or country(args) == "PCN" or country(args) == "SHN" or country(args) == "SGS" or country(args) == "TCA" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[Великобритания]]"
infobox_args['метка2'], infobox_args['текст2'] = constituent(args)
if country(args) ~= "ENG" then
infobox_args['метка5'] = 'Графства'
infobox_args['текст5'] = args.counties
end
if country(args) == "ENG" then
infobox_args['метка3'] = 'Графства'
infobox_args['текст3'] = args.counties
infobox_args['метка4'] = 'Боро'
infobox_args['текст4'] = args.boroughs
elseif country(args) == "NIR" then
infobox_args['метка3'] = 'Районы'
infobox_args['текст3'] = args.districts
elseif country(args) == "SCT" then
infobox_args['метка3'] = 'Округа'
infobox_args['текст3'] = args.areas
elseif country(args) == "WLS" then
infobox_args['метка3'] = 'Графства'
infobox_args['текст3'] = args.counties
infobox_args['метка4'] = 'Округа'
infobox_args['текст4'] = args.boroughs
elseif country(args) == "GGY" or country(args) == "JEY" or country(args) == "BMU" or country(args) == "MSR" then
infobox_args['метка3'] = 'Приходы'
infobox_args['текст3'] = args.parishes
elseif country(args) == "IMN" then
infobox_args['метка3'] = 'Sheadings'
infobox_args['текст3'] = args.sheadings
elseif country(args) == "AIA" or country(args) == "VGB" or country(args) == "CYM" or country(args) == "TCA" then
infobox_args['метка3'] = 'Районы'
infobox_args['текст3'] = args.districts
elseif country(args) == "SHN" then
infobox_args['метка3'] = 'Остров'
infobox_args['текст3'] = args.island
end
------------- UNITED STATES --------------
elseif country(args) == "USA" then
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = "[[United States]]"
local function county(args)
local state = args.state
local stateName = frame:expandTemplate ({title='Country name', args = { "USA-" .. state}})
local country = country(args)
local countyName = args.county or args.parish or args.borough or args.municipality
local county
if state == 'LA' then
county = 'Приход'
elseif state == 'AK' then
county = 'Боро'
elseif state == 'PR' then
county = 'Муниципалитет'
else
county = 'Графство'
end
return string.format("[[%s %s, %s|%s]]", countyName, county, stateName, countyName)
end
if args.state2 then
infobox_args['метка2'] = 'States'
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} }) .. ", " .. frame:expandTemplate ({title='Flagg', args = {"xx" , state2(args)} })
elseif args.state then
if args.state == "AS" or args.state == "GU" or args.state == "MP" or args.state == "PR" or args.state == "VI" then
infobox_args['метка2'] = 'Территория'
elseif args.state == "DC" then
infobox_args['метка2'] = 'Federal district'
else
infobox_args['метка2'] = 'State'
end
if args.state == "GA" then
infobox_args['текст2'] = '[[Georgia (U.S. state)|Georgia]]'
else
infobox_args['текст2'] = frame:expandTemplate ({title='Flagg', args = {"xx" , state(args)} })
end
else
infobox_args['метка2'] = 'States'
infobox_args['текст2'] = args.states
end
if args.county then
infobox_args['метка3'] = 'Графство'
infobox_args['текст3'] = county(args)
else
infobox_args['метка3'] = 'Графства'
infobox_args['текст3'] = args.counties
end
if args.parish then
infobox_args['метка4'] = 'Приход'
infobox_args['текст4'] = county(args)
else
infobox_args['метка4'] = 'Приходы'
infobox_args['текст4'] = args.parishes
end
if args.borough then
infobox_args['метка5'] = 'Боро'
infobox_args['текст5'] = county(args)
else
infobox_args['метка5'] = 'Боро'
infobox_args['текст5'] = args.boroughs
end
if args.municipality then
infobox_args['метка6'] = 'Муниципалитет'
infobox_args['текст6'] = county(args)
else
infobox_args['метка6'] = 'Муниципалитеты'
infobox_args['текст6'] = args.municipalities
end
if args.indep_city then
infobox_args['метка6'] = 'Независимый город'
infobox_args['текст6'] = args.indep_city
else
infobox_args['метка7'] = 'Независимые города'
infobox_args['текст7'] = args.indep_cities
end
else
------------- ALL OTHER COUNTRIES --------------
if country(args) ~= nil then
local countryname = frame:expandTemplate ({title='Country name', args = { country(args)}})
infobox_args['метка1'] = 'Страна'
infobox_args['текст1'] = frame:expandTemplate ({title='Flagg', args = { "xx", countryname }})
else
infobox_args['метка1'] = 'Страны'
infobox_args['текст1'] = args.countries
end
infobox_args['метка2'] = 'Остров'
infobox_args['текст2'] = args.island
infobox_args['метка3'] = 'Communities'
infobox_args['текст3'] = args.communities
infobox_args['метка4'] = 'Регионы'
infobox_args['текст4'] = args.regions
infobox_args['метка5'] = 'Провинции'
infobox_args['текст5'] = args.provinces
infobox_args['метка6'] = 'Штаты'
infobox_args['текст6'] = args.states
infobox_args['метка7'] = 'Governorates'
infobox_args['текст7'] = args.governorates
infobox_args['метка8'] = 'Графства'
infobox_args['текст8'] = args.counties
infobox_args['метка9'] = 'Департаменты'
infobox_args['текст9'] = args.departments
infobox_args['метка10'] = 'Кантоны'
infobox_args['текст10'] = args.cantons
infobox_args['метка11'] = 'Префектуры'
infobox_args['текст11'] = args.prefectures
infobox_args['метка12'] = 'Divisions'
infobox_args['текст12'] = args.divisions
infobox_args['метка13'] = 'Области'
infobox_args['текст13'] = args.oblasts
infobox_args['метка14'] = 'Районы'
infobox_args['текст14'] = args.districts
infobox_args['метка15'] = 'Приходы'
infobox_args['текст15'] = args.parishes
infobox_args['метка16'] = 'Коммуны'
infobox_args['текст16'] = args.communes
infobox_args['метка17'] = 'Территории'
infobox_args['текст17'] = args.territories
infobox_args['метка18'] = args.label1
infobox_args['текст18'] = args.location1
infobox_args['метка19'] = args.label2
infobox_args['текст19'] = args.location2
infobox_args['метка20'] = args.label3
infobox_args['текст20'] = args.location3
infobox_args['метка21'] = args.label4
infobox_args['текст21'] = args.location4
infobox_args['метка22'] = args.label5
infobox_args['текст22'] = args.location5
infobox_args['метка23'] = 'Субрегионы'
infobox_args['текст23'] = args.subregions
infobox_args['метка24'] = 'Субграфства'
infobox_args['текст24'] = args.subcounties
infobox_args['метка25'] = 'Субпрефектуры'
infobox_args['текст25'] = args.subprefectures
end
if country(args) ~= "USA" then
infobox_args['метка26'] = 'Муниципалитеты'
infobox_args['текст26'] = args.municipalities
infobox_args['метка27'] = 'Города'
infobox_args['текст27'] = args.cities
infobox_args['метка28'] = 'Малые города'
infobox_args['текст28'] = args.towns
infobox_args['метка29'] = 'Деревни'
infobox_args['текст29'] = args.villages
-- if country(args) == "GBR" or country(args) == "ENG" or country(args) == "NIR" or country(args) == "SCT" or country(args) == "WLS" or
-- country(args) == "GGY" or country(args) == "IMN" or country(args) == "JEY" or country(args) == "AIA" or country(args) == "BMU" or
-- country(args) == "IOT" or country(args) == "VGB" or country(args) == "CYM" or country(args) == "FLK" or country(args) == "GIB" or
-- country(args) == "MSR" or country(args) == "PCN" or country(args) == "SHN" or country(args) == "SGS" or country(args) == "TCA" then
--
-- infobox_args['метка30'] = '[[Primary status|Primary<br>destinations]]'
-- infobox_args['текст30'] = args.destinations
-- else
infobox_args['метка30'] = 'Основные<br>пункты следования'
infobox_args['текст30'] = args.destinations
-- end
end
return frame:expandTemplate ({title='Infobox/песочница', args = infobox_args})
end
local function params(args)
if country(args) or args.areas or args.borough or args.boroughs or args.cantons or args.cities or args.communes or args.communities or args.counties or
args.countries or args.county or args.departments or args.destinations or args.districts or args.divisions or args.federal_cities or args.governorates or
args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or
args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or
args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or
args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories or args.towns or args.villages then
return true
else
return false
end
end
function p.location(frame)
local args = getArgs(frame)
if params(args) == false then
return nil
else
return location(args)
end
end
return p