Jump to content

Module talk:Country population

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Static Row Numbers

[edit]

Hey, Jts1882, would {{srn}} be useful in this module? โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐š (talk) 21:59, 2 May 2021 (UTC)[reply]

ย Done
FYI, you can't just add templates or tags to wikitext output generated in a module, as they won't expand properly. You need to use frame:expandTemplate or frame:extensionTag
P.S. I don't think the template {{srn}} is a good idea. It's to short to make it clear what it does and looks like one of the short note citation template, which could confuse people. Better to use the full template name which gives an indication of what it is doing. โ€”ย ย Jts1882ย |ย talkย  08:56, 5 May 2021 (UTC)[reply]
Ok. โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐š (talk) 09:06, 5 May 2021 (UTC)[reply]

Bottom alignment

[edit]

Jts1882: Rows seem to be valigned to the bottom. I had a look at the code, and could only find bottom alignment for the header row, which is fine. โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐š (talk) 01:07, 5 May 2021 (UTC)[reply]

Flaglist vs Flagcountry

[edit]

Jts1882: Wouldn't {{flaglist}} be better for alignment than {{flagcountry}} here? โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐š (talk) 01:28, 5 May 2021 (UTC)[reply]

Template wrapper

[edit]

I started a template wrapper for this module bc I wanted to pass the list of countries as a template (like the {{List of countries in South America}}), bc the MW engine processes modules before templates. The main function here is commented with called from template, but I got stuck passing through the arguments. Did you already create the template you referred to there, Jts1882, or can you help me beat that one into shape? Cheers. โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐šย โ˜Ž 08:17, 13 June 2021 (UTC)[reply]

The main() function wasn't doing anything. The module was using p.populations().
When a module is called directly from #invoke the arguments are in frame.args. The function p.populations() uses these frame arguments. I've split p.populations to have an entry point for invoke that gets the frame arguments and calls p._populations() to generate the table.
When called from a template the arguments are in the parent frame. I've changed main() to get the parent frame arguments and then call p._populations() so it now seems to work for the template. Not an ideal approach but an easy change for now. โ€”ย ย Jts1882ย |ย talkย  10:04, 13 June 2021 (UTC)[reply]


CountryProjected population
(13 November 2024)
Pct of
total
UN Population estimatesAnnual growth[a]Doubling time
(years)[b]
1 July 20231 July 2022IncrementRate
ย Brazil212,289,97948.63%211,140,729210,306,415834,3140.40%175
ย Colombia53,131,44612.17%52,321,15251,737,944583,2081.13%62
ย Argentina45,717,92610.47%45,538,40145,407,904130,4970.29%242
ย Peru34,359,8057.87%33,845,61733,475,438370,1791.11%63
ย Venezuela28,421,7266.51%28,300,85428,213,01787,8370.31%223
ย Chile19,804,8194.54%19,658,83519,553,036105,7990.54%128
ย Ecuador18,196,4454.17%17,980,08317,823,897156,1860.88%79
ย Bolivia12,476,8872.86%12,244,15912,077,154167,0051.38%50
ย Paraguay6,960,5621.59%6,844,1466,760,46483,6821.24%56
ย Uruguay3,384,2020.78%3,388,0813,390,913โˆ’2,832โˆ’0.08%โˆ’830
ย Guyana832,8630.19%826,353821,6374,7160.57%121
ย Suriname636,8170.15%628,886623,1645,7220.92%76
ย French Guiana310,5310.07%303,402298,3065,0961.71%41
ย Falkland Islands3,4590.00%3,4773,490โˆ’13โˆ’0.37%โˆ’186
Total436,527,468100%433,024,175430,492,7792,531,3960.58%118
I wonder what I need to do to get this to work:
CountryProjected population
(13 November 2024)
Pct of
total
Annual growthDoubling time
(years)
IncrementRate
ย Brazil212,289,97948.63%834,3140.40%175
ย Colombia53,131,44612.17%583,2081.13%62
ย Argentina45,717,92610.47%130,4970.29%242
ย Peru34,359,8057.87%370,1791.11%63
ย Venezuela28,421,7266.51%87,8370.31%223
ย Chile19,804,8194.54%105,7990.54%128
ย Ecuador18,196,4454.17%156,1860.88%79
ย Bolivia12,476,8872.86%167,0051.38%50
ย Paraguay6,960,5621.59%83,6821.24%56
ย Uruguay3,384,2020.78%โˆ’2,832โˆ’0.08%โˆ’830
ย Guyana832,8630.19%4,7160.57%121
ย Suriname636,8170.15%5,7220.92%76
ย French Guiana310,5310.07%5,0961.71%41
ย Falkland Islands3,4590.00%โˆ’13โˆ’0.37%โˆ’186
Total436,527,468100%2,531,3960.58%118
Yeah, well, I know it works like thatโ€”{{Country populations|ARG|BOL|BRA|COL|PER|VEN|CHL|ECU|PRY|URY|GUY|GUF|SUR|FLK}}โ€”but what I really wanted was:
{{Country populations|{{List of countries in South America|ISO=y}}}}
{{Country populations|{{List of countries in South America|ISO=y}}}}
The motive here is replicating the good work you did with {{Country populations}} to, say, {{Country areas}}, {{Country densities}}, etc, so that the list of countries in each region could be centrally maintained in a single template for each. โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐šย โ˜Ž 21:59, 13 June 2021 (UTC)[reply]
The problem there is that the result of that is to set parameter {{para|1|{{List of countries in South America|ISO=y}}}}.
I don't think you can use a template to supply a series of parameters. The solutions is to get the module to handle a list (e.g. comma delimited). If the module is handling it, then the lists may as well be stored in a subpage and be provided a via a parameter, e.g. |. โ€”ย ย Jts1882ย |ย talkย  08:24, 14 June 2021 (UTC)[reply]
CountryProjected population
(13 November 2024)
Pct of
total
UN Population estimatesAnnual growthDoubling time
(years)
1 July 20231 July 2022IncrementRate
ย United States346,159,62256.74%343,477,335341,534,0461,943,2890.57%122
ย Mexico131,300,47521.52%129,739,759128,613,1171,126,6420.88%79
ย Canada39,963,8206.55%39,299,10538,821,259477,8461.23%57
ย Guatemala18,511,5583.03%18,124,83817,847,877276,9611.55%45
ย Haiti11,823,3631.94%11,637,39811,503,606133,7921.16%60
ย Dominican Republic11,470,5601.88%11,331,26511,230,734100,5310.90%78
ย Cuba10,965,4761.80%11,019,93111,059,820โˆ’39,889โˆ’0.36%โˆ’192
ย Honduras10,898,0771.79%10,644,85110,463,872180,9791.73%40
ย Nicaragua6,953,1531.14%6,823,6136,730,65492,9591.38%51
ย El Salvador6,350,0241.04%6,309,6246,280,31929,3050.47%149
ย Costa Rica5,138,2810.84%5,105,5255,081,76523,7600.47%149
ย Panama4,539,5030.74%4,458,7594,400,77357,9861.32%53
ย Jamaica2,840,6660.47%2,839,7862,839,1446420.02%3,066
ย Trinidad and Tobago1,512,5980.25%1,502,9321,495,9217,0110.47%148
ย Belize422,8690.07%411,106402,7338,3732.08%34
ย Bahamas402,0620.07%399,440397,5381,9020.48%145
ย Barbados274,3360.04%282,336288,318โˆ’5,982โˆ’2.07%โˆ’33
ย Saint Lucia179,9780.03%179,285178,7815040.28%246
ย Grenada117,3120.02%117,081116,9131680.14%483
ย Saint Vincent and the Grenadines100,3400.02%101,323102,046โˆ’723โˆ’0.71%โˆ’97
ย Antigua and Barbuda93,9730.02%93,31692,8404760.51%136
ย Dominica66,0790.01%66,51066,826โˆ’316โˆ’0.47%โˆ’146
ย Saint Kitts and Nevis46,8250.01%46,75846,709490.10%661
Total610,130,951100%604,011,876599,595,6114,416,2650.73%94

