Reputation: 14526
I have two specific questions and I hope someone can answer either of them:
mw
library to a stand-alone lua script?Background: I am trying to figure out how to access the output of a wiktionary module (in this case, pron-th
). This is a module that can be dynamically inserted by editors to show transliteration (pronunciation) of Thai words. For example, whenever an editor has added this line:
{{th-pron|ไคฺร่}}
...the server will run the Lua script documented found here and outputs a table showing the various transliterations (example). However, this output is specifically excluded when doing API requests (example) and I cannot find an endpoint that includes this data. And running the lua script directly fails because it is missing several imports, such as mw.ustring
, mw.text
, etc., which I believe are defined in a PHP include higher up their software stack. I have significant PHP experience but none with Lua, so I am sort of at a loss here.
Short of calling up each page directly and scraping the data, I can't think of a way to do this.
Upvotes: 2
Views: 278
Reputation: 611
The MediaWiki mw library is part of the Scribunto extension (see https://github.com/wikimedia/mediawiki-extensions-Scribunto/tree/master/includes/engines/LuaCommon/lualib), and has a lot of dependencies back to MEdiawikis php core, so it won't be easy to just import that.
You could render that wikitext via API like https://en.wiktionary.org/w/api.php?action=parse&text=%20{{th-pron|%E0%B9%84%E0%B8%84%E0%B8%BA%E0%B8%A3%E0%B9%88}}&contentmodel=wikitext and parse the output, or you could try and replace the MediaWiki specific function calls with other function calls to some native Lua library.
Upvotes: 1