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
(16 May 2024)
Pct of
total
UN Population estimatesAnnual growth[a]Doubling time
(years)[b]
1 July 20231 July 2022IncrementRate
ย Brazil217,397,98049.15%216,422,446215,313,4981,108,9480.52%135
ย Colombia52,270,72311.82%52,085,16851,874,024211,1440.41%171
ย Argentina46,005,88010.40%45,773,88445,510,318263,5660.58%120
ย Peru34,620,3147.83%34,352,71934,049,589303,1300.89%78
ย Venezuela29,316,8046.63%28,838,49928,301,696536,8031.90%37
ย Chile19,652,2554.44%19,629,59019,603,73325,8570.13%526
ย Ecuador18,358,0084.15%18,190,48418,001,000189,4841.05%66
ย Bolivia12,534,3672.83%12,388,57112,224,110164,4611.35%52
ย Paraguay6,933,0341.57%6,861,5246,780,74480,7801.19%59
ย Uruguay3,423,3850.77%3,423,1093,422,7943150.01%7,532
ย Guyana818,3320.19%813,834808,7265,1080.63%110
ย Suriname627,8220.14%623,237618,0415,1960.84%83
ย French Guiana318,9620.07%312,155304,5577,5982.49%28
ย Falkland Islands3,8010.00%3,7913,780110.29%239
Total442,281,666100%439,719,011436,816,6102,902,4010.66%105
I wonder what I need to do to get this to work:
CountryProjected population
(16 May 2024)
Pct of
total
Annual growthDoubling time
(years)
IncrementRate
ย Brazil217,397,98049.15%1,108,9480.52%135
ย Colombia52,270,72311.82%211,1440.41%171
ย Argentina46,005,88010.40%263,5660.58%120
ย Peru34,620,3147.83%303,1300.89%78
ย Venezuela29,316,8046.63%536,8031.90%37
ย Chile19,652,2554.44%25,8570.13%526
ย Ecuador18,358,0084.15%189,4841.05%66
ย Bolivia12,534,3672.83%164,4611.35%52
ย Paraguay6,933,0341.57%80,7801.19%59
ย Uruguay3,423,3850.77%3150.01%7,532
ย Guyana818,3320.19%5,1080.63%110
ย Suriname627,8220.14%5,1960.84%83
ย French Guiana318,9620.07%7,5982.49%28
ย Falkland Islands3,8010.00%110.29%239
Total442,281,666100%2,902,4010.66%105
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
(16 May 2024)
Pct of
total
UN Population estimatesAnnual growthDoubling time
(years)
1 July 20231 July 2022IncrementRate
ย United States341,497,79656.66%339,996,564338,289,8571,706,7070.50%138
ย Mexico129,294,34821.45%128,455,567127,504,126951,4410.75%93
ย Canada39,069,8206.48%38,781,29238,454,327326,9650.85%82
ย Guatemala18,312,0763.04%18,092,02617,843,908248,1181.39%50
ย Haiti11,848,5101.97%11,724,76411,584,996139,7681.21%58
ย Dominican Republic11,424,9471.90%11,332,97311,228,821104,1520.93%75
ย Cuba11,178,9401.85%11,194,44911,212,191โˆ’17,742โˆ’0.16%โˆ’438
ย Honduras10,736,7311.78%10,593,79810,432,860160,9381.54%45
ย Nicaragua7,133,1681.18%7,046,3116,948,39297,9191.41%50
ย El Salvador6,390,0441.06%6,364,9436,336,39228,5510.45%154
ย Costa Rica5,239,7690.87%5,212,1735,180,82931,3440.60%115
ย Panama4,520,8420.75%4,468,0874,408,58159,5061.35%52
ย Jamaica2,823,9400.47%2,825,5442,827,377โˆ’1,833โˆ’0.06%โˆ’1,069
ย Trinidad and Tobago1,538,3520.26%1,534,9371,531,0453,8920.25%273
ย Bahamas414,9490.07%412,624409,9842,6400.64%108
ย Belize415,7480.07%410,825405,2735,5521.37%51
ย Barbados282,3120.05%281,996281,6353610.13%541
ย Saint Lucia180,5960.03%180,251179,8583930.22%318
ย Grenada126,8410.02%126,184125,4387460.59%117
ย Saint Vincent and the Grenadines103,4810.02%103,699103,948โˆ’249โˆ’0.24%โˆ’289
ย Antigua and Barbuda94,7690.02%94,29893,7635350.57%122
ย Dominica73,3050.01%73,04072,7383020.42%167
ย Saint Kitts and Nevis47,8400.01%47,75547,658970.20%341
Total602,749,125100%599,354,100595,503,9973,850,1030.64%108

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).