Module talk:Country population
Static Row Numbers
[edit]Hey, Jts1882, would {{srn}} be useful in this module? โ ๐๐ฎ๐๐ซ๐๐ฉ๐ข๐ซ๐๐ง๐ ๐ (talk) 21:59, 2 May 2021 (UTC)
- ย 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
orframe: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)
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)
Flaglist vs Flagcountry
[edit]Jts1882: Wouldn't {{flaglist}} be better for alignment than {{flagcountry}} here? โ ๐๐ฎ๐๐ซ๐๐ฉ๐ข๐ซ๐๐ง๐ ๐ (talk) 01:28, 5 May 2021 (UTC)
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)
- 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)
Country | Projected population (13 November 2024) | Pct of total | UN Population estimates | Annual growth[a] | Doubling time (years)[b] | ||
---|---|---|---|---|---|---|---|
1 July 2023 | 1 July 2022 | Increment | Rate | ||||
ย Brazil | 212,289,979 | 48.63% | 211,140,729 | 210,306,415 | 834,314 | 0.40% | 175 |
ย Colombia | 53,131,446 | 12.17% | 52,321,152 | 51,737,944 | 583,208 | 1.13% | 62 |
ย Argentina | 45,717,926 | 10.47% | 45,538,401 | 45,407,904 | 130,497 | 0.29% | 242 |
ย Peru | 34,359,805 | 7.87% | 33,845,617 | 33,475,438 | 370,179 | 1.11% | 63 |
ย Venezuela | 28,421,726 | 6.51% | 28,300,854 | 28,213,017 | 87,837 | 0.31% | 223 |
ย Chile | 19,804,819 | 4.54% | 19,658,835 | 19,553,036 | 105,799 | 0.54% | 128 |
ย Ecuador | 18,196,445 | 4.17% | 17,980,083 | 17,823,897 | 156,186 | 0.88% | 79 |
ย Bolivia | 12,476,887 | 2.86% | 12,244,159 | 12,077,154 | 167,005 | 1.38% | 50 |
ย Paraguay | 6,960,562 | 1.59% | 6,844,146 | 6,760,464 | 83,682 | 1.24% | 56 |
ย Uruguay | 3,384,202 | 0.78% | 3,388,081 | 3,390,913 | โ2,832 | โ0.08% | โ830 |
ย Guyana | 832,863 | 0.19% | 826,353 | 821,637 | 4,716 | 0.57% | 121 |
ย Suriname | 636,817 | 0.15% | 628,886 | 623,164 | 5,722 | 0.92% | 76 |
ย French Guiana | 310,531 | 0.07% | 303,402 | 298,306 | 5,096 | 1.71% | 41 |
ย Falkland Islands | 3,459 | 0.00% | 3,477 | 3,490 | โ13 | โ0.37% | โ186 |
Total | 436,527,468 | 100% | 433,024,175 | 430,492,779 | 2,531,396 | 0.58% | 118 |
- I wonder what I need to do to get this to work:
Country | Projected population (13 November 2024) | Pct of total | Annual growth | Doubling time (years) | |
---|---|---|---|---|---|
Increment | Rate | ||||
ย Brazil | 212,289,979 | 48.63% | 834,314 | 0.40% | 175 |
ย Colombia | 53,131,446 | 12.17% | 583,208 | 1.13% | 62 |
ย Argentina | 45,717,926 | 10.47% | 130,497 | 0.29% | 242 |
ย Peru | 34,359,805 | 7.87% | 370,179 | 1.11% | 63 |
ย Venezuela | 28,421,726 | 6.51% | 87,837 | 0.31% | 223 |
ย Chile | 19,804,819 | 4.54% | 105,799 | 0.54% | 128 |
ย Ecuador | 18,196,445 | 4.17% | 156,186 | 0.88% | 79 |
ย Bolivia | 12,476,887 | 2.86% | 167,005 | 1.38% | 50 |
ย Paraguay | 6,960,562 | 1.59% | 83,682 | 1.24% | 56 |
ย Uruguay | 3,384,202 | 0.78% | โ2,832 | โ0.08% | โ830 |
ย Guyana | 832,863 | 0.19% | 4,716 | 0.57% | 121 |
ย Suriname | 636,817 | 0.15% | 5,722 | 0.92% | 76 |
ย French Guiana | 310,531 | 0.07% | 5,096 | 1.71% | 41 |
ย Falkland Islands | 3,459 | 0.00% | โ13 | โ0.37% | โ186 |
Total | 436,527,468 | 100% | 2,531,396 | 0.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)
- 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)
- Yeah, well, I know it works like thatโ
Country | Projected population (13 November 2024) | Pct of total | UN Population estimates | Annual growth | Doubling time (years) | ||
---|---|---|---|---|---|---|---|
1 July 2023 | 1 July 2022 | Increment | Rate | ||||
ย United States | 346,159,622 | 56.74% | 343,477,335 | 341,534,046 | 1,943,289 | 0.57% | 122 |
ย Mexico | 131,300,475 | 21.52% | 129,739,759 | 128,613,117 | 1,126,642 | 0.88% | 79 |
ย Canada | 39,963,820 | 6.55% | 39,299,105 | 38,821,259 | 477,846 | 1.23% | 57 |
ย Guatemala | 18,511,558 | 3.03% | 18,124,838 | 17,847,877 | 276,961 | 1.55% | 45 |
ย Haiti | 11,823,363 | 1.94% | 11,637,398 | 11,503,606 | 133,792 | 1.16% | 60 |
ย Dominican Republic | 11,470,560 | 1.88% | 11,331,265 | 11,230,734 | 100,531 | 0.90% | 78 |
ย Cuba | 10,965,476 | 1.80% | 11,019,931 | 11,059,820 | โ39,889 | โ0.36% | โ192 |
ย Honduras | 10,898,077 | 1.79% | 10,644,851 | 10,463,872 | 180,979 | 1.73% | 40 |
ย Nicaragua | 6,953,153 | 1.14% | 6,823,613 | 6,730,654 | 92,959 | 1.38% | 51 |
ย El Salvador | 6,350,024 | 1.04% | 6,309,624 | 6,280,319 | 29,305 | 0.47% | 149 |
ย Costa Rica | 5,138,281 | 0.84% | 5,105,525 | 5,081,765 | 23,760 | 0.47% | 149 |
ย Panama | 4,539,503 | 0.74% | 4,458,759 | 4,400,773 | 57,986 | 1.32% | 53 |
ย Jamaica | 2,840,666 | 0.47% | 2,839,786 | 2,839,144 | 642 | 0.02% | 3,066 |
ย Trinidad and Tobago | 1,512,598 | 0.25% | 1,502,932 | 1,495,921 | 7,011 | 0.47% | 148 |
ย Belize | 422,869 | 0.07% | 411,106 | 402,733 | 8,373 | 2.08% | 34 |
ย Bahamas | 402,062 | 0.07% | 399,440 | 397,538 | 1,902 | 0.48% | 145 |
ย Barbados | 274,336 | 0.04% | 282,336 | 288,318 | โ5,982 | โ2.07% | โ33 |
ย Saint Lucia | 179,978 | 0.03% | 179,285 | 178,781 | 504 | 0.28% | 246 |
ย Grenada | 117,312 | 0.02% | 117,081 | 116,913 | 168 | 0.14% | 483 |
ย Saint Vincent and the Grenadines | 100,340 | 0.02% | 101,323 | 102,046 | โ723 | โ0.71% | โ97 |
ย Antigua and Barbuda | 93,973 | 0.02% | 93,316 | 92,840 | 476 | 0.51% | 136 |
ย Dominica | 66,079 | 0.01% | 66,510 | 66,826 | โ316 | โ0.47% | โ146 |
ย Saint Kitts and Nevis | 46,825 | 0.01% | 46,758 | 46,709 | 49 | 0.10% | 661 |
Total | 610,130,951 | 100% | 604,011,876 | 599,595,611 | 4,416,265 | 0.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)
- Yep, that's useful. Unfortunately, the other aim I had in mind no worky โ ๐๐ฎ๐๐ซ๐๐ฉ๐ข๐ซ๐๐ง๐ ๐ย โ 06:05, 15 June 2021 (UTC)
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)
- 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)
- 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)
- @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)
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).