Page MenuHomePhabricator

ParserFunction vs magic word for current date elements
Open, Needs TriagePublic

Description

It happens frequently that we copy a template from English Wikipedia into another non-English Wikipedia (in my cast, Persian Wikipedia) and that template uses magic words such as {{CURRENTDAY}} or {{CURRENTYEAR}} which, depending on the context we would need to convert back to English (e.g. when that value is then used by another template or module to do mathematical operations on the date). In situations like this, we are faced with two options:

  • Keep the magic word, but convert its output to English digits using formatnum, e.g. {{formatnum:{{CURRENTDAY}}|R}}
  • Replace the magic word with a parser function that has a formatting parameter, e.g. replace {{CURRENTDAY}} with {{#time: j ||en}}

Can anyone explain, heuristically or empirically, which of these choices is better? By "better" I mean better performance, lesser likelihood of hitting the parser's maxima (some of these templates are quite involved), etc.