Extract Drupal.t and Drupal.formatPlural calls from your webpack bundles.
The plugin will gather all those calls in one single file and emit them. Then you can add this file to your Drupal theme library. Drupal will pick it up and run its regex over it, so that those translations end up in the Frontend.
How to use
Add the plugin to your webpack config
You can use both translation functions everywhere, but you need to tell webpack that Drupal is a global object:
Also, if you use ESLint, you want to declare Drupal a global object:
It's important that you use the functions like normal, e.g. not write
or otherwise wrap them in your own function, etc. The plugin is rather "dumb"; it will
just go through all JS files and parse out the actual "string" where the function is