Brain-WP/BrainMonkey

Add fake translation function __()

salcode opened this issue · 2 comments

I have code I'm testing that includes

$message = __( 'Hello', 'ironcode' );

which is throwing

Error: Call to undefined function

A fake function that returns the first value (i.e. no translation occurs), would be helpful.

Hi Sal,

thanks for your interest and your effort.

Please note that there's already a way to do this.

You do:

Brain\Monkey\Functions::when( '__' )->returnArg();

ans that's it.

It works with all the functions, so no need to create a mock for each of the thousands of WordPress functions...

Please refers to documentation https://brain-wp.github.io/BrainMonkey/docs/functions-when.html

Wonderful, thank you.

My apologies for not reading the documentation more closely.

Thanks for putting me back on the right path.

Have a great day.