Last active
May 15, 2018 08:47
-
-
Save Elendev/749738c59de503e6af4d16a23cf5e177 to your computer and use it in GitHub Desktop.
Medium : Drupal 8, Typescript, React and i18n - locale.module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Implements hook_js_alter(). | |
| */ | |
| function locale_js_alter(&$javascript, AttachedAssetsInterface $assets) { | |
| // ... | |
| // Replace the placeholder file with the actual JS translation file. | |
| $placeholder_file = 'core/modules/locale/locale.translation.js'; | |
| if (isset($javascript[$placeholder_file])) { | |
| if ($translation_file = locale_js_translate($files)) { | |
| $js_translation_asset = &$javascript[$placeholder_file]; | |
| $js_translation_asset['data'] = $translation_file; | |
| // @todo Remove this when https://www.drupal.org/node/1945262 lands. | |
| // Decrease the weight so that the translation file is loaded first. | |
| $js_translation_asset['weight'] = $javascript['core/misc/drupal.js']['weight'] - 0.001; | |
| } | |
| // ... | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment