Fixed: Lua and other errors on Kannada Wikipedia Time templates

Problem statement 1:

“Lua error in Module:TimeAgo at line 60: attempt to perform arithmetic on a string value”

The above error was prominent across many Infobox templates used on Kannada wikipedia where the different of date of birth and the current date was supposed to show when did the person was born, or when the organization was started etc.

For example: Here is how I wanted to see the start date of Wikipedia

ಟೆಂಪ್ಲೇಟು Infobox website   ವಿಕಿಪೀಡಿಯ

Sample testcases for {{Template:Time_ago}} found here never showed a single value in the above format.

Problem statement 2:

I remember working with M.G Harish an another Kannada wikipedian and admin on a similar issue last year where the expressions used in templates were unable to parse the Kannada numerals and used to result in an another error given below:

Expression error: Unrecognized punctuation character “�”

Since 2013 I have been working on articles falling under “Category:Pages with script errors” and working on resolving them step by step. Finding missing templates, modules etc used to be a work around for many such issues. With the expression parse issue reported here on Phabricator I was sure that we needed to understand the modules and templates or atleast mediawiki internals to fix some of these errors effectively. While we got a response from the developers on resolving the expression related issue, I could successfully use the same information fixing the problem statement 1 I have reported above.

To get a clue on similar template usage, I linked the template page to interwiki and found that many Indian and other language wikis use the similar template with some variations. Nepali wiki had the exact same copy of the template {{Template:Time ago}} but with minimal errors. I started skimming through various interlinked modules and template pages to find that the module {{Module:Time ago}} had a small variation in the line 54 and line 60.

 

Line: 54

– local noError, inputTime = pcall( lang.formatDate, lang, ‘U’, args[1], true ) (kn:wiki)

+ local noError, inputTime = pcall( lang.formatDate, lang, ‘xnU’, args[1], true ) (ne:wiki)

Line: 60

– local timeDiff = lang:formatDate( ‘U’, nil, true ) – inputTime (kn:wiki)

+ local timeDiff = lang:formatDate( ‘xnU’, nil, true ) – inputTime (ne:wiki)

The lua error on the first line of this article also clearly says that the error is due to a string that is being passed to perform an arithmetic operation. I applied the small change on the module, previewed the testcases to see the magic of errors disappearing from the screen.

It would be great to get some hands on walk through on the templates, modules, lua and other technologies to ensure language wiki’s look neat and the people working around these technical issues are empowered.

Thanks Ravi for forcing me to post this issue on Wikimedia India Technical Desk. Its a good initiative. It revealed that Punjabi wiki also needed a solution for this and I could apply my findings almost immediately to resolve the problem. Satdeep gill – lets keep exchanging issues and solutions to enhance Indic wiki’s.