mw.jqueryMsg: Handle non-string parameters to functions that expect strings better
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 10 Sep 2018 09:08:00 +0000 (11:08 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 12 Sep 2018 21:23:31 +0000 (23:23 +0200)
commit724fbe82c15cfb8a7d79155bfa2d66e0abbc832a
tree39ede81c07e8af0b6ca81317a74036205c8195ab
parent76e72fd4c4262e71b7dc927cb07bf4957cc78554
mw.jqueryMsg: Handle non-string parameters to functions that expect strings better

Generally, non-string parameters should not be passed to functions
that expect strings. But sometimes we don't document the types well
and our translators do unexpected things. :)

* If the function uses the parameter to look up some other value
  (e.g. {{GENDER:$1|...}}, {{PLURAL:$1|...}}), convert it to a string
  by removing all formatting (using textify()) and hope for the best.
* If the function applies some textual transformation to the parameter
  (e.g. {{GRAMMAR:...|$1}}, {{formatnum:$1}}), do nothing and return
  the original parameter.

Bug: T203892
Change-Id: I5c760bf666cc8dae4ce10e3319366e73e2d596e8
resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js