Page MenuHomePhabricator

Create a {{PAGEVIEWLANGUAGE}} magic word
Open, Needs TriagePublic

Description

Would like to introduce the creation of a magic word {{PAGEVIEWLANGUAGE}} returning the page view language (variant) of the current page.

It would be particularly useful for the LanguageConverter and the Translate extension in order to better localize the translations. For instance the page title template will broken if using the -{ }- syntax:

{{PAGENAME:-{zh:zh; zh-hans:zh-Hans; zh-hant:zh-Hant; zh-hk:zh-Hant-HK;}-}}<!-- return empty string -->

However, it will be fixed by using a syntax like:

{{PAGENAME:{{#switch:{{PAGEVIEWLANGUAGE}}|zh=zh|zh-hans|zh-cn|zh-sg|zh-mo=zh-Hans|zh-hant|zh-tw=zh-Hant|zh-hk|zh-mo=zh-Hant-HK
}}}}

See: https://www.mediawiki.org/wiki/Template:Localized_link

Event Timeline

Sounds a bit like duplicate of T4085: Add a {{USERLANGUAGE}} magic word. It is not possible to distinct the parser result on the view language, that would break caching etc.

Maybe the {{TRANSLATIONLANGUAGE}} mention there can help as well.

If you only want to distinct the result on the variant, that maybe easier to implement in the parser structure as this generic way to distinct the result on the views language.

-{zh:{{PAGENAME:zh}}; zh-hans:{{PAGENAME:zh-Hans}}; zh-hant:{{PAGENAME:zh-Hant}}; zh-hk:{{PAGENAME:zh-Hant-HK}};}-

It is not possible to distinct the parser result on the view language, that would break caching etc.

The parser result already distinct with the converted content, even in caching.

Sounds a bit like duplicate of T4085: Add a {{USERLANGUAGE}} magic word. It is not possible to distinct the parser result on the view language, that would break caching etc.

As an aside, we already do this for {{int:... and on some wikis (commons) the majority of pages are already split by user language. i think most of the objections are trying to get toothpaste back in the tube.

Regardless still probably a dupe.

Then, is there any good solution for something like [[File:Foo.svg|lang={{PAGEVIEWLANGUAGE}}]] ?

It is very stupid to wrote something like -{zh-hans:[[File:Foo.svg|lang=zh-hans]]; zh-hant:[[File:Foo.svg|lang=zh-hant]]; zh-hk:[[File:Foo.svg|lang=zh-hant-hk]];}- .