Page MenuHomePhabricator

uselang parameter for action=parse?
Closed, ResolvedPublic


Could we have a uselang parameter for action=parse, please?

Background: the Commons uses a {{LangSwitch}} template to provide content in the user's interface language (license templates, the {{information}} template, and others). This works pretty well (from a user perspective; I don't know if it's actually 100% sound what they do, see T16404... but I guess if it really weren't OK, it would've been shut down long ago.) It even works when a file description page is viewed at another wiki (non-local file).

However, if we want to get information through JavaScript from some other wiki about a file on the Commons (such as the file description), we cannot use a direct API call at the commons due to cross-domain restrictions. Using an importScript with a callback works, but treats the user as a non-logged-in anon. So you can't present, through JavaScript, information from the Commons respecting the user language setting. (A local API call would just return information about the non-existing local file or file page, so that's no good either.)

With a uselang parameter for action=parse, that'd be possible. (If that uselang parameter was honored even if the user is treated as an anon, that is.)

Version: 1.16.x
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:01 PM
bzimport set Reference to bz22764.

(In reply to comment #1)

(given that its not documented to work as such, i have no idea if that is a
"feature" or a "bug").

You're right, this works by accident. It should be documented and given a different name for stability (who knows if this'll break when someone moves the uselang processing code to some other place).

Hm. That's what I get for just looking at the documentation (and I even did look at ApiParse.php, but didn't and don't see it there either). Next time I'll just experiment the hell out of it. :-)

Anyway, where's that uselang handling?

Could we keep it without renaming the parameter?

Presumably one of the parameters is passed into the parser or something...

Roan, if you decide how you want to do it, i'll take care of it

I'm fine with keeping the param name on principle. I think uselang is handled by the code that initializes $wgLang (Setup.php or something). The best way to go about this IMO would be to call the parameter uselang and check that $wgLang doesn't just happen to already be in the right language (as long as uselang works the way it currently does. this will always be the case) so we can do $lang = $wgLang; instead of creating our own Language object.