Move config-based text replacement to the Config class.

So that it can be called easily from anywhere.