CKEditor 5 plugins needs to be compiled with the DLL build to be able to work with Drupal. The expected directory structure of a DLL build is the following:
ckeditor-plugin-name/
- translations/
- ckeditor-plugin-name.js
The only thing needed from A Drupal contrib author is to declare that a plugin has translations. It can be done by adding a dependency to the core/ckeditor5.translations library in the plugin library declaration. Based on this dependency, Drupal will automatically find and load CKEditor 5 translations files.
The use of a dependency is necessary to be able to know which library is related to a CKEditor 5 plugin during the cache rebuild phase, other ways to access this information is not available when the caches are being rebuilt.
MODULE_NAME.libraries.yml
myDrupalCkeditorPlugin:
js:
assets/js/ckeditor5/ckeditor-plugin-name/ckeditor-plugin-name.js: { minified: true, preprocess: false }
dependencies:
- core/ckeditor5
- core/ckeditor5.translations
With this declaration Drupal automatically look for existing translations in the assets/js/ckeditor5/ckeditor-plugin-name/translations/* folder.
The DLL build automatically adds translations to the translations/ subdirectory. This is predicable because the original .po files used in the translation process are in a lang/translations/ sub-directory by convention.