[00:16:13] If I wanted to file a request regarding how MediaWiki handles a page's language, is that a core thing or something else? [00:20:07] Yeah [00:21:14] Basically all language support stuff is in core, with a few rare exceptions [00:21:36] Okay. Before I do so, I want to run it by you all. One issue I am running into is that CSSJanus is *great* when it identifies the page content as a RTL language, and does its RTL thing. The problem, though, is that I have pages where everything is loaded through templates based on the *user* language. So I will load Arabic content on a page, but because the page is nominally an English page, the RTL transformations don't apply. [00:21:59] I'm not sure if my specific ask should be to allow overriding a page language via parserfunction, or to create the notion of a language-neutral page, or what. [00:22:48] User language is not appropriate for content, really [00:22:53] Why not? [00:23:03] Requires cache variations [00:23:36] I mean, if content on the page is arabic, it should be reported as an arabic page, not english [00:23:41] Why would it be english? [00:23:52] Because MediaWiki doesn't know better? [00:24:04] Well, we can set languages per-page, right? [00:24:36] Are you in the office? It might be easier if I show you these things [00:25:07] I am not :p [00:25:36] Well, in any case, let me introduce you to the Wikimedia Resource Center, which is essentially model–view–controller but in Lua. [00:25:56] Anyway, I'm not the best person to ask really. I dunno much about CSSJanus or page languages. Just to answer your original question: CSSJanus and page languages are both core functionality :) [00:26:13] Sure. [00:26:34] One more question, since you brought it up – is it actively harmful for me to generate page content based on user language? [00:27:44] Ehh, not the worst thing in the world. We cache on it (we didn't used to, hehe). But it's why we've long avoided stuff like {{USERLANGUAGE}} or whatever because it *encourages* poorly-cacheable output [00:27:45] :) [00:29:08] Collectively these pages that do this dynamic content stuff have gotten 286 views in the last 2 weeks (i.e. since they launched) [00:29:24] Indeed, not the end of the world ;-) [00:29:57] Ideally they'll get more views, but not to the point that it busts Wikimedia's infrastructure. It's designed for a fairly specific audience. [01:38:08] RainbowSprinkles, you know about {{int:lang}} on Commons? :P [01:50:54] int:lang is on Meta too and I love it [17:16:04] anomie: would it be a crazy idea to add an overridable method to ApiBase for transforming caught exceptions into errors? [17:16:28] it seems like a waste of lines to add try...catch...dieWithException everywhere [17:17:47] tgr: How would ApiMain know which module's method to call? [17:18:18] For something like ApiQuery, it's not necessarily the action module [17:18:54] I see, I did not think of that [17:20:00] Having to do that a lot may be a sign that you're using exceptions for control flow rather than actual exceptional conditions. [17:20:26] (and yes, ApiUsageException is hugely guilty of that) [17:21:02] using them for control flow when there is an error and processing needs to be aborted does not seem like a bad thing to me [17:21:22] Depends on the situation [17:21:32] I tried using lots of StatusValues but the lack of return typehints annoyed me [17:24:08] how about wrapping execute() in something that can transform other exceptions into ApiUsageExceptions? then ApiQuery could wrap its calls to each submodule separately [17:24:29] and it would be clear which submodule's method to call [17:24:58] You could do that in your module without making any change to ApiBase. function execute() { try { ... } catch ( Exception $ex ) { ... } } [17:25:45] Or function execute() { try { $this->realExecute(); } catch ( ... ) { ... } } if you really want. [17:27:17] Just make sure to rethrow ApiUsageException, and maybe DBError if you don't want nonstandard handling for that. [17:32:36] yeah, I don't want to catch everything, just the specific exception that I throw for invalid operations [19:07:01] is there any way to convert a wiki domain into an interwiki prefix? [19:09:00] I guess I can parse the interwiki table, but I'm hoping something does that already [19:48:48] tgr: you mean like en.wikipedia.org to :w:en: or whatever? [19:49:20] bd808: yeah [19:49:33] I found InterwikiLookup::getAllPrefixes in the meanwhile which at least does the DB query [19:51:15] but wiki where both the project and the language differs aren't even interwikis technically so I guess I need to rethink what I want to do [19:56:01] tgr: there may be weird stuff to do this in core from wikidata... [19:56:20] there are like 3 different interwiki lookup systems that do different things :/ [19:57:01] VE does it somehow [19:57:29] if you add a URL that is also an interwiki prefix it changes it to an interwiki link [20:04:52] legoktm: Parsoid does it. VE's just a dumb HTML editor. [20:05:27] tgr, legoktm: So… roundtrip the request via the Parsoid API. ;-) [20:30:11] tgr, https://github.com/wikimedia/parsoid/blob/master/lib/config/WikiConfig.js#L213-L291 /cc bd808 legoktm James_F is the code in question that is used elsewhere (https://github.com/wikimedia/parsoid/blob/master/lib/html2wt/LinkHandler.js#L186-L221 ) [20:30:49] thx! [20:30:53] link handling is a big complicated mess overall. [20:34:20] tgr, but yes James_F comment is valid .. is there a usecase to expose this as an (utility) api endpoint? [20:34:43] in my case, not really [20:34:59] reading lists will store pages as domain+title [20:35:08] ok [20:35:27] since the apps use them to interact with restbase apis [20:35:51] also the domain -> interwiki prefix gets translated in the context of what the home wiki is .. since we look up the interwiki map as set up for that local wiki. [20:35:53] I was thinking about how to use that data for an api.php generator [20:36:21] which can return interwikis, although I guess they are fairly useless [22:44:14] so I just learned the "dir" attribute is a thing [22:44:17] On a Friday afternoon [22:44:24] After spending all this time doing these fixes by hand [22:44:38] dir=rtl dir=ltr