Wikipedia talk:Lua

(Redirected from Module talk:Example/sandbox)
Latest comment: 8 days ago by Izno in topic WD or interwiki question

I've hit an impasse and need a little bit of help with a module and a template.

edit

Hello! I am currently in the process of creating an interactive template map of the 2026 Lebanon war. I am essentially "zooming in" on the relevant area from Template:Israeli-Palestinian conflict detailed map; see the image I'm using.

I have created both a module at Module:Sandbox/296cherry and a template in the Template:Template sandbox, although since that page is periodically cleared, I'll just paste the code from that page:

TLDR: I just need help actually transplanting the coded map from the module into the template as a visual, interactive map, like the one on Template:Israeli-Palestinian conflict detailed map. Any help would be greatly appreciated. 296cherry (talk) 04:48, 28 April 2026 (UTC)Reply

I've put it in a format closer to expected. I can't say what else needs to be done. Izno (talk) 05:12, 28 April 2026 (UTC)Reply
Thanks, I appreciate it :) 296cherry (talk) 06:20, 28 April 2026 (UTC)Reply
To anyone who sees this, I still need help btw 296cherry (talk) 19:15, 28 April 2026 (UTC)Reply
First, make your life easier by putting the {{#invoke:Location map/multi|load|Module:Sandbox/296cherry}} in your sandbox.
At Module:Location_map/multi line 210 that module should load Module:Sandbox/296cherry. At line 211 containerArgs gets the contents of the same-named table in your Module:Sandbox/296cherry (line 3).
At line 214, Module:Location_map/multi looks at index '[1]' in containerArgs. If you look at containerArgs in Module:Sandbox/296cherry, you will see that index '[1]' is not defined so string.gmatch() gets nil. You somehow must redefine containerArgs at line 3 in Module:Sandbox/296cherry so that line 214 will be happy.
Trappist the monk (talk) 19:59, 28 April 2026 (UTC)Reply
Okay, I finally got the map of Lebanon to show, but I still need it to be zoomed in (see File:South Lebanon Map.svg). I tried putting in coordinates for the edges of the image but it did nothing. Any ideas? 296cherry (talk) 21:56, 28 April 2026 (UTC)Reply
Probably the right place to be asking these questions, now that I think about it, is Template talk:Location map. Izno (talk) 22:19, 28 April 2026 (UTC)Reply
Collapsed the map.
Don't you have to have a data file? Summat like Module:Location map/data/Lebanon but for Module:Location map/data/South Lebanon and then name 'South Lebanon' in containerArgs?
Trappist the monk (talk) 22:46, 28 April 2026 (UTC)Reply
You're right, I've done just that. It works now! Thank you everyone who helped, my request has been answered. 296cherry (talk) 00:32, 29 April 2026 (UTC)Reply

WD or interwiki question

edit

hi all.

i think i'm reasonably proficient with scribuntu, but one area i never dabbled in is wikibase.

i did RTFM, but failed to find the answer, so asking here:

given a wiki language (say, 'en', 'fr' or 'de') and an article name in that language, i want to get the WD item id (aka QID) of this article.

phase II will be checking to see if there is an article in some _other_ language for same QID, aka "interwiki". bonus points for name of said interwiki in 2nd wiki (in my use case, this 2nd wiki will be the local one).

i believe i'll be able to overcome phase II myself (though i'll appreciate guidance there too), but i hit a wall in step 1: given lang and article name, get QID.

rationale: in hewiki (and prolly elsewhere), we often attach link to existing "foreign" article next to "red" internal links. when writing an article about X, the author may add a red link to Y which does not yet exist in local wiki but does exist in some other wiki. in those cases, the author sometimes adds a link to the "foreign" wikipedia after the redlink (think "poor man's internal link" for readers proficient in this other language). we have a bunch of "foreign link templates" to facilitate those foreign wiki links. now, a year or ten later, someone may finally write article Y locally. this may or may not paint the redlink blue (it can fail if the spelling of the redlink differs from the actual article name - transliteration is not a precise science). when the redlink was painted blue, we simply want to remove the "foreign" link, and when it wasn't, we want to correct the spelling _and_ remove the foreign link. to facilitate this, i'd like to add a maintenance cat for "foreign link template where local article exists". the idea is to teach those "foreign link templates" to add a maintenance category to help with this gnoming task.

TL;DR given a language and article name, find wikidata QID of this article in that language.

thanks in advance,

peace - קיפודנחש (aka kipod) (talk) 22:46, 11 May 2026 (UTC)Reply

Does this not do what you want?
mw.wikibase.getEntityIdForTitle('Abraham Lincoln', 'enwiki') → Q91 → Abraham Lincoln (Q91)
mw.wikibase.getEntityIdForTitle('Abraham Lincoln', 'frwiki')
mw.wikibase.getEntityIdForTitle('Abraham Lincoln', 'dewiki')
and:
mw.wikibase.getEntity('Q91').sitelinks.hewiki → אברהם לינקולן and Q91
mw.wikibase.getEntityIdForTitle('אברהם לינקולן', 'hewiki') → Q91
Trappist the monk (talk) 00:07, 12 May 2026 (UTC)Reply
thank you so much!
i'm sure this appears somewhere in the doc and it's only my flawed reading comprehension skills which made me miss it...
peace. קיפודנחש (aka kipod) (talk) 14:56, 12 May 2026 (UTC)Reply
@Trappist the monk:
FWIW, you may want to look at the module i knitted. it's here: he:יחידה:קישורים לוויקיפדיות זרות.
this adds maintenance cats to pages which contain a "foreign wiki link" template which points to either non-existent page on the other wiki (we want to fix it) or a page which already has local interwiki (we want to remove the foreign-wiki link).
there are 2 weak points, but i do not expect a solution: when the template points to a "foreign" article which is not yet linked to WD, from the module point of view it does not exist (rare but occasionally happens), and a much more prevalent case, when the template is used to link to a redirect on the other side WD does not recognize it, and says "no such thing". so in some cases, the "links to nothing" test pops false positives
with those limitations, we (hewiki community) still think this is very useful, and again, please accept my gratitude.
peace. קיפודנחש (aka kipod) (talk) 23:30, 13 May 2026 (UTC)Reply
@Trappist the monk (and everyone else):
The module works, and the comrades in hewiki think it's useful. kudos! You have my full gratitude.
One fly in the ointment, though: when the name passed to getEntityIdForTitle() represents a redirect, it returns nil (WD is unaware of redirects - all it knows is the name of the "real" article), ,and we raise the "link to non-existent page on foreign wiki" flag
Is there a way to query WD in a way that "respects" redirects? If not, do you know if scribuntu's "new title" works for titles in other projects? I assume this will be considered "expensive" if it's possible at all, but it may be worth it anyway. any other idea how can i ask "is article X exist in wiki Y" which will return the qid and work for redirects?
Peace קיפודנחש (aka kipod) (talk) 17:04, 15 May 2026 (UTC)Reply
If there is a way to do what you want, I don't know of it. As I understand it, except for the specific cases of wikidata and commons, Scribunto has access only to the project where the module is running. So a module running here cannot see anything at he.wiki so cannot learn that the target is a redirect. You might ask at wikidata to see if there is a way to follow redirects to their canonical titles. I guess I'd be surprised ...
Trappist the monk (talk) 19:12, 15 May 2026 (UTC)Reply
Links can be IDd as redirects via badge on Wikidata, but this is a manual process, so will be prone to inaccuracy. I don't know if those are discoverable in the JSON. Izno (talk) 20:06, 15 May 2026 (UTC)Reply