Wikipedia talk:Lua
To help centralize discussions and keep related topics together, all Wikipedia:Lua subpages' talk pages and Help talk:Lua redirect here. |
The contents of the Wikipedia:Lua/Requests page were merged into Wikipedia talk:Lua on 5 February 2016. For the contribution history and old versions of the redirected page, please see its history. |
Wikipedia:Lua/To do was nominated for deletion on 21 May 2015. The result of the discussion was keep. |
This page has archives. Sections older than 90 days may be automatically archived by ClueBot III when more than 1 section is present. |
Script error
Hi, Could someone please help me to fix Module:Location map's coord2text
problem on Bengali wikipedia. See the problem here. Because of this, 200+ pages showing script error. --Aftabuzzaman (talk) 16:42, 22 April 2017 (UTC)
- I can't take the time now to fully investigate, but for anyone wanting a quick introduction, the problem appears to be as follows.
- Module:Location map has been copied to bn:Module:অবস্থান মানচিত্র.
- The latter has been edited to translate error messages.
- However, it also translates some other items such as:
local moduletitle = mw.title.new('Module:Location map/data/' .. map)
local moduletitle = mw.title.new('মডিউল:অবস্থান মানচিত্র/উপাত্ত/' .. map)
- It is conceivable that a problem could arise because the required subpage is missing or has a problem.
- My first approach was going to be pasting a copy of the enwiki module into the bnwiki page (but not saving), then use the preview to show what happens on one of the pages with an error. Would the result (using the enwiki version) display an error? The same error? However, the page is protected so I can't do that, and setting up a sandbox test would take too long.
- I see there are some
mw.log
lines in the module. I wonder if they show any useful information when the module is somehow invoked while editing the module. Johnuniq (talk) 05:40, 23 April 2017 (UTC)- @Johnuniq: Another issue is that the regex for the coord2text function doesn't work because while it searches for strings like
22.467°N 92.117°E
, in bnwiki the equivalent text generated by {{Coord}} is<span dir="ltr">২২.৪৬৭°</span> উত্তর <span dir="ltr">৯২.১১৭°</span> পূর্ব
. I cannot read the text and don't really know how Lua handles this, so alternatively the module could search for<span class="geo">22.467; 92.117</span>
. Jc86035 (talk) Use {{re|Jc86035}}
to reply to me 07:04, 23 April 2017 (UTC)- @Jc86035: Thanks, that sounds like the reason. I worked on bn:Module:Convert three years ago and have code to convert bn digits to en. That might help if the module needs the actual values (I suspect something needs them because I have seen a couple of coord errors in articles where 0° W was used, and that is rejected, while 0° E is accepted. Johnuniq (talk) 07:47, 23 April 2017 (UTC)
- @Jc86035 and Johnuniq: I removed those
<span dir="ltr"></span><span dir="ltr"></span>
tags from module. I set up test pages for you. Please use Module:Location map/sandbox, Module:Coordinates/sandbox & Template:Location map/sandbox (for testing module). Do whatever you need to do. --Aftabuzzaman (talk) 17:08, 23 April 2017 (UTC)
- @Jc86035 and Johnuniq: I removed those
- @Jc86035: Thanks, that sounds like the reason. I worked on bn:Module:Convert three years ago and have code to convert bn digits to en. That might help if the module needs the actual values (I suspect something needs them because I have seen a couple of coord errors in articles where 0° W was used, and that is rejected, while 0° E is accepted. Johnuniq (talk) 07:47, 23 April 2017 (UTC)
- @Johnuniq: Another issue is that the regex for the coord2text function doesn't work because while it searches for strings like
Preliminary results follow. I might be able to think more in a day or two. Pasting {{Coord|44|26|N|15|3|E}}
into bn:Special:ExpandTemplates shows a long result. Some of that is:
- ৪৪.৪৩৩° উত্তর ১৫.০৫০° পূর্ব
At enwiki, the corresponding text is:
- 44.433°N 15.050°E
The module fails with the "Malformed coordinates" error because it looks for the exact format used at enwiki, namely
<number>°N<space><number>°E
where <number> consists of enwiki digits or a dot. This is due to the regex mentioned by Jc86035 above. Johnuniq (talk) 11:39, 24 April 2017 (UTC)
- @Johnuniq: I think i found a solution on persian wikipedia. It seems working. See the test page (& diff). Is it ok? is any correction needed? --Aftabuzzaman (talk) 17:00, 24 April 2017 (UTC)
- It seems fine although I have not studied the details. However I tell you about a couple of problems that I noticed. You can fix them, or if wanted, I can have a go later.
- First, repeating code is not desirable. I can see the rationale behind using a separate require for Module:Numeral_converter, once for each of the five times it is used. It is possible to do a single require on the first call (that is, only call require if it is needed), but it would make the code a bit harder to follow. However, there are 12 lines repeated in p.main and p.mark. They should be put into a function and called when needed. And the two loops are unnecessary—one is all that is needed and it would be easier to comprehend.
- Second, I'm not sure why the new coord2 variable is used, although if I were to study it I would probably see a reason. However, there is a bug. If mw.ustring.match fails to find a match (very possible given that it is working with user input), coord2 would be nil. Executing coord2:gsub would then crash the script. The code has
coord2 or ''
but that comes too late. - I had a very quick look at bn:Module:Numeral converter and noticed that p.convert is not efficient. If there is ever a problem from it being used many times on a page and the result being too slow, I could speed it up, although the cost would be some increase in code complexity. Johnuniq (talk) 05:19, 25 April 2017 (UTC)
- @Johnuniq: Please fix there and for Module:Numeral converter here. You know i don't understand much lua, it is difficult for me to fix them.--Aftabuzzaman (talk) 14:50, 25 April 2017 (UTC)
- @Johnuniq: any progress? --Aftabuzzaman (talk) 14:09, 10 May 2017 (UTC)
- Sorry, I've been busy, and still am. I might be free in about a week. Johnuniq (talk) 03:22, 11 May 2017 (UTC)
- Ok, no problem. I can wait. --Aftabuzzaman (talk) 15:38, 11 May 2017 (UTC)
- @Johnuniq: Sorry for disturbing. I waited 3 months but no one even comment here. Could you please take a look. You don't have to explain here, just edit there. Thanks again. --Aftabuzzaman (talk) 16:56, 3 August 2017 (UTC)
- Ok, no problem. I can wait. --Aftabuzzaman (talk) 15:38, 11 May 2017 (UTC)
- Sorry, I've been busy, and still am. I might be free in about a week. Johnuniq (talk) 03:22, 11 May 2017 (UTC)
- @Johnuniq: any progress? --Aftabuzzaman (talk) 14:09, 10 May 2017 (UTC)
- @Johnuniq: Please fix there and for Module:Numeral converter here. You know i don't understand much lua, it is difficult for me to fix them.--Aftabuzzaman (talk) 14:50, 25 April 2017 (UTC)
- @Johnuniq: I think i found a solution on persian wikipedia. It seems working. See the test page (& diff). Is it ok? is any correction needed? --Aftabuzzaman (talk) 17:00, 24 April 2017 (UTC)
@Aftabuzzaman: Please briefly bring me up to date about the current status. Do the three pages you mentioned at "test pages for you" above contain the current wikitext, and are they are ready for me to experiment? I'm wondering about your "I think i found a solution" above. Did that solution get implemented and did it work? It seems bn:মধ্যমগ্রাম is showing the "Malformed coordinates" error due to what I said at 11:39, 24 April 2017 above. I should be able to have a look when you reply, although it won't be quick. Johnuniq (talk) 05:48, 4 August 2017 (UTC)
- @Johnuniq: No, i didn't implemented because of what you said at 05:19, 25 April 2017 (UTC). Yes, those three page has same wikitext as en.wiki (with solution). Solution still works but as you said, solution have some problem, 12 lines repeated there, If mw.ustring.match has bug (see your comment at 05:19, 25 April 2017 (UTC)). Yes, they are ready for your experiment. --Aftabuzzaman (talk) 15:37, 4 August 2017 (UTC)
- I have started looking at the issue and further discussion is at bn:User talk:Johnuniq#Module:Location map. Johnuniq (talk) 10:22, 5 August 2017 (UTC)
(Urgent) Help needed for intensively used Module:Syrian_Civil_War_detailed_map
Hi,
We had to split the intensively used Module:Syrian_Civil_War_detailed_map into a detailed map and an overview map.
Because the huge middle eastern conflict map could no longer include the whole detailed map because it had become to large.
After a lot of work Module:Syrian_Civil_War_detailed_map now successfully inlcudes Module:Syrian_Civil_War_overview_map with all the large towns and strategic places and the huge middle eastern conflict map succesfully includes the new Module:Syrian_Civil_War_overview_map instead of the Module:Syrian_Civil_War_detailed_map
Yet a new problem occurred with the Module:Syrian_Civil_War_detailed_map that I don't understand can't solve.
All villages after +- line 2700 won't display. While before it displayed more than 7000 lines.
Can anyone look at it and try to solve it?
The module is intensively monitored by large amount of people and it should be remain out of fully working order for to long.
Kind regards, --Niele~enwiki (talk) 20:13, 26 July 2017 (UTC)
- Per Talk:Cities and towns during the Syrian Civil War#when will the map be restored, the problem may be resolved now? Johnuniq (talk) 01:29, 27 July 2017 (UTC)
Why does a reverted change persist?
Despite this removal of code "ç" from Module:IPAc-en/phonemes, it still persists in pages that use it. Before the code was added, the error "[invalid input: 'ç']" showed at Mary Hamilton#Lyrics amidst the pronunciation spelling of note 3. Why does this error not show again now the code has been removed? Is this a caching issue? — Sebastian 08:42, 9 August 2017 (UTC)
- No, it is not a caching issue. An easy way to see that is to edit the whole page, then preview the result. Observe that the error appears in the preview, then close the window to discard the edit.
- Consider:
{{IPAc-en|n|i|ç|t}}
→ /ni[invalid input: 'ç']t/{{IPAc-en|n|i|t}}
→ /nit/
- What should the first template (copied from the article) do? Johnuniq (talk) 10:48, 9 August 2017 (UTC)
- Thank you for your patient answer and for the editing trick, which I will use next time. (BTW, it now shows up as error even in the article itself without editing. So, if not caching, at least time appears to be involved somehow. Or maybe that is because I displayed this page first, which may have triggered a rerun of the script.)
- The template {{IPAc-en}} is used to display English International Phonetic Alphabet (IPA). The change in question is now under discussion at Template talk:IPAc-en#Addition of /ç/ — Sebastian 11:30, 9 August 2017 (UTC)
- I guess I disagree a bit with Editor Johnuniq. Editor SebastianHelm added the code for 'ç' to Module:IPAc-en/phonemes with this edit and in the same minute added
{{IPAc-en|n|i|ç|t}}
to Mary Hamilton with with this edit. And all was good; no errors. Half-hour later, Editor Nardog rises to object and reverts. The question was:Why does this error not show again now the code has been removed?
(emphasis added). The error did not show because the job queue had not yet got round to refreshing all of the pages that use Module:IPAc-en/phonemes. The error shows now because someone purged or null edited Mary Hamilton or because the job queue got round to refreshing it. - —Trappist the monk (talk) 12:10, 9 August 2017 (UTC)
- Thank you, Trappist the monk, that explains it very well. — Sebastian 13:00, 9 August 2017 (UTC)
- Oh. I was a bit rushed and did not see the point in the OP. When I looked at the article, it was showing the red "invalid input: 'ç'" above, and I imagined the question was why was the error visible. Johnuniq (talk) 10:57, 10 August 2017 (UTC)
- I guess I disagree a bit with Editor Johnuniq. Editor SebastianHelm added the code for 'ç' to Module:IPAc-en/phonemes with this edit and in the same minute added
Did someone write a text-to-math module yet?
Last I knew, eval() was disabled for security reasons and seemed highly unlikely ever to be available. I ran across a comment on the Refdesk that "The metabolic cost of walking (Cw) in J/(Kg *m) was empirically determined to be 280.5i5-58.7i4-76.8i3+51.9i2+19.6i+2.5 where i is the incline..." which is when I remembered that I'd meant to write some kind of function to evaluate math expressions input as text. I'd probably want to access it indirectly from my old prototype Module:Plotter to do something like {{#invoke:Plotter|eval|280.5*i^5-58.7*i^4-76.8*i^3+51.9*i^2+19.6*i+2.5|left=0|right=0.9|step=0.05}} So I'd want to chunk the text according to at least five basic arithmetic operators and have a pass-through for Math. and Module:Math functions. Anyway, it would be a big project if done right, so I should check to see if anyone has done it. Also I think there was some magic word to do it in wikipedia format and maybe it can be sent out as a call also; I'm not sure how that would compare with just doing it by Lua. I won't ask anyone to write this since it seems like a good exercise to refresh my memory, and not urgent. Wnt (talk) 20:30, 11 August 2017 (UTC)
- If
{{#expr:}}
would do what you want, you could use mw.ext.ParserFunctions.expr to do it. Anomie⚔ 23:05, 11 August 2017 (UTC) - I put a simple expression evaluator in Module:Convert/makeunits—search for "evaluate expressions" to see it. It will not do anything like the ambitious project in the OP, but it allows the scale of a unit to be specified with simple operators such as
0.9144^3/3600
. It does not support unary operators (negation). I mention that for anyone interested but WOSlinker is correct that #expr should be used. Try this in a module:return frame:callParserFunction{ name = '#expr', args = { '0.9144^3/3600' } }
- However, it uses #expr syntax. Johnuniq (talk) 23:31, 11 August 2017 (UTC)
Need Help with Template:Dts
I want to extend / refine the nowrap=off
argument of the dts template in such a way, that only the year is wrapable, (for rationale see here Template talk:Dts). Best way is probably to create a new argument like wrap=year
, however I leave that to the implementer. The Lua code for dts is here: Module:Dts. Any help greatly appreciated, thanks. Wikiinger (talk) 10:05, 17 August 2017 (UTC)
Discussion at Template talk:Authority control
Would someone familiar with Lua and Wikidata please take a look at Template talk:Authority control#Tracking categories. Thanks. — JJMC89 (T·C) 17:43, 18 August 2017 (UTC)
Do you have small Lua related tasks suitable for new contributors?
Hi everybody! Google Code-in (GCI) will soon take place again - a seven week long contest for 13-17 year old students to contribute to free software projects. Tasks should take an experienced contributed about two or three hours and can be of the categories Code, Documentation/Training, Outreach/Research, Quality Assurance, and User Interface/Design. Do you have any Lua / template related idea for a task (needs documentation, or some code / code changes) and can imagine enjoying mentoring such a task to help a new contributor? If yes, please check out mw:Google Code-in/2017 and become a mentor! Thanks in advance! --AKlapper (WMF) (talk) 19:50, 16 October 2017 (UTC)
- @AKlapper (WMF): Would converting a MediaWiki parser code template to Lua count? I'd like to see Template:Term and perhaps some of the draft features in Template:Term/sandbox, redone in Lua for efficiency. In a long glossary article like Glossary of cue sports terms this template can be used hundreds of times. Ideally the
|id=
parameter would be made more "bulletproof"; I did a little work on that earlier to day, but it's still fairly easy to break it, either by producing invalid output or just not useful output (it should produce a "clean" word to server as a link target, like "break" or "stakehorse", without any extraneous markup. — SMcCandlish ☏ ¢ >ʌⱷ҅ᴥⱷʌ< 10:01, 17 October 2017 (UTC)- @SMcCandlish: Thanks for the interest! Anything task that is not too complex (or can be broken down into subtasks) is welcome, if you volunteer to mentor such tasks or have a mentor in mind! :) --AKlapper (WMF) (talk) 16:04, 18 October 2017 (UTC)