The above table is generated with {{Country populations|list=North America}}. The list of countries is stored in a table as follows:

	
local country_lists = {
  ['South America'] = { "ARG","BOL","BRA","CHL","COL","ECU","GUY","PRY","PER","SUR","URY","VEN","BVT","FLK","SGS","GUF" },
  ['North America'] = { "ATG","BHS","BLZ","BRB","CAN","CRI","CUB","DMA","DOM","GRD","GTM","HND","HTI","JAM","KNA","LCA","MEX","NIC","PAN","SLV","TTO","USA","VCT" },
  ['Arab countries'] = { "EGY","DZA","SDN","IRQ","MAR","SAU","YEM","SYR","TUN","JOR","ARE","LBN","LBY","PSE","OMN","KWT","MRT","QAT","BHR","DJI","COM" }
}

At the moment it is just a local variable in the function, but I suggest putting them in a subpage of the module. Then the subpage can be used by other modules. โ€”ย ย Jts1882ย |ย talkย  16:26, 14 June 2021 (UTC)[reply]

Yep, that's useful. Unfortunately, the other aim I had in mind no worky โ€” ๐†๐ฎ๐š๐ซ๐š๐ฉ๐ข๐ซ๐š๐ง๐ ๐šย โ˜Ž 06:05, 15 June 2021 (UTC)[reply]

Bug

[edit]

Something's gone awry with the module, Jts1882. Look at the missing 2nd figures column heading, and that the projected populations are lower than the latest (2019) estimate: List of African countries by population. Cheers. โ€” Guarapirangaย โ˜Ž 03:20, 29 July 2021 (UTC)[reply]

The module gets the dates and data from List of countries by population (United Nations). You changed the section labels with this edit, so the date calculations no longer work correctly. You can also see that the first date column header is missing in List of African countries by population. โ€”ย ย Jts1882ย |ย talkย  07:09, 29 July 2021 (UTC)[reply]
Yes, and additionally in List of African countries by population, Guinea-Bissau is missing. Does anyone know what is causing this bug? I wasn't able to follow the explanation above. I can't see anything problematic in the UN source list. Cstanford.math (talk) 19:19, 2 September 2021 (UTC)[reply]
@Cstanford.math:. The section labels weren't set properly in the page with the population data (List of countries by population (United Nations)). I've set them now (with this edit) and the previous module version of List of African countries by population seems to work (you may need to display it in edit preview due to caching). โ€”ย ย Jts1882ย |ย talkย  07:22, 3 September 2021 (UTC)[reply]
  1. ^ Cite error: The named reference UN was invoked but never defined (see the help page).


Cite error: There are <refย group=lower-alpha> tagsย or {{efn}} templates on this page, but the references will not show without a {{reflist|group=lower-alpha}} templateย or {{notelist}} template (see the help page).