Template talk:City

Latest comment: 7 years ago by Jarekt in topic Rewrite in LUA

name of countries edit

The langSwitch location templates don't show the name of the country the location is in. For New York or Moscow, it's not a problem, but for {{Otterlo}}, or {{Chantilly}}, it's not obvious that people know where it is. One solution is to put write : {{Chantilly}}, {{France}}, so that the country is displayed, but it has some minor inconvenience. For instance, I think some languages would rather have "Chantilly (France)" than "Chantilly, France". It seems to me that a (probably bot-friendly) is to nest them in a locality template, which is what I tried for Chantilly :
The default display is unchanged (Chantilly), but if we turn on the country option, it reads: Chantilly. (I don't know how to delete the space before the comma, is someone can tell me how to do, it would be useful in several other templates as well).

I had a bit of a hard time to make it work, but in fact it's pretty simple, once you know how to write it. Of course, we can add more options like US state or German Land. It it worth being extended to other cities ?--Zolo (talk) 11:21, 19 July 2010 (UTC)Reply

If I understand correctly what you are trying to achieve, maybe {{RelativeLocation}} could work since it heavily uses i18n and thus is language-specific syntax ? Jean-Fred (talk) 12:10, 19 July 2010 (UTC)Reply
I don't think it seves the same purpose. What I am trying to do is to provide an option that makes the location a bit more understandable, especially for small towns. For instance, here, we get Chantilly, but I think most non-French users don't know where Chantilly is. With the locality template, you can activate the country option so that it reads "Chantilly (France)" in French and "Chantilly, Frankreich" in German. And if you decide that for all works in the Musée Condé in Chantilly, you should have "Musée Condé, Chantilly, France" rather than just "Musée Condé, Chantilly" it can certainly be done by a bot. I had the painting locations in mind, but it can certainly be used elsewhere. The point is that you can decide in each case which level of explanation you want--Zolo (talk) 12:46, 19 July 2010 (UTC)Reply
If it's not clear which one it is, you will need to add the country. Docu  at 12:49, 19 July 2010 (UTC)Reply
There is a line on template Chantilly to tell which country it is. — Preceding unsigned comment added by Zolo (talk • contribs)
hmm ... interesting. I'm not sure if this is really compatible with this template. I was under the impression that all locations here are in just one country and would ideally link to a WP article.  Docu  at 13:06, 19 July 2010 (UTC)Reply
I think the idea was that with interwiki links one can click on the city name and know all the details he/she can possibly need. That said I agree that sometimes in case of little known places and international authors it is convenient to mention country. To do so we use either "{{Chantilly}} ({{France}})" or "{{Chantilly}}, {{France}}" notation. I do not see much advantage of {{Chantilly|country=yes}} and it would be a big job to change all the location templates to follow this format. It might be easier to add it to the {{City}}. Finally the "{{Chantilly}} ({{France}})" or "{{Chantilly}}, {{France}}" notations are variants depending on language. I think comma notation works in most languages and originally many location templates used that notation. However that did not work well in the Workloc field of the creator template (where they were often used) producing lines like: "Italy, London, UK, Paris, France".--Jarekt (talk) 13:11, 19 July 2010 (UTC)Reply
Couldn't {{city|Chantilly}} just output Chantilly -- or Chantilly (Oise) or Chantilly (France)?. If it's not clear which one it is, the input would be, e.g. {{city|Chantilly, Oise}}? This might need some tweaking for other languages.  Docu  at 13:18, 19 July 2010 (UTC)Reply
I don't think it should take more than 30 seconds by template, and if some template are not changed, it just stays how it is now. The default display remains the same, so it doesn't imply make things more complicated for users. I agree however that this doesn't make much difference with "{{Chantilly}}, {{France}}". The main advantage is that it adjusts automatically to such variants as "{{Chantilly}} ({{France}})" or "{{Chantilly}}, {{France}}". Minor advantage, but not so much work to do either I think.
@docu: The template works with me (in French and English, I didn't try other languages) Chantilly

I get two links to Wikipedia: one to Chantilly and one to France. The only problem I get it that it gets to a new line, I don't know how to fix that but it's probably quite simple. There are plenty of other European locations here. We can certainly adjust for Chantilly Oise, that had not been done in the present template. Do we need to put Chantilly, Oise by default in English ?--Zolo (talk) 13:26, 19 July 2010 (UTC)Reply

Really I think it would be nice to have the country name. It is certainly not essential but it makes for nicer code. For exampple creator:el Greco has | Deathloc = {{RelativeLocation|Toledo|,|Spain}} which does not look that good and implies a good acquaintance with Commons templates. It would be easier to have simply | Deathloc = Toledo with the template automatically adding the rest. Of course "New York City, United States" looks a bit silly but why not ?--Zolo (talk) 09:09, 10 February 2011 (UTC)Reply

We could have a second parameter so {{City|Toledo}} would still give Toledo, but {{City|Toledo|,}} would give "Toledo, Spain" and {{City|Toledo|()}} would give "Toledo (Spain)". The format with "," can be used in places like Deathloc, where a single city is expected. --Jarekt (talk) 12:07, 10 February 2011 (UTC)Reply
Yes but isn't it simpler to have {{Toledo|coutry}} for the former - and {{Toledo|disambiguated}} for the latter (if it is the use you have in mind) ? I think it would make it clearer what the template is supposed to do and it would look more logical if other languages have different formatting habits.--Zolo (talk) 12:38, 10 February 2011 (UTC)Reply
If I would make changes to each city template than I would have to be working on about 200 templates in Category:Multilingual tags: Locations, I prefer to work on {{City}} template alone. But the more I think about it the more messy it gets. City names change much less frequently than countries do just look at Jerusalem depending on period different country name should be used. Same with Lviv It belonged to Poland (>500 years), Austria (>100 years), Soviet Union (>50 years) and Ukraine (20 years) and depending on the time period different country should be mentioned. It would be wrong to assign historical figures to countries based on current borders, and it would be mostly impossible to add years to each city template. --Jarekt (talk) 14:14, 10 February 2011 (UTC)Reply
With the "," parameter we would still have to add the country to each template, wouldn't we ? But true border changes are a real problem.--Zolo (talk) 07:29, 11 February 2011 (UTC)Reply

Add Perpignan edit

{{editprotected}} Please, add {{Perpignan}} in "Locations in France". --V.Riullop (talk) 23:00, 10 January 2011 (UTC)Reply

  Done --Jarekt (talk) 02:03, 11 January 2011 (UTC)Reply

Proposed Changes edit

This template changed a lot since its early versions, which did not rely as much on templates. With such a large number of locations maintenance become an issue and now that the template is protected - it is silly to be adding cities one by one with {{Editprotected}} ( appologies to User:Vriullop - I am not picking on him/her). I would like to propose to use {{#ifexist:template:{{{1|}}}|{{{{{1}}}}} }} construct on the beginning of the template and eliminate all lines like: "name = {{name}}". --Jarekt (talk) 02:12, 11 January 2011 (UTC)Reply

I agree, but ifexist is an expensive parser function, so a bot should replace existing city templates. --V.Riullop (talk) 08:26, 11 January 2011 (UTC)Reply
Actually the limit is s500 expensive parser function calls, so I think that if we keep using the template the way we do, it would be fine to implement Jarekt's proposal. If we dramatically expand the use of the template we may need another solution, but Template:Departments of France uses 100 "ifexist" without any loading delay.--Zolo (talk) 08:38, 18 February 2011 (UTC)Reply
All ifexist in {{City}}, {{Artwork}}, and {{Book}} now check if the tested string is already in the correct format before trying ifexist. So in creator pages Deathloc={{Paris}} is more efficient than Deathloc=Paris which is more efficient than Deathloc=XXXX. this last one checks for existence of a template, gallery and category before giving up. I also decided to leave links like "name = {{name}}" in this template this way it is easier to add alternative names "name|name1|name2 = {{name}}". --Jarekt (talk) 14:06, 18 February 2011 (UTC)Reply

The name of the template edit

The name of the template is pretty confusing, if it doesn't serve just for cities. I think it should be renamed. --Petrus Adamus (talk) 12:23, 31 May 2011 (UTC)Reply

Most of use is for city names I can not think of other name which would be less confusing. {{Location}} might have been a good option but it is already taken. It seems to me that the other common use is for countries, so wh could have {{Country}} redirect to it, but that template name is used for something else as well. --Jarekt (talk) 12:34, 31 May 2011 (UTC)Reply

Please add to at edit

Please add to at „Locations in Germany“:

 |Bonn={{Bonn}}
 |Greifswald={{Greifswald}}  
 |Potsdam={{Potsdam}}

Please add to at “Locations in France”:

 |Fontainebleau={{Fontainebleau}} 

thanks --Botaurus (talk) 15:00, 31 July 2011 (UTC)Reply

  Done --Jarekt (talk) 01:31, 1 August 2011 (UTC)Reply

Please add to at "Locations in Italy“:

 |Gorizia|Gorica={{Gorizia}}

--Sporti (talk) 12:34, 2 November 2011 (UTC)Reply

  Done --Jarekt (talk) 03:48, 3 November 2011 (UTC)Reply

Please add to at „Locations in Austria“:

 |Klagenfurt|Klagenfurt am Wörthersee|Celovec={{Klagenfurt}}
 |Villach|Beljak={{Villach}}
 |Graz|Gradec|Grác={{Graz}}

--Sporti (talk) 12:23, 7 November 2011 (UTC)Reply

  Done--Zolo (talk) 13:19, 7 November 2011 (UTC)Reply

Linking to categories edit

I don't like the fall-back behavior of linking to categories. In many cases, this will be confusing to the user. If I click on a link in a description, I never expect to go to a category (which may contain nothing but the image I was already looking at). I expect to go to a page giving me information about that location. Can we remove the category fallback behavior? Kaldari (talk) 19:23, 24 March 2012 (UTC)Reply

This if usually the last fallback and the intent was that a link to a category is better than no link, since categories might have interwiki links, or parent categories would tell you about what country the city is in, etc. But I agree that this is the least desirable outcome and I would be fine with retiring it if others feel the same way. --Jarekt (talk) 02:17, 25 March 2012 (UTC)Reply
I would rather keep it because of the links, and because there is often a short description in categories. But would be fine at removing it too. It is sometimes annoying that would never quite know in advance where the links will go.--Zolo (talk) 07:20, 25 March 2012 (UTC)Reply
We could use different colors for different links. The colors do not have to vary much. --Jarekt (talk) 01:16, 26 March 2012 (UTC)Reply
Perhaps. But I guess it would be even more confusing for occasional users. More experienced users can actually mouse over the link to see where it leads. It is just not the most intuitive option.--Zolo (talk) 09:26, 26 March 2012 (UTC)Reply
Yes maybe the same kind of difference as Wikipedia link vs Commons link. But I must say I find those colors somewhat confusing: to me lighter link seems to mean less relevant link than darker link, but links to Wikipedia are both lighter and (in most cases) more relevant than Commons links. -Zolo (talk) 14:28, 26 March 2012 (UTC)Reply

Please add edit

{{editprotected}} For "Locations in Iran":

|Persia={{Persia}}
|Tehran|Teheran={{Tehran}}
|Isfahan|Esfahan={{Isfahan}}
|Shiraz={{Shiraz}}
|Tabriz={{Tabriz}}

and "Locations in Tajikistan":

|Dushanbe={{Dushanbe}}

and for "Locations in Egypt":

|Cairo = {{Cairo}}
|Valley of the Kings = {{Valley of the Kings}}

Thanks! --Z 07:20, 2 May 2012 (UTC)Reply

  Done and thanks for helping --Jarekt (talk) 11:21, 2 May 2012 (UTC)Reply

sl edit

{{Editprotected}} Please, add:

  • |sl=Grodno
  • |sl=[[:sl:Kirovska oblast|Vjatka]]
  • |sl=Čugujev for (Chuhuiv|Чугуїв|Чугуев)
  • |sl=[[:sl:Repino|Kuokala (Terioki)]]
  • ''|sl=[[Vlaanderen|Flandrija]]''
  • ''|sl=[[:sl:Bern|Bern (Švica)]]''
  • ''|sl=[[:sl:Torunj|Torunj]]'' for (Torun)
  • ''|sl=[[:sl:Riga|Riga]]''
  • ''|sl=[[:sl:Nežin|Nežin]]'' for (|Nezhin|Нежин|Ніжин)

Thanks a lot. --Eleassar (t/p) 13:31, 12 October 2012 (UTC)Reply

Can you add your changes to template:City/sandbox? I just synchronised it with the current template:City. --Jarekt (talk) 15:15, 12 October 2012 (UTC)Reply

Why not collaborate with wikidata? edit

The wikidata project recently collected almost all the wikipedia interwiki links centralizing them to one single node in wikidata.

I have taken a look at the location names in wikidata. Some very little towns like counties in China have been collected. So I think there is no need to add new location template like Template:Beijing. Just take advantage of wikidata.

--Lee凡其Fanchy 09:12, 1 January 2013 (UTC)Reply

Wikidata will surely be very useful in the future, but it is not yet possible to transclude Wikidata content on Commons. --Zolo (talk) 11:25, 1 January 2013 (UTC)Reply
Maybe WikiData should collaborate with Commons? --  Docu  at 11:55, 1 January 2013 (UTC)Reply
Sorry, I don't know it is not yet possible to get the data stored in WikiData. I have thought it should be like getting a picture stored in Commons.--Lee凡其Fanchy 13:46, 1 January 2013 (UTC)Reply
It will be a game changer, but for the time being it is business as usual. it is also unclear to me that we will be able to write templates like Template:Beijing exploring wikidata-stoded links, but I sure hope so. --Jarekt (talk) 03:28, 2 January 2013 (UTC)Reply

Please add (Trieste) edit

{{Editprotected}} To "Locations in Italy":

|Trieste|Trst={{Trieste}}

--Sporti (talk) 08:57, 18 January 2013 (UTC)Reply

  Done --Jarekt (talk) 12:32, 18 January 2013 (UTC)Reply

Please add {{Vinci}} edit

{{Editprotected}} In the paragraph Locations in Italy, please substitute the code |Vinci={{LangSwitch|en=[[Vinci]]|mk=[[:mk:Винчи|Винчи]]}} with |Vinci={{Vinci}}.
Thanks in advance, — TintoMeches, 17:11, 24 June 2013 (UTC)Reply

One more thing: in Other Locations, the key European Union has three occurrences, I think one is enough.
Maybe we can add EU and UE as alternative abbreviations... — TintoMeches, 22:25, 24 June 2013 (UTC)Reply
Done. Killiondude (talk) 00:53, 28 June 2013 (UTC)Reply

Typo edit

{{Editprotected}} There is a typo on this line:

|uk=[[:ru:Вятская губерния||В'ятська Губернія]]

It should be replaced with:

|uk=[[:ru:Вятская губерния|В'ятська Губернія]]

Basilicofresco (msg) 10:26, 10 September 2013 (UTC)Reply

These links are outdated/ I suppose uk should be [[Vyatka Governorate]] ? By the way, is there a difference between "Vyatka Province" and Vyatka Governorate ? --Zolo (talk) 10:51, 10 September 2013 (UTC)Reply
  Doneebraminiotalk 15:28, 14 September 2013 (UTC)Reply

Please disambiguate "Syracuse" edit

{{Editprotected}} Please add the bold parts and remove the part stricken through!

 |Dieppe
 |Guadalajara
 |Laval
 |Syracuse =  {{tagged ambiguous}}

 |Syracuse, Sicily={{Syracuse}}{{tagged ambiguous}}

Thanks in advance, --Marsupium (talk) 13:11, 2 January 2014 (UTC)Reply

Are you sure that all instances now refer to Syracure, Sicily unambiguously? Otherwise, we'd better to just add the new one and leave the old entry as well (and I did so). whym (talk) 01:45, 13 January 2014 (UTC)Reply
Sorry for my late answer. I think you mix two things: I am not sure that all transclusions of {{Syracuse}} refer to Syracuse, Sicily, I did not even look it up. But all transclusions of {{city|Syracuse}} should be disambiguated. There are no cases at the moment, cf. Category:Tagged ambiguous. But I'd prefer that the template {{city|Syracuse}} does not transclude {{Syracuse}} to show the issue to an editor newly adding it. We could even remove the line |Syracuse={{Syracuse}}{{tagged ambiguous}}. But since it is not currently used it is not that important. Regards, --Marsupium (talk) 09:48, 31 January 2014 (UTC)Reply
@Marsupium: Thank you, now I see what you mean.   Done whym (talk) 10:00, 31 January 2014 (UTC)Reply

German-speaking countries edit

{{Editprotected}}

Please add "Österreich" to Austria and "Deutschland" to Germany. Thanks! --tacsipacsi (talk) 17:22, 22 April 2014 (UTC)Reply

  Done --Jarekt (talk) 18:36, 22 April 2014 (UTC)Reply
Thanks! --tacsipacsi (talk) 20:15, 22 April 2014 (UTC)Reply

Please add edit

{{Editprotected}} To "Locations in Germany":

|Bayreuth={{Bayreuth}}
|Magdeburg={{Magdeburg}}

--ACBahn (talk) 19:52, 5 September 2014 (UTC)Reply

Spui seen as city template when entered as city edit

Spui is a small place in the Netherlands, when it's used in building address (example at File:Ronde stenen beltmolen van achteren gefotografeerd - AMR Molenfoto - 20541280 - RCE.jpg) it gives a link to Template:Spui, which is a user-license template. Would it be possible to prevent this (maybe adding "|spui=Spui" without a template)? Mvg, Basvb (talk) 23:52, 3 February 2015 (UTC)Reply

Yes, done. --~~
Thank you. Basvb (talk) 08:50, 4 February 2015 (UTC)Reply

be-tarask edit

{{Editprotected}} Please add

     |be-tarask={{w|Гародня||be-x-old}}

to the section «Locations in Belarus». Thanks, Renessaince (talk) 06:42, 20 July 2015 (UTC)Reply

  Done --Jarekt (talk) 13:08, 22 July 2015 (UTC)Reply

Constantinople edit

Constantinople is the old name of Istanbul. Changing it automatically to Istanbul is not a good idea, I think. Vincent Steenberg (talk) 09:37, 27 January 2016 (UTC)Reply

  Fixed --Jarekt (talk) 12:58, 27 January 2016 (UTC)Reply

Wikidata edit

It would be much simpler to get the links and labels directly from Wikidata rather than maintaining all that here. The main issue is performance. If we want to get a link to Wikipedia on Commons, we need to load te whole wikidata entity, which is sometimes several megabytes (and counting). Every page is limited to 50 mb. On the other hand links to Commons and labels in int:lang are now pretty much cheap. --Zolo (talk) 08:03, 28 April 2016 (UTC)Reply

I added support for specifying cities by a wikidata q-code {{City|Q144786}} gives "Zakopane", I also added a test entry for {{City|Toruń}} which is pulled from wikidata by it's q-code. We could be replacing the templates like {{Paris}}, {{Berlin}} with {{#invoke:Wikidata|getLabel|entity=Q....|link=wikipedia}}. We could ad calls to Module:Wikidata directly to this template in order to simplify it, but also replace {{Paris}}, etc with a single call to Module:Wikidata. This way {{City}} still serves as a look-up table matching city names with Q-codes. --Jarekt (talk) 18:00, 28 April 2016 (UTC)Reply
That would sound like the best solution if we hadn't this memory issue. But {{city|Q183}} (Germany) is alrady 6Mb. As demographic or economic data get added to Wikidata we might get many items as big as that. So that a single {{Creator}} might be enough to break memory limits. Replacing wikipedia link with links to Commons would solve the issue, but that does not sound really be satisfying. --Zolo (talk) 18:55, 28 April 2016 (UTC)Reply
Zolo I do not understand the 50 MB limit, and probably others as well, can you point me somewhere where it is explained? --Jarekt (talk) 20:31, 28 April 2016 (UTC)Reply
When previewing a page, you can see in the performance analysis at the bottom of the page that "Lua memory usage" is limited to 50 MB.
You can see in mw:Extension:Wikibase Client/Lua that in order to use data from Wikidata, you usually need to load the whole Wikidata item in a Lua table through mw.wikibase.getEntityObject). And those about geographic entities can be big. For Germany, mw.wikibase.getEntityObject("Q183") take about 6 Mb.
There are a few things for which you do not need to load the whole item, like getting the label in the user's language through mw.wikibase.label or the sitelink to the local wiki (ie Commons) through mw.wikibase.sitelink. But if you want to get a Wikipedia link on Commons, you need to load the whole item.
I hope it makes it clearer. --Zolo (talk) 21:04, 28 April 2016 (UTC)Reply
An empty input {{city|}} give "invalid ID" (), which is troublesome in incomplete creator templates. I guess there is an issue with the initial {{#if:{{#invoke:String|match|{{{1|}}}|^Q%d+$|nomatch=}}|{{#invoke:Wikidata|getLabel|entity={{{1|}}}|link=wikipedia}}. --Zolo (talk) 07:37, 13 May 2016 (UTC)Reply
I fixed empty input case. I guess "{{#invoke:String|match||^Q%d+$|nomatch=}}" did not returned empty string as expected, but an error code. --Jarekt (talk) 12:04, 13 May 2016 (UTC)Reply
If we are to use Wikidata, I think we should put data in a separate page rather. I made an untested draft at Module:City + Module:City/data. --Zolo (talk) 07:42, 26 July 2016 (UTC)Reply
That is great and very close to what I had in mind. In the meantime based on this bot run by User:Zhuyifei1999 we have q-codes for most locations recognized by the {{City}}. Yesterday I rewrote {{City}} to call {{Label}} template directly with provided q-codes, bypassing the need to rely on over a thousand location templates. There are still some location templates not converted to use wikidata (see User:Jarekt/a), and those locations do not have a q-code in the current {{City}} template. However it should be easier to write Module:City/data now. Zolo, please continue with Module:City. It would be great If you could test it. I am working at the moment on testing Module:Name. Both of those modules are needed for future Module:Creator. --Jarekt (talk) 12:20, 26 July 2016 (UTC)Reply

Loops edit

I won't be able to investigate it right now, but there is an issue with {{city|{{city|Haarlem}} }} in Creator:Hercules Seghers. --Zolo (talk) 18:22, 13 May 2016 (UTC)Reply

it was a test by user:Multichill. This] will be a better way. --Jarekt (talk) 19:23, 13 May 2016 (UTC)Reply

Rewrite in LUA edit

I tested and improved on Module:City, drafted by User:Zolo. I think it is working correctly now. I had some questions to a larger community at Commons:Village_pump#Template:City_rewrite_in_Lua. Please respond. In the mean time current template no longer test for existence of templates with a given name. Please help me test this module by adding to Module:City/testcases. Unless any new issues are found the current version will go live in a few days. --Jarekt (talk) 13:37, 12 September 2016 (UTC)Reply

  Done --Jarekt (talk) 19:22, 13 September 2016 (UTC)Reply
Return to "City" page.