| Thismodule is rated asready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned onhelp pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed throughsandbox testing rather than repeated trial-and-error editing. |
| This module is currently under extended confirmed protection. Extended confirmed protection prevents edits from all unregistered editors and registered users with fewer than 30 days tenure and 500 edits. Thepolicy on community use specifies that extended confirmed protection can be applied to combat disruption, if semi-protection has proven to be ineffective. Extended confirmed protection may also be applied to enforcearbitration sanctions. Please discuss any changes on thetalk page; you maysubmit an edit request to ask for uncontroversial changes supported byconsensus. |
{{#invoke:Slovak municipality|function_name}}
Get statistic data about Slovak municipalities.
This template is a sibling ofTemplate:Slovak municipality.
This template use the data from CC-BY database.
Original first author:Dušan Kreheľ.
Reference implementation is on hrwiki.
| Meaning | Parameter | Code | Code output |
|---|---|---|---|
| Population | p | {{#invoke:Slovak municipality|sk|p|SK0417524395}} | 2550 |
| Population (source URL) | P | {{#invoke:Slovak municipality|sk|P|SK0417524395}}<br>{{#invoke:Slovak municipality|sk|P|SK}}<br>{{#invoke:Slovak municipality|sk|P|SK0106}} | https://datacube.statistics.sk/#!/view/sk/vbd_dem/om7101rr/v_om7101rr_00_00_00_sk https://datacube.statistics.sk/#!/view/sk/vbd_dem/om7102rr/v_om7102rr_00_00_00_sk https://datacube.statistics.sk/#!/view/sk/vbd_dem/om7102rr/v_om7102rr_00_00_00_sk |
| Population (ex. for table) | p | {{#invoke:Slovak municipality|sk|o|SK0417524395}} | 2,550 |
| Population Id | r | {{#invoke:Slovak municipality|sk|r|SK0417524395}} | om7101rr |
| Area | a | {{#invoke:Slovak municipality|sk|a|SK0417524395}} | 11.24 |
| Area (source URL) | A | {{#invoke:Slovak municipality|sk|A|SK0417524395}} | https://datacube.statistics.sk/#!/view/sk/vbd_dem/om7014rr/v_om7014rr_00_00_00_sk |
| Area Id | b | {{#invoke:Slovak municipality|sk|b|SK0417524395}} | om7014rr |
| Population density (as population/area) | d | {{#invoke:Slovak municipality|sk|d}} | 226.78 |
| Data year | y | {{#invoke:Slovak municipality|sk|y}} | |
| Last acces | l | {{#invoke:Slovak municipality|sk|l}} | |
| Last update | u | {{#invoke:Slovak municipality|sk|u}} | |
| Is slovak municipality (none support %i) | i | {{#invoke:Slovak municipality|sk|i|SK0417524395}} | 1 |
| Get NUTS/LAU code (none support %e) | e |
You can used both the format string likeprintf() with parameters from table.
| Code: | {{#invoke:Slovak municipality|sk|%p (source: %P)|SK0417524395}} |
| Output: | 2550 (source:https://datacube.statistics.sk/#!/view/sk/vbd_dem/om7101rr/v_om7101rr_00_00_00_sk |
It is a STUN or LAU code for place sup-place (ex.SK0417524395). If none, then code is automatic based on the actual page.
-- Project "[[:wikidata:Q132395970|Module:SK]]"localsk={}sk.error_place="Unknown place."sk.error_code="Unknown password."sk.decimal_separator="."sk.thousands_separator=","sk.percentage_delimer=""sk.percent_first_value=truesk.year_suffix=""sk.minus="−"sk.open_th="<th>"sk.open_td="<td>"sk.none_value="–"sk.religion_table_language="en"sk.population_notice_title="Note on population"sk.population_notice="The difference between the population numbers above and in the census (here and below) is that the population numbers above are mostly made up of permanent residents, etc.; and the census should indicate the place where people actually mainly live.<br>For example, a student is a citizen of a village because he has permanent residence there (he lived there as a child and has parents), but most of the time he studies at a university in the city."sk.religion_table_percent_plus=1sk.table_class="wikitable sortable"sk.religion_header='<tr><th>Religion</th><th>Number</th><th>Fraction</th></tr>'sk.etno_header='<tr><th>Ethnicity</th><th>Number</th><th>Fraction</th></tr>'sk.religion_caption_ref="{{cite web| title=Population - Basic results| publisher=Statistical Office of the Slovak republic|url=LINK| accessdate=2025-11-03|website= www.scitanie.sk}}"sk.religion_caption='Census YEAR (1+ %)REFERENCE'sk.etno_caption='Census YEAR (1+ %)REFERENCES'sk.etno_relig_interval_notice="Sum of %s–%s."sk.etno_relig_text=truesk.etno_relig_text_content_etno="In year %s was %s people by ethnicity %s."sk.etno_relig_text_content_relig="In year %s was %s people by religion %s."sk.etno_relig_text_item_etno="DELIMER NUMBER as NAME"sk.etno_relig_text_item_relig="DELIMER NUMBER from NAME"sk.etno_relig_text_delimer=", "sk.etno_relig_text_delimer_end=" and "sk.etno_relig_links_table=truesk.etno_relig_links_text=truefunctionsk.etno_table(args)localall_translateslocalcaptionlocalcaption_noticelocalcaption_ref_firstlocalcaption_ref_secondlocaldatasetlocaldataset_grouplocaletno_relig_contentlocaletno_relig_item_headlocaletno_relig_item_contentlocaletno_relig_itemslocaletno_relig_items_contentlocalitem_countlocallabel_rawlocallau=args.args[1]locallau_lengthlocallua_lengthlocalmax_valuelocaloendlocalostartlocalpercentlocalplacelocalplace_valueslocalprefix_keylocalref_urllocalref_url_secondlocalselect_prefixlocaltranslatelocaltranslate_keylocaltranslate_key_termlocaltranslateslocaltranslates_linkslocaltype_percentlocalwikilocalyeariflau==""thenlau=sk.get_nuts_lua()end-- Select translates --all_translates=mw.ext.data.get("Translates of Population ethnicities of Slovak municipalities.tab")translates={}translates_links={}select_prefix=sk.religion_table_language..":"fori,itemsinipairs(all_translates["data"])doprefix_key=string.sub(items[1],1,3);ifprefix_key==select_prefixthentranslates[items[1]]=items[2]translates_links[items[1]]=items[3]endend-- Datasetslau_length=string.len(lau)iflau_length==12thendataset_group=tonumber(string.sub(lau,4,4));ifnotdataset_groupthenreturn""endifdataset_group<3thendataset=mw.ext.data.get("Population ethnicities of Slovak municipalities (SK01 and SK02; last census).tab")elseifdataset_group==3thendataset=mw.ext.data.get("Population ethnicities of Slovak municipalities (SK03, last census).tab")elsedataset=mw.ext.data.get("Population ethnicities of Slovak municipalities (SK04, last census).tab")endendelsedataset=mw.ext.data.get("Population ethnicities of Slovak supmunicipalities (last census).tab")end-- Place value statisticplace_values=falsefori,itemsinipairs(dataset["data"])doifitems[1]==lauthenplace_values=itemsbreakendendifplace_values==falsethenreturn""end-- Place statisticplace={}place['values']={}place['percents']={}fori,itemsinipairs(dataset["schema"]["fields"])doifi>2thenlabel_raw=items["title"]ifnotlabel_rawthenlabel_raw=items["title"]["sk"]endtype_percent=falsetranslate_key=sk.religion_table_language..":"..label_rawtranslate_key_term=translate_keyostart,oend=string.find(translate_key_term," %(%%%)")ifostartthentype_percent=truetranslate_key_term=string.sub(translate_key_term,1,ostart-1)end--translate=translates[translate_key_term]translate=string.sub(translate_key_term,4)iftranslatetheniftype_percentthenplace['percents'][translate]=place_values[i]elsetable.insert(place['values'],{tostring(translate),place_values[i]})endendendend-- Sort by valuetable.sort(place['values'],function(v,w)ifv[2]==w[2]thenreturnv[1]>w[1]endreturnv[2]>w[2]end)-- Table constructionostart,oend=string.find(dataset["sources"],"the year ")year=string.sub(dataset["sources"],ostart+9,ostart+12);lau_length=string.len(lau)iflau=="SK0422_0425"orlau=="SK_CAP"theniflau=="SK_CAP"thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-ethnicity/KR/SK010/OK"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-another-ethnicity/KR/SK010/OK"elseref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-ethnicity/KR/SK042/OK"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-another-ethnicity/KR/SK042/OK"endelseif(lau_length==3)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-ethnicity/SR/SK0/SR"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-another-ethnicity/SR/SK0/SR"elseif(lau_length==5)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-ethnicity/KR/"..lau.."/KR"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-another-ethnicity/KR/"..lau.."/KR"elseif(lau_length==6)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-ethnicity/OK/"..lau.."/OK"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-another-ethnicity/OK/"..lau.."/OK"elseif(lau_length==12)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-ethnicity/OB/"..lau.."/OB"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-another-ethnicity/OB/"..lau.."/OB"endendendendendcaption_ref_first=string.gsub(sk.religion_caption_ref,"LINK",ref_url)caption_ref_first=args:callParserFunction("#tag","ref",caption_ref_first)caption_ref_second=string.gsub(sk.religion_caption_ref,"LINK",ref_url_second)caption_ref_second=args:callParserFunction("#tag","ref",caption_ref_second)caption_notice=""iflau=="SK0422_0425"orlau=="SK_CAP"theniflau=="SK0422_0425"thencaption_notice=string.format(sk.etno_relig_interval_notice,"SK0422","SK0425")elsecaption_notice=string.format(sk.etno_relig_interval_notice,"SK0101","SK0105")endcaption_notice=args:callParserFunction("#tag","ref",caption_notice)endcaption=string.gsub(sk.etno_caption,"REFERENCES",caption_ref_first..caption_ref_second..caption_notice)caption=string.gsub(caption,"YEAR",year)wiki='<table class="'..sk.table_class..'"><caption>'..caption..'</caption>'..sk.etno_headermax_value=-1item_count=0;fori,vinipairs(place['values'])doifv[2]>max_valuethenmax_value=v[2]endifv[2]~=0thenitem_count=item_count+1endpercent=place['percents'][v[1]]ifnotpercentthenpercent=0endifpercent>=sk.religion_table_percent_plusthenifpercentthenpercent=sk.localised_number(tostring(percent))elsepercent=""endifsk.percent_first_valuethenpercent=percent..sk.percentage_delimer.."%"elsepercent="%"..sk.percentage_delimer..percentendifsk.etno_relig_links_tablethentranslate=translates_links[sk.religion_table_language..":"..v[1]]iftranslate==""thentranslate=translates[sk.religion_table_language..":"..v[1]]endelsetranslate=translates[sk.religion_table_language..":"..v[1]]endwiki=wiki.."<tr><td>"..translate.."</td><td>"..sk.localised_number(tostring(v[2])).."</td><td>"..percent.."</td></tr>"endenditem_count=item_count-1-- suma outtranslate=translates[sk.religion_table_language..":Spolu"]wiki=wiki.."<tr><td>"..translate.."</td><td>"..sk.localised_number(max_value).."</td></tr></table>"-- Etno/relig textifsk.etno_relig_text==falsethenwiki=wiki.."\n:<small><table role=\"presentation\" class=\"wikitable mw-collapsible mw-collapsed\"><tr><th style=\"color:grey !important\">"..sk.population_notice_title.."</th></tr><tr><td>"..sk.population_notice.."</td></tr></table></small>\n\n"doreturnwikiendendetno_relig_items="";fori,vinipairs(place['values'])do-- v = {place, count}ifv[2]>0andi>1then-- first is suma of all that it's skeepingifi>2thenitem_count=item_count-1ifitem_count==1thenetno_relig_item_head=sk.etno_relig_text_delimer_endelseetno_relig_item_head=sk.etno_relig_text_delimerendelseetno_relig_item_head=""endetno_relig_item_content=sk.etno_relig_text_item_etnoifsk.etno_relig_links_textthentranslate=translates_links[sk.religion_table_language..":"..v[1]]iftranslate==""thentranslate=translates[sk.religion_table_language..":"..v[1]]endelsetranslate=translates[sk.religion_table_language..":"..v[1]]endetno_relig_item_content=string.gsub(etno_relig_item_content,"DELIMER",etno_relig_item_head)etno_relig_item_content=string.gsub(etno_relig_item_content,"NUMBER",sk.localised_number(tostring(v[2])))etno_relig_item_content=string.gsub(etno_relig_item_content,"NAME",translate)etno_relig_items=etno_relig_items..etno_relig_item_contentendendwiki=wiki..string.format(sk.etno_relig_text_content_etno,year,sk.localised_number(max_value),etno_relig_items)wiki=wiki.."\n:<small><table role=\"presentation\" class=\"wikitable mw-collapsible mw-collapsed\"><tr><th style=\"color:grey !important\">"..sk.population_notice_title.."</th></tr><tr><td>"..sk.population_notice.."</td></tr></table></small>\n\n"returnwikiendfunctionsk.religion_table(args)localall_translateslocalcaptionlocalcaption_noticelocalcaption_reflocalcaption_ref_firstlocaldatasetlocaldataset_grouplocalitem_countlocallabel_rawlocallau=args.args[1]locallau_lengthlocalmax_valuelocaloendlocalostartlocalpercentlocalplacelocalplace_valueslocalprefix_keylocalref_urllocalref_url_secondlocalselect_prefixlocaltranslatelocaltranslate_keylocaltranslate_key_termlocaltranslateslocaltranslates_linkslocaltype_percentlocalwikilocalyeariflau==""thenlau=sk.get_nuts_lua()end-- Select translates --all_translates=mw.ext.data.get("Translates of Religious belief of Slovak municipalities.tab")translates={}translates_links={}select_prefix=sk.religion_table_language..":"fori,itemsinipairs(all_translates["data"])doprefix_key=string.sub(items[1],1,3);ifprefix_key==select_prefixthentranslates[items[1]]=items[2]translates_links[items[1]]=items[3]endend-- Datasetslau_length=string.len(lau)iflau_length==12thendataset_group=string.sub(lau,4,4);ifnotdataset_groupthenreturn""endiftonumber(dataset_group)>2thendataset=mw.ext.data.get("Religious belief of Slovak municipalities (SK03 and SK04; last census).tab")elsedataset=mw.ext.data.get("Religious belief of Slovak municipalities (SK01 and SK02; last census).tab")endelsedataset=mw.ext.data.get("Religious belief of Slovak supmunicipalities (last census).tab")end-- Place value statisticplace_values=falsefori,itemsinipairs(dataset["data"])doifitems[1]==lauthenplace_values=itemsbreakendendifplace_values==falsethenreturn"hodnoty miest"end-- Place statisticplace={}place['values']={}place['percents']={}fori,itemsinipairs(dataset["schema"]["fields"])doifi>2thenlabel_raw=items["title"]ifnotlabel_rawthenlabel_raw=items["title"]["sk"]endtype_percent=falsetranslate_key=sk.religion_table_language..":"..label_rawtranslate_key_term=translate_keyostart,oend=string.find(translate_key_term," %(%%%)")ifostartthentype_percent=truetranslate_key_term=string.sub(translate_key_term,1,ostart-1)endtranslate_key_term=string.gsub(translate_key_term," %(abs%.%)","")--translate=translates[translate_key_term]translate=string.sub(translate_key_term,4)iftranslatetheniftype_percentthenplace['percents'][translate]=place_values[i]elsetable.insert(place['values'],{translate,place_values[i]})endendendend-- Sort by valuetable.sort(place['values'],function(v,w)ifv[2]==w[2]thenreturnv[1]>w[1]endreturnv[2]>w[2]end)-- Table constructionostart,oend=string.find(dataset["sources"],"the year ")year=string.sub(dataset["sources"],ostart+9,ostart+12);lau_length=string.len(lau)iflau=="SK0422_0425"orlau=="SK_CAP"theniflau=="SK_CAP"thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/KR/SK010/OK"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/KR/SK010/OK"elseref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/KR/SK042/OK"ref_url_second="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/KR/SK042/OK"endelseif(lau_length==3)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/SR/SK0/SR"elseif(lau_length==5)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/KR/"..lau.."/KR"elseif(lau_length==6)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/OK/"..lau.."/OK"elseif(lau_length==12)thenref_url="https://www.scitanie.sk/en/population/basic-results/structure-of-population-by-religious-belief/OB/"..lau.."/OB"endendendendendcaption_ref_first=string.gsub(sk.religion_caption_ref,"LINK",ref_url)caption_ref=args:callParserFunction("#tag","ref",caption_ref_first)caption=string.gsub(sk.religion_caption,"REFERENCE",caption_ref)caption=string.gsub(caption,"YEAR",year)caption_notice=""iflau=="SK0422_0425"orlau=="SK_CAP"theniflau=="SK0422_0425"thencaption_notice=string.format(sk.etno_relig_interval_notice,"SK0422","SK0425")elsecaption_notice=string.format(sk.etno_relig_interval_notice,"SK0101","SK0105")endcaption_notice=args:callParserFunction("#tag","ref",caption_notice)endwiki='<table class="'..sk.table_class..'"><caption>'..caption..caption_notice..'</caption>'..sk.religion_headermax_value=-1item_count=0;fori,vinipairs(place['values'])doifv[2]>max_valuethenmax_value=v[2]endifv[2]~=0thenitem_count=item_count+1endpercent=place['percents'][v[1]]ifnotpercentthenpercent=0endifpercent>=sk.religion_table_percent_plusthenifpercentthenpercent=sk.localised_number(tostring(percent))elsepercent=""endifsk.percent_first_valuethenpercent=percent..sk.percentage_delimer.."%"elsepercent="%"..sk.percentage_delimer..percentendifsk.etno_relig_links_tablethentranslate=translates_links[sk.religion_table_language..":"..v[1]]iftranslate==""thentranslate=translates[sk.religion_table_language..":"..v[1]]endelsetranslate=translates[sk.religion_table_language..":"..v[1]]endwiki=wiki.."<tr><td>"..translate.."</td><td>"..sk.localised_number(tostring(v[2])).."</td><td>"..percent.."</td></tr>"endenditem_count=item_count-1-- suma outtranslate=translates[sk.religion_table_language..":Spolu"]wiki=wiki.."<tr><td>"..translate.."</td><td>"..sk.localised_number(max_value).."</td></tr></table>"-- Etno/relig textifsk.etno_relig_text==falsethendoreturnwikiendendetno_relig_items="";fori,vinipairs(place['values'])do-- v = {place, count}ifv[2]>0andi>1then-- first is suma of all that it's skeepingifi>2thenitem_count=item_count-1ifitem_count==1thenetno_relig_item_head=sk.etno_relig_text_delimer_endelseetno_relig_item_head=sk.etno_relig_text_delimerendelseetno_relig_item_head=""endetno_relig_item_content=sk.etno_relig_text_item_religtranslate=translates[sk.religion_table_language..":m:"..v[1]]ifnottranslatethenifsk.etno_relig_links_textthentranslate=translates_links[sk.religion_table_language..":"..v[1]]iftranslate==""thentranslate=translates[sk.religion_table_language..":"..v[1]]endelsetranslate=translates[sk.religion_table_language..":"..v[1]]endendetno_relig_item_content=string.gsub(etno_relig_item_content,"DELIMER",etno_relig_item_head)etno_relig_item_content=string.gsub(etno_relig_item_content,"NUMBER",sk.localised_number(tostring(v[2])))etno_relig_item_content=string.gsub(etno_relig_item_content,"NAME",translate)etno_relig_items=etno_relig_items..etno_relig_item_contentendendwiki=wiki..string.format(sk.etno_relig_text_content_relig,year,sk.localised_number(max_value),etno_relig_items)returnwikiendfunctionsk.table_list(args)localplaces=args.args[1]localitems=mw.text.split(places,";",true)localoutput=""localdata=falselocaldata_sup=falselocalcustom_text=falselocallabellocallaulocalrecordlocalpopulationlocallang=mw.language.getContentLanguage()fori,iteminipairs(items)dolabel=""custom_text=string.find(item,"::")ifcustom_textthenlabel=string.sub(item,custom_text+2)lau=string.sub(item,1,custom_text-1)endifstring.len(lau)==12thenifnotdatathendata=mw.ext.data.get("Statistics of Slovak municipalities.tab")endrecord=sk.get_line_data(data,lau)elseifnotdata_supthendata_sup=mw.ext.data.get("Statistics of Slovak supmunicipalities.tab")endrecord=sk.get_line_data(data_sup,lau)endpopulation=record[2]area=record[3]output=output.."<tr><td>"..label.."</td><td>"..sk.localised_number(area).."</td><td>"..lang:formatNum(population).."</td></tr>\n"endreturnoutputendfunctionsk.get_nuts_lua()localplace_infolocalnuts_laucode=mw.wikibase.getEntityIdForCurrentPage()ifcode==nilthenreturnnilend-- Source of 2 codes: https://commons.wikimedia.org/w/index.php?title=Data:Statistics_of_Slovak_supmunicipalities.tab&oldid=1001162094ifcode=="Q1780"thenreturn"SK_CAP"endifcode=="Q25409"thenreturn"SK0422_0425"endifcode=="Q214"thenreturn"SK0"endifcode=="SK"thenreturn"SK0"endwhile1doplace_info=mw.wikibase.getBestStatements(code,"P605")ifplace_info[1]==nilthenbreakendnuts_lau=place_info[1]["mainsnak"]['datavalue']['value']ifnuts_lau==nilthenelsereturnnuts_lauendbreakendwhile1doplace_info=mw.wikibase.getBestStatements(code,"P782")ifplace_info[1]==nilthenbreakendnuts_lau=place_info[1]["mainsnak"]['datavalue']['value']ifnuts_lau==nilthenelsereturnnuts_lauendbreakendreturnnilendfunctionsk.is_slovak(args)localnuts_lau=args.args[1]ifnuts_lau==nilornuts_lau==""thennuts_lau=sk.get_nuts_lua()ifnuts_lau==nilthenreturn""endendifstring.sub(nuts_lau,1,2)=="SK"thenreturn"1"endreturn""endfunctionsk.localised_number(number)localnumber2localoffsetlocaloffset_endlocalfirstlocalsecondlocalfirst_lengthlocalOutputnumber2=tostring(number)offset,offset_end=string.find(number2,"%.")ifoffset==nilthenfirst=numbersecond=""elsefirst=string.sub(number2,1,offset-1)second=sk.decimal_separator..string.sub(number2,offset+1,offset+2)endiffirst==nilthenfirst=""endfirst_length=string.len(first)if(first_length<=4)thenreturnfirst..secondendOutput=string.sub(first,-3,-1)if(first_length>3)thenOutput=string.sub(first,-6,-4)..sk.thousands_separator..Outputendif(first_length>6)thenOutput=string.sub(first,-9,-7)..sk.thousands_separator..Outputendif(first_length>9)thenOutput=string.sub(first,-12,-10)..sk.thousands_separator..Outputendifsecond==nilthenreturnOutputelsereturnOutput..secondendendfunctionsk.delta_progress(count_a,count_b)-- count_a < count_bifcount_a==0orcount_b==0thenreturn"–"endlocalvaluevalue=tostring(count_b/(count_a/100)-100)ifstring.sub(value,1,1)=="-"thenvalue_string=string.sub(value,2)value=sk.minus..sk.localised_number(value_string)elsevalue="+"..sk.localised_number(value)endifsk.percent_first_valuethenvalue=value..sk.percentage_delimer.."%"elsevalue="%"..sk.percentage_delimer..valueendreturnvalueendfunctionsk.get_line_data(data,nuts_lau)index=1while1doitem=data.data[index]ifitem==nilthenbreakendifitem[1]==nuts_lauthenbreakendindex=index+1endifitem==nilthenmw.addWarning(sk.error_place)endreturnitemendfunctionsk.constant_code(code)ifcode==nilthenreturnnilendifstring.len(code)==2then-- Source of 2 codes: https://commons.wikimedia.org/w/index.php?title=Data:Statistics_of_Slovak_supmunicipalities.tab&oldid=1001162094ifcode=="BA"thenreturn"SK_CAP"endifcode=="KE"thenreturn"SK0422_0425"endifcode=="SK"thenreturn"SK0"endendreturncodeend-- Reference data are for populationfunctionsk.population_table(args)localstyle=args.args[1]-- formatlocalnuts_lau=args.args[2]-- nuts / LAU, default: automaticlocalcount_yearslocalcount_years_stoplocaldatalocalheadlocalindexlocalitemlocali_startlocali_endlocaltextlocalone_step_yearlocalone_step_valueslocalvaluelocalvalue_stringlocalyearlocalyears={}nuts_lau=sk.constant_code(nuts_lau)-- get NUTS/LUA for pageifnuts_lau==nilornuts_lau==""thennuts_lau=sk.get_nuts_lua()ifnuts_lau==nilthenreturn""endend-- select date lineifstring.len(nuts_lau)==12thendata=mw.ext.data.get("Population statistic of Slovak municipalities (some years).tab")elsedata=mw.ext.data.get("Population statistic of Slovak supmunicipalities (some years).tab")end-- get yearshead=""text=data.sourcesi_start,i_end=string.find(text,"years: ")offset=i_start+7count_years=0while1doyear=string.sub(text,offset,offset+3)count_years=count_years+1years[count_years]=yearifstring.sub(text,offset+4,offset+4)==" "thenoffset=offset+7breakendoffset=offset+6endyear=string.sub(text,offset,offset+3)count_years=count_years+1years[count_years]=yearcount_years_stop=count_years+1head=""fori=2,count_years_stopdoyear_index=i-1while1doifyear_index+1<count_years_stopthenif(years[year_index]-years[year_index+1])==-1thenbreakendendhead=head..sk.open_th..years[year_index]..sk.year_suffix.."</th>"breakendendifstyle=="h"thenreturnheadend-- valuesitem=sk.get_line_data(data,nuts_lau)ifitem==nilthenmw.addWarning(sk.error_place)end-- get valuescontent=""ifstyle=="d"orstyle=="Y"orstyle=="V"orstyle=="P"thenone_step_year=""one_step_values=""one_step_progress=""content="<td></td>\n"fori=3,count_years_stopdoyear_index=i-1while1do-- check the first item with delta = 1ifyear_index+1<count_years_stopthenif(years[year_index]-years[year_index+1])==-1thenone_step_year=one_step_year..sk.open_th..years[year_index]..sk.year_suffix.."</th>"one_step_values=one_step_values..sk.open_td..sk.localised_number(item[i]).."</td>"one_step_progress=one_step_progress.."<td></td>"breakendend-- check the second item with delta = 1ifyear_index>1thenif(years[year_index]-years[year_index-1])==1thenone_step_year=one_step_year..sk.open_th..years[year_index]..sk.year_suffix.."</th>"one_step_values=one_step_values..sk.open_td..sk.localised_number(item[i]).."</td>"one_step_progress=one_step_progress..sk.open_td..sk.delta_progress(item[i-1],item[i]).."</td>"content=content..sk.open_td..sk.delta_progress(item[i-2],item[i]).."</td>\n"breakendendcontent=content..sk.open_td..sk.delta_progress(item[i-1],item[i]).."</td>\n"breakendendifstyle=="Y"thenreturnone_step_yearendifstyle=="V"thenreturnone_step_valuesendifstyle=="P"thenreturnone_step_progressendreturncontentendcontent=""fori=2,count_years_stopdoyear_index=i-1while1doifyear_index+1<count_years_stopthenif(years[year_index]-years[year_index+1])==-1thenbreakendendcontent=content..sk.open_td..sk.localised_number(item[i]).."</td>"breakendendreturncontentendfunctionsk.sk(args)localstyle=args.args[1]-- formatlocalnuts_lau=args.args[2]-- nuts / LAU, default: automaticlocalcodelocaldatalocalindexlocalinfolocalitemlocali_startlocali_start2locali_endlocallanglocallast_acceslocallast_updatelocalplace_infolocalurl_populationlocalurl_arealocalyearlang=mw.language.getContentLanguage()-- select date linenuts_lau=sk.constant_code(nuts_lau)ifnuts_lau==nilornuts_lau==""thennuts_lau=sk.get_nuts_lua()ifnuts_lau==nilthenreturn""endendifstyle=="i"thenlocalparameters={args={nuts_lau}}returnsk.is_slovak(parameters)endifstyle=="e"theni_start,i_end=string.find(nuts_lau,"_")ifi_start==nilthenreturnnuts_lauelsereturn""endend-- select date lineifstring.len(nuts_lau)==12thendata=mw.ext.data.get("Statistics of Slovak municipalities.tab")elsedata=mw.ext.data.get("Statistics of Slovak supmunicipalities.tab")end-- get NUTS/LUA for pageifstyle=="l"orstyle=="u"orstyle=="y"thenelseitem=sk.get_line_data(data,nuts_lau)ifitem==nilthenmw.addWarning(sk.error_place)endend-- yeari_start,i_end=string.find(data.sources,"year: ")year=string.sub(data.sources,i_start+6,i_start+9)-- last accesi_start,i_end=string.find(data.sources,"acces: ")ifi_start==niltheni_start,i_end=string.find(data.sources,"access: ")last_acces=string.sub(data.sources,i_start+8,i_start+17)elselast_acces=string.sub(data.sources,i_start+7,i_start+16)end-- last updatei_start,i_end=string.find(data.sources,"update: ")last_update=string.sub(data.sources,i_start+8,i_start+17)-- url_populationi_start,i_end=string.find(data.sources,"http")i_start2,i_end=string.find(string.sub(data.sources,i_start)," ")i_start2=i_start+i_start2-1url_population=string.sub(data.sources,i_start,i_start2)-- url_areai_start,i_end=string.find(data.sources,"http")info=string.sub(data.sources,i_start+1)i_start,i_end=string.find(info,"http")i_start2,i_end=string.find(string.sub(info,i_start)," ")i_start2=i_start+i_start2-1url_area=string.sub(info,i_start,i_start2)-- population_idi_start,i_end=string.find(url_population,"/vbd_dem/")info=string.sub(url_population,i_start+9)i_start,i_end=string.find(info,"/")population_id=string.sub(info,1,i_start-1)-- area_idi_start,i_end=string.find(url_area,"/vbd_dem/")info=string.sub(url_area,i_start+9)i_start,i_end=string.find(info,"/")area_id=string.sub(info,1,i_start-1)-- renderi_start,i_end=string.find(style,"%%")ifi_start==nilthenifstyle=="p"orstyle=="o"orstyle=="d"thenifitem[2]thenifstyle=="p"thenreturnsk.localised_number(item[2])endifstyle=="o"thenreturnlang:formatNum(item[2])endifstyle=="d"thenifitem[2]~=0thenifitem[3]anditem[3]~=0thenreturnsk.localised_number(item[2]/item[3])endendendendreturnsk.none_valueendifstyle=="a"thenifitem[3]thenreturnsk.localised_number(item[3])elsereturnsk.none_valueendendifstyle=="P"thenreturnurl_populationendifstyle=="A"thenreturnurl_areaendifstyle=="y"thenreturnyearendifstyle=="l"thenreturnlast_accesendifstyle=="u"thenreturnlast_updateendifstyle=="r"thenreturnpopulation_idendifstyle=="b"thenreturnarea_idendmw.addWarning(sk.error_code)elseOutput=styleOutput=string.gsub(Output,"%%p",sk.localised_number(item[2]))Output=string.gsub(Output,"%%P",url_population)Output=string.gsub(Output,"%%a",sk.localised_number(item[3]))Output=string.gsub(Output,"%%o",lang:formatNum(item[2]))Output=string.gsub(Output,"%%A",url_area)localdensity;ifitem[2]==niloritem[2]==0thendensity=sk.none_value;elsedensity=sk.localised_number(item[2]/item[3])endOutput=string.gsub(Output,"%%d",density)Output=string.gsub(Output,"%%y",year)Output=string.gsub(Output,"%%l",last_acces)Output=string.gsub(Output,"%%u",last_update)Output=string.gsub(Output,"%%r",population_id)Output=string.gsub(Output,"%%b",area_id)returnOutputendendreturnsk