Use Drupal.t() for Translatable Strings in JavaScript for Drupal 8, 9, and 10

Sometimes your JavaScript needs to insert new strings into the user interface. In order to ensure that those user-facing strings can be translated into other languages, just like the rest of Drupal's user interface, you should make sure and use the Drupal.t function anytime you output a string of text.

Theming Drupal Sites