How to ignore extra whitespaces in translation functions like _e?

My first thought would be to wrap the string in a trim() statement:

<?php _e( trim($text), $domain ) ?>

Would this do what you are wanting it to do or did I misunderstand your question?


EDIT: On looking further at the docs, while technically you may be able to get away with passing a variable, you should not pass variables into translation functions. See the examples section in the docs.

A better bet would be to translate multiple smaller fixed text strings and then join them later, or to adjust your code so that your whitespace is in your PHP and not your string/HTML.