Template talk:Langcode

From OpenStreetMap Wiki
Jump to navigation Jump to search

Revert

The change in early September has not been as successful as intended. It is beneficial for Zh-hans:Map Features and Zh-hant:Map Features where the large processor node count for pages with this language syntax was blowing up rendering but, instead, pages not in Chinese are made more complicated and Map Features in some languages and several project pages cannot be rendered. It did not tackle the underlying problem that the {{langcode|{{{lang|}}}}} syntax, far from being the optimisation that several edits adding it to templates claimed it was in their edit summaries, switches off Mediawiki’s cache and evaluates the template repeatedly instead of once.

As such, I suggest reverting the change for the present.--Andrew (talk) 12:32, 19 September 2018 (UTC)

Thank you for sharing this information and investing your time and effort into that. I do not fully understand this template, so I do have no objections, just the question whether you found out anything that would affect my revision of Template:Relation? --Tigerfell This user is member of the wiki team of OSM (Let's talk) 13:59, 19 September 2018 (UTC)
The Relation template, which cannot be cached because of the relation id argument, includes {{LangSwitch}} (also uncachable) in the Route Manager link, which then calls {{langcode|{{{lang|}}}}} twice. Breaking that chain would be worth doing separately from any bigger rewrite.
Thanks for clarifying.
If you call Lua many times on the same page the page renderer might give up. It may be possible to change the limits set in Mediawiki if there are no undesirable side-effects.--Andrew (talk) 20:57, 19 September 2018 (UTC)
Talking about the "manage" link, I actually planned to remove it, as I can not access this address. I just emailed the webmaster of the domain to check the current status. Thank you again, I will test this a bit more intensively on long pages then. --Tigerfell This user is member of the wiki team of OSM (Let's talk) 21:53, 19 September 2018 (UTC)


I am going to reuse some of the module's code for the lang-switch in the other template as I can not use the template itself. Just that you know. --Tigerfell This user is member of the wiki team of OSM (Let's talk) 18:16, 22 September 2018 (UTC)

Hello @Dragomaniaca:. Unfortunately your change breaks some templates. I saw its effect on Template:Dir and Template:Country
(screenshot - translations are broken and also words are reversed).
I don't know if any other thing would be affected by that change. iriman (talk) 05:56, 3 October 2019 (UTC)

No. None other thing would be affected by this change. It’s approved. We shouldn’t use the {{#if:{{{1|}}}|{{{1}}} parser function, instead we would use {{{1|. Dragomaniaca (talk) 14:37, 3 October 2019 (UTC)
Thanks for clarifying. I'm not a template pro. It would be greate and I would appreciate if you could also update related templates accordingly (esp. dir and country). iriman (talk) 16:17, 3 October 2019 (UTC)
What you mean by "It’s approved"? Mateusz Konieczny (talk) 19:27, 6 October 2019 (UTC)
The screenshot you showed is consistent with a nonsense value of the lang= parameter to {{Place}}. I don’t see how a change here would trigger it unless the weird markup in {{Place}} is responsible. --Andrew (talk) 21:26, 3 October 2019 (UTC)
The change to this template definitely breaks a number of pages that use it. The #invoke command is exceptionally sensitive to formatting, which has caught me out a number of times. --Andrew (talk) 17:23, 6 October 2019 (UTC)

More robust implementation

Module:Langcode relies on passing in a blacklist of prefixes that aren't namespaces. By contrast, Module:Languages's languageFromTitle() and Module:OsmPageTitleParser's parseTitleToObj() both rely on a whitelist of namespaces maintained at Module:OSM Constants and Module:Languages/config, respectively. A whitelist-based approach is more maintainable because the set of language namespaces is more predictable – we can even piggyback on MediaWiki's language list. Perhaps we could migrate this template to either of the whitelist-based functions instead. The other modules and their config modules do add a modest amount to the page size, but the config module gets loaded as data, which means it only gets transcluded into the page once. – Minh Nguyễn 💬 04:47, 28 November 2019 (UTC)

Yes you would appear to be right. There’s also {{Pagelanguage}} with its own whitelist.--Andrew (talk) 07:24, 28 November 2019 (UTC)
This could also return the page content language set in Mediawiki if set to something other than the default of English. Templates that are confident that page languages have been tagged and any pages with a page content language set to English really are in English can use {{PAGELANGUAGE}} instead. --Andrew (talk) 07:39, 28 November 2019 (UTC)
Portal: needs to be added to the blacklist, see Template talk:LangSwitch --Andrew (talk) 21:04, 6 November 2021 (UTC)
Finland: should also be added. --Andrew (talk) 08:41, 7 November 2021 (UTC)

Proposed change: use page content language if set

I propose to change this template to:

{{#if:{{{1|}}}|{{{1}}}|{{#ifeq:{{PAGELANGUAGE}}|en|{{#invoke:langcode|langcode
      |Key=en|POI=en|Tag=en|Relation=en|Canada=en|Iran=en}} }}|{{PAGELANGUAGE}} }}<noinclude>{{Documentation}}</noinclude>

