Module talk:Settlement Wikidata
Preferred year
Is there a reason why we have a preferred year instead of just selecting the latest available? For example, I was looking at Switzerland: there is official population data updated to 2024 for Zurich, but data from 2018 is selected instead. This differs by several hundred thousand people. Why use 6 years old data? Ita140188 (talk) 15:08, 7 November 2025 (UTC)
- @Ita140188: I don't know. The templates that this Module replaced had hardwired dates, so I copied that behavior over. We could remove the preferred dates for Switzerland at least. — hike395 (talk) 03:43, 21 January 2026 (UTC)
- Yes, I would remove preferred dates (at least for Switzerland, but I don't see why we would have it for any other country either). In my opinion, the latest date available should be always used. I cannot edit the page myself, so if you agree it would be great if you could make that change, thank you Ita140188 (talk) 08:13, 21 January 2026 (UTC)
- I removed the preferred 2018 dates for Switzerland and Austria, because the corresponding data is getting obsolete. Since I don't know why the original templates
- @Ita140188 and Markussep: I eliminated the "preferred date" logic, because that seems like a hack. Instead, the code examines the rank and dates of the statements to determine what area or population to show:
- Unsourced statements are never shown, nor are ones with "deprecated" rank.
- Higher ranked statements are preferred to lower ones (e.g., "preferred" is shown instead of "normal")
- At the same rank, dated statements are preferred to undated ones
- Between dates statements at the same rank, the latest one is preferred
- I think the module is more robust now. — hike395 (talk) 11:55, 22 January 2026 (UTC)
- @Ita140188 and Markussep: I eliminated the "preferred date" logic, because that seems like a hack. Instead, the code examines the rank and dates of the statements to determine what area or population to show:
- I removed the preferred 2018 dates for Switzerland and Austria, because the corresponding data is getting obsolete. Since I don't know why the original templates
- Yes, I would remove preferred dates (at least for Switzerland, but I don't see why we would have it for any other country either). In my opinion, the latest date available should be always used. I cannot edit the page myself, so if you agree it would be great if you could make that change, thank you Ita140188 (talk) 08:13, 21 January 2026 (UTC)
More specific reference?
Is there a way to link to a more specific reference for French population data? All 2023 population data refer to wikidata:Q137545422 (Populations de référence 2023), which links to https://www.insee.fr/fr/statistiques/8681011. In the old version of {{France metadata Wikidata}}, there was a link to a specific reference for each commune (e.g. https://www.insee.fr/fr/statistiques/8643952?geo=COM-62069), created by looking up the INSEE code (wikidata:Property:P374 in Wikidata:
<ref name=popref2023>{{cite web |title={{wikidata|label|eid=Q137545422}} |url=https://www.insee.fr/fr/statistiques/8643952?geo=COM-{{#if: {{wikidata|property|P374}} | {{wikidata|property|P374}} | {{main other|[[Category:Pages using Template:France metadata Wikidata without references]]}} }} |publisher={{wikidata|property|linked|eid=Q137545422|P123}} |date=29 December 2025|language=fr}}</ref>
This specific reference can be accessed from the general reference by clicking "Vous pouvez également obtenir la population de chaque commune, arrondissement, département et région." For places that are not communes (regions, departments etc.), the general reference has to be used. I think that would be an improvement, is there a way to include it in this module? @Hike395: could you comment on that? Markussep Talk 14:50, 17 January 2026 (UTC)
- Possibly. The current code doesn't hardwire the general reference, but assembles it from Wikidata properties. If the general reference changes in the future, we should not hardwire https://www.insee.fr/fr/statistiques/8643952?geo=COM-P374 to forever be the reference.
- One hack is to see whether the url is https://www.insee.fr/fr/statistiques/8681011 and P374 exists. If it does, then we could replace it with https://www.insee.fr/fr/statistiques/8643952?geo=COM-P374. But this would not be future-proof. — hike395 (talk) 03:41, 21 January 2026 (UTC)
- All French communes have just been updated to the 2023 populations, the next update will be in January 2027. The way it was done before the change to Lua (and now temporarily, to check the update), the template would check for 2023 populations, and if so, check for the right reference (Q137545422) and P374, and if so, create the reference as I wrote above. If no 2023 data but 2022 data were available, it would check for that reference (Q131560738) and P374, and if so, create a similar reference for the 2022 population. For non-communes (so no P374), it would create the general reference. Some time in January 2027, the module would have to be updated. I can/will provide the new reference and url structure then. Markussep Talk 08:42, 21 January 2026 (UTC)
We may be miscommunicating. The module does not look up the reference via Q137545422 or Q131560738. It doesn't have those QIDs hardwired into the code, because it can work for any settlement in any country. Instead, it looks at the following list of Wikidata properties in the population P2046 or area P1082 to assemble the reference:
P50 = "author",
P123 = "publisher",
P407 = "language",
P577 = "date",
P813 = "access-date",
P854 = "url",
P856 = "url",
P953 = "url",
P1476 = "title",
P2699 = "url",
What you're suggesting is that we break this generality. I'm reluctant to do that, because it would break the integrity of the source -- Wikidata is saying the reference is one thing, and we're going to override it with another URL. I cannot see how to do that in general, and it doesn't seem like a good idea even in 1 or 2 cases. — hike395 (talk) 14:16, 21 January 2026 (UTC)
- Then probably we should keep the French data lookup separate from this module, like it was before October. Your edit to {{France metadata Wikidata}} just now does not seem to work, but probably you're testing something. Markussep Talk 15:04, 21 January 2026 (UTC)
- (edit conflict) @Markussep: The current version of {{France metadata Wikidata}} does not work for many settlements. See, e.g., Azincourt and Annecy that both lost their population fields in their infoboxes. The Lua module correctly returned their 2023 population without any special code (see Template:France metadata Wikidata/testcases
- I'll do the following:
- Revert {{France metadata Wikidata}} to use the module
- Modify the module to produce an additional reference based on P374 that is more specific. It will be a hack -- i.e., it will check for an exact URL and P374. This way we are both happy -- we are showing the exact reference from Wikidata, and a second reference that is the more specific reference in the special cases that you've defined.
- Does that sounds good? — hike395 (talk) 15:15, 21 January 2026 (UTC)
- The template worked well until half an hour ago, provided it can use the wikidata ID of the page it is called on. I guess you want to be able to retrieve the population etc. by feeding it a specified wikidata ID. Is there a way to do both? Markussep Talk 15:19, 21 January 2026 (UTC)
- That was just for testing, let me first revert back to your version. — hike395 (talk) 15:27, 21 January 2026 (UTC)
- OK, my edits broke the template, now reverted. How about this
- I'll modify the module to provide your reference as an additional second reference.
- After that, I will revert back to Lua.
- Does that sound good? — hike395 (talk) 15:30, 21 January 2026 (UTC)
- I'd rather have just one reference, it seems a bit silly to have two basically identical references for the same data point. Maybe it's better to keep using the old/current version of Template:France metadata Wikidata for the infoboxes of French communes etc. (which are 36000+ articles), and have the Lua module for all other applications. Markussep Talk 15:37, 21 January 2026 (UTC)
- OK, my edits broke the template, now reverted. How about this
- That was just for testing, let me first revert back to your version. — hike395 (talk) 15:27, 21 January 2026 (UTC)
- The template worked well until half an hour ago, provided it can use the wikidata ID of the page it is called on. I guess you want to be able to retrieve the population etc. by feeding it a specified wikidata ID. Is there a way to do both? Markussep Talk 15:19, 21 January 2026 (UTC)
I went ahead and implemented a URL rewrite rule (in function mapURL()), to implement the behavior Markussep requested. If you add more rows to the urlMap table, you can rewrite more examples (using any property substituted into *****. I'll restore calling the Lua, because it is more robust than the current template: e.g., if there is no P374 the current template returns an incorrect URL, while the Lua produces a correct (but more general) template. — hike395 (talk) 04:10, 22 January 2026 (UTC)
- Excellent! The articles I checked about French communes, departments, cantons etc. give the right output. Thanks a lot for the update! BTW does the module always pick the population from Wikidata that has the preferred rank? If that's the case, we don't need the specified "asOf" date (line 7) for France. Markussep Talk 08:13, 22 January 2026 (UTC)
- It currently uses the latest statement if no asOf date is specified. That means it automatically updates when (e.g.) MystBot adds a newer census. I can remove the "asOf" date. — hike395 (talk) 10:03, 22 January 2026 (UTC)
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.