Add language localisation to javascript alert?

This is a way to do this without wp_localize_script. I do it this way with forms and scripts when I want to visualize the output inside a HEREDOC. I name a variable something like the string in my native English, l18n it first, and then put it where it goes in the heredoc:

$someText = __('Some Text', 'myPluginSlug');
$helloWorld = __('Hello World!!', 'myPluginSlug');

$output = <<<OUTPUT

   $someText

   <script>
      alert('$helloWorld');
   </script>

OUTPUT;

return $output;