Wikipedia:Lua requests

From Wikipedia, the free encyclopedia
Jump to: navigation, search
  WP:Lua
Project
  WT:Lua
Project talk
  Modules
 
  Help
 
  To do
 
  Requests
 
  Resources
en: m: mw: external
 
Shortcuts:

Lua scripts on Wikipedia are similar to templates but useful for performing more complex tasks for which templates are too complex or slow. Common examples include numeric computations, string manipulation and parsing, and decision trees. You can use this page to request help from Lua developers in writing a Lua module for a specific task on Wikipedia or another Wikimedia Foundation project. Both debugging help and full implementation are available.

To start a request, just make a new section below and describe what you need. You may wish to first check Special:PrefixIndex/Module: to see if you can find a suitable existing script.

It may help developers to provide examples of where the task is likely to be useful within Wikipedia. If the proposal would replace or improve upon existing templates, please note which ones.

Help fix Script error on Telugu WP Templates which are imported from English WP[edit]

https://te.wikipedia.org/w/index.php?title=Template:Yesno&oldid=1405292 Template page shows error "Script error: Lua error at line 1: unexpected symbol near '{'" and displays the template script, which is usually not shown. Similarly https://te.wikipedia.org/w/index.php?title=Template:Category_handler also shows same error, probably related to Documentation. --Arjunaraoc (talk) 01:42, 10 February 2015 (UTC)

@Arjunaraoc: You somehow imported our template as a module. Re-import the template as the template and the module as the module, deleting what's already there if necessary. Jackmcbarn (talk) 03:10, 10 February 2015 (UTC)
Thanks Jackmcbarn for your response. Your suggestion worked. --Arjunaraoc (talk) 08:09, 10 February 2015 (UTC)

Module:Episode list[edit]

Hello, I'm from Korean Wikipedia. I'd like to make a alias parameter(i.e. Korean parameter name) on my kowiki but I don't know how to do it. I need some help.--Namoroka (talk) 05:09, 15 February 2015 (UTC)

I might be able to help if you can give a clear example of what currently works, and something which does not work now, but which you want. On a talk or sandbox page at kowiki would be fine. By example, I mean a template or whatever that calls the module, preferably with a brief description of what it does.
Oh. Editing the wikitext to post my comment revealed the table at the side, tucked under the archive box. This looks simple, I think, but I still want examples because looking at code without knowing how it is called is a waste of time. Johnuniq (talk) 06:16, 15 February 2015 (UTC)
I copied Module:Episode list to here and it works well in English(original) parameters. So I'd like to translate English parameter names into Korean names.--Namoroka (talk) 07:20, 15 February 2015 (UTC)
I edited ko:Module:Episode list to include the aliases you gave. Please check them carefully because I just did a quick copy/paste from the displayed html, and that sometimes corrupts characters. You should now be able to use either enwiki or kowiki argument names; if both are given, the kowiki value will be used. See my comment about _mod. It probably does not matter, but I used Lua's mod function because ko:Module:Math is out of date and does not include _mod. I can't resist fiddling a little when editing code, but I only did that on stuff I had to change anyway. I kept all the enwiki names in the module and I suggest you do not try to change that because in the future people will probably want to compare the enwiki and kowiki versions to see if updates are needed, and that will be a lot easier if changes are kept to a minimum. You don't have to translate "Module" and you could restore them. Johnuniq (talk) 09:21, 15 February 2015 (UTC)
By the way, in case it's not obvious, I have not tested the code and have no idea if it works! Let me know what a thorough test shows. Johnuniq (talk) 09:26, 15 February 2015 (UTC)
It works gretly in both English and Korean. Thank you very much indeed! I will update ko:Module:Math soon. Thank you once again.--Namoroka (talk) 09:39, 15 February 2015 (UTC)

On reflection, what I put in the module is theoretically broken because it only captures expected arguments, namely those listed in the aliases table. If any other arguments, such as an unnamed argument, were used, they would be omitted. I don't think that would be a problem with this module, but following is what I think would fix it (again, very untested).

local aliases = {
	['에피소드 번호'] = 'EpisodeNumber',
	['에피소드 번호 2'] = 'EpisodeNumber2',
	['제목'] = 'Title',
	['제목 주석'] = 'RTitle',
	['부제'] = 'AltTitle',
	['부제 주석'] = 'RAltTitle',
	['예비1'] = 'Aux1',
	['감독'] = 'DirectedBy',
	['각본'] = 'WrittenBy',
	['예비2'] = 'Aux2',
	['예비3'] = 'Aux3',
	['본방송일자'] = 'OriginalAirDate',
	['방송일자 2'] = 'AltDate',
	['작품번호'] = 'ProdCode',
	['시청률'] = 'Viewers',
	['예비4'] = 'Aux4',
	['요약'] = 'ShortSummary',
	['선색'] = 'LineColor',
	['윗색'] = 'TopColor',
	['열색'] = 'RowColor',
}
 
local function local_args(args)
	-- Return a new table of arguments using any given local options.
	local result = {}
	for k, v in pairs(args) do
		result[aliases[k] or k] = v
	end
	return result
end

The above operates differently from my previous effort: if both enwiki and kowiki names are given for a particular argument, the result is undefined (either the enwiki or the kowiki value will be used, but it might be either). That situation should never arise so is not a concern.

Module:Episode list has a slight misunderstanding: it refers to args['1'] but that should never occur—the module should be using args[1] for the first unnamed argument. Therefore, I don't think the above fix would achieve anything, but I'm mentioning it in case anyone else wants to look at the code for other places. Johnuniq (talk) 22:28, 15 February 2015 (UTC)

There was something wrong with previous code. When {{Episode list/sublist}} is transcluded onto the main list, all |ShortSummary=s should be hided, but it doesn't work on kowiki. Now I replaced args['1'] with args[1], and it works well. Thank you.--Namoroka (talk) 09:45, 17 February 2015 (UTC)