Refactor and clean up gettext management