Theming

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

Last updated
Categories
Up-to-date with minor version
11.0.x

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.