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
| declare namespace Drupal { | |
| /** | |
| * Helper to rethrow errors asynchronously. | |
| * | |
| * This way Errors bubbles up outside of the original callstack, making it | |
| * easier to debug errors in the browser. | |
| * | |
| * @param {Error|string} error | |
| * The error to be thrown. |
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])) { |
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
| translations: | |
| # No sensible version can be specified, since the translations may change at | |
| # any time. | |
| js: | |
| # This file does not actually exist; it's a placeholder file that will be | |
| # overriden by locale_js_alter(), to use the file that contains the actual | |
| # translations, for the language used in the current request. | |
| locale.translation.js: {} |
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
| Drupal.t = function (str, args, options) { | |
| options = options || {}; | |
| options.context = options.context || ''; | |
| if (typeof drupalTranslations !== 'undefined' && drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str]) { | |
| str = drupalTranslations.strings[options.context][str]; | |
| } | |
| if (args) { | |
| str = Drupal.formatString(str, args); |