How to use translation functions inside WordPress page

Rather than use a plugin that uses the eval() function, you could write a simple shortcode to handle translations. something like this:

The issue you would face is that the strings wouldn’t be picked up automatically by a tool like POEdit, you would need to manually add the strings to the translation PO files.

/**
 * [__]My string to translate[/__]
 * 
 * @param $atts
 * @param $content
 * @return string|void
 */
function my_translate_shortcode( $atts ,$content ){

    $atts = shortcode_atts( [
        'textdomain' => 'mytextdomain'
    ], $atts );


    return __( $content, $atts['textdomain'] );

}
add_shortcode( '__',  'my_translate_shortcode' );