Enable fallback languages when retrieving messages

The core function behind wfMessage() (MessageCache->get()) did not
apply the language fallback chain to on-wiki messages.

This patch has changed the behavior to iterate over all possible
languages, first checking on-wiki and then checking the CDB cache,
until it finds the message. Note that fallback languages never
take precedence over the actual requested language.

This patch was taken from the following changes and then
adjusted to fix issues that caused bug 46579.

* Change-Id: Iaaf6ccebd8c40c9602748c58c3a5c73c29e7aa4d
- Author: Matthew Walker <mwalker@wikimedia.org>
- (cherry picked from commit d434bfcf3bbab05660ed8f798a4622487dd8ba56)
* Change-Id: Ib607a446d3499a3c042dce408db5cbaf12fa9e3d
- Author: Mormegil <mormegil@centrum.cz>
- (cherry picked from commit 1b8cb8dc3119bfb12d86d2f044018dc12553939b)

Bug: 1495
Bug: 46579
Change-Id: I420457863eeb79824698d06abc7784032b267af2
Merge "Enable fallback languages when retrieving messages"