This means that the language returned is the page content language set in Mediawiki if it doesn’t remain defaulted to English, for instance Zoo Osnabrück is reported as German. Note that if you are confident that page content languages are set thoroughly and any page still set to English really is in English you can just use {{PAGELANGUAGE}} instead of {{langcode}}.

--Andrew (talk) 19:11, 18 June 2020 (UTC)

Proposed change: ChangesetKey: pseydo namespace

Resolved: Done. 22:32, 9 November 2023 (UTC)

I propose to change this template to:

{{#if:{{{1|}}}|{{{1}}}|{{#ifeq:{{PAGELANGUAGE}}|en|{{#invoke:langcode|langcode
      |Key=en|POI=en|Tag=en|Relation=en|ChangesetKey=en|Portal=en|Canada=en|Iran=en|Finland=en}}|{{PAGELANGUAGE}} }} }}<noinclude>{{Documentation}}</noinclude>

This change adds support for "ChangesetKey" namespace. See Template_talk:ChangesetKeyDescription -- Something B (talk) 22:53, 4 November 2023 (UTC)

Go ahead. Andrew (talk) 08:26, 5 November 2023 (UTC)
In case of changing we should at the same time include "ChangesetTag" for use in future, so +ChangesetTag=en.
{{#if:{{{1|}}}|{{{1}}}|{{#ifeq:{{PAGELANGUAGE}}|en|{{#invoke:langcode|langcode
      |Key=en|POI=en|Tag=en|Relation=en|ChangesetKey=en|ChangesetTag=en|Portal=en|Canada=en|Iran=en|Finland=en}}|{{PAGELANGUAGE}} }} }}<noinclude>{{Documentation}}</noinclude>
The template is edit protected to users. --Chris2map (talk) 08:55, 5 November 2023 (UTC)
@Wynndale: Could you perform the additions for us, please? --Chris2map (talk) 12:42, 7 November 2023 (UTC)
Only administrators can edit this template. Ask someone like @Minh Nguyen:. Andrew (talk) 20:59, 7 November 2023 (UTC)
@Wynndale: Thanks and sorry for late response. I mistakenly saw you as admin because I was too busy and the last edit of the template was yours (2021). --Chris2map (talk) 17:46, 9 November 2023 (UTC)
@Something B and Wynndale: Fixed. Along the way, I moved everything under Portal:, Canada:, Iran:, and Finland: into (subpages of) the main namespace or the appropriate language pseudonamespace and removed support for these topical pseudonamespaces from this template. I left POI: in place for now because it isn't as clear to me where these pages should go, or if they should be deleted in favor of the Name Suggestion Index. I refrained from adding support for ChangesetTag: for now because nothing resides under that prefix yet. – Minh Nguyễn 💬 17:33, 9 November 2023 (UTC)
@Minh Nguyen: Thank you for performing it! Could you also add "ChangesetTag=en" for future pages like "ChangesetTag:source=survey"? --Chris2map (talk) 17:46, 9 November 2023 (UTC)
@Chris2map: If someone creates such a page, we can add it, but I'm hesitant to make this template any more complex than it needs to be because it's so overused. For what it's worth, I wouldn't have recommended creating a separate namespace for changeset keys and tags in the first place. All we really needed was to add another icon to the "Used on these elements" row of the infobox to indicate whether the key or tag could be used on changesets; then the status could be something other than "discardable". Another option would've been to move these pages to subpages under Changeset, similar to Special:PrefixIndex/OpenHistoricalMap/Tags/ and Osm2pgsql/Key:way_area (before it got deleted out of an abundance of caution). But if there has been a discussion somewhere about creating ChangesetTag: too, we can add it as soon as it's needed. – Minh Nguyễn 💬 20:08, 9 November 2023 (UTC)