Add a third parameter to the constructor to localize error messages. Closes #2140.