[1.7.x] Set compile messages options as class variable

Refs #18714. Same logic as options for makemessages commands.
Backport of 3a435a057 from master.