Page MenuHomePhabricator

Add ability to fetch the page language in Scribunto
Closed, DuplicatePublicFeature

Description

Feature summary:

Scributno should provide an interface to fetch the language of the current page.

Use case(s):

I am writing a Lua module for the Community Wishlist Survey, which has translatable pages on Meta. When viewing these translatable pages directly, I do not want some things to appear. One naive solution is to compare the subpage name with the value of the page language. If they are the same, we can assume (99% of the time) that we're on a translatable page. Currently I cannot get the page language through Scribunto. Instead I must pass in {{PAGELANGUAGE}} when the module is invoked.

Benefits:

This would allow module programmers to easily fetch the page language from Lua code, allowing various templates on Meta, Commons, and other multilingual wikis could be re-implemented in Lua.

We are able to fetch many properties about the current page, such as the content model, and even the content itself. I think being able to fetch the page language would be a natural fit for the already somewhat rich language library that Scribunto offers. I am tempted to suspect it only wasn't added because {{PAGELANGUAGE}} wasn't introduced (~2017) until after Scribunto was deployed.

Event Timeline

MusikAnimal updated the task description. (Show Details)
MusikAnimal added a subscriber: Pcoombe.

Change 844519 had a related patch set uploaded (by Reedy; author: Reedy):

[mediawiki/extensions/Scribunto@master] TitleLibrary: Add getPageLangCode

https://gerrit.wikimedia.org/r/844519

Change 844519 merged by jenkins-bot:

[mediawiki/extensions/Scribunto@master] mw.title: add `pageLang` property

https://gerrit.wikimedia.org/r/844519