function _locale_invalidate_js
Force the JavaScript translation file(s) to be refreshed.
This function sets a refresh flag for a specified language, or all languages except English, if none specified. JavaScript translation files are rebuilt (with locale_update_js_files()) the next time a request is served in that language.
Parameters
string|null $langcode: (optional) The language code for which the file needs to be refreshed, or NULL to refresh all languages. Defaults to NULL.
Return value
array New content of the 'system.javascript_parsed' variable.
4 calls to _locale_invalidate_js()
- LocaleHooks::configurableLanguageDelete in core/modules/ locale/ src/ Hook/ LocaleHooks.php 
- Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
- LocaleHooks::configurableLanguageInsert in core/modules/ locale/ src/ Hook/ LocaleHooks.php 
- Implements hook_ENTITY_TYPE_insert() for 'configurable_language'.
- LocaleHooks::configurableLanguageUpdate in core/modules/ locale/ src/ Hook/ LocaleHooks.php 
- Implements hook_ENTITY_TYPE_update() for 'configurable_language'.
- locale_js_translate in core/modules/ locale/ locale.module 
- Returns a list of translation files given a list of JavaScript files.
1 string reference to '_locale_invalidate_js'
- _locale_refresh_translations in core/modules/ locale/ locale.module 
- Refresh related information after string translations have been updated.
File
- 
              core/modules/ locale/ locale.module, line 855 
Code
function _locale_invalidate_js($langcode = NULL) {
  $parsed = \Drupal::state()->get('system.javascript_parsed', []);
  if (empty($langcode)) {
    // Invalidate all languages.
    $languages = locale_translatable_language_list();
    foreach ($languages as $language_code => $data) {
      $parsed['refresh:' . $language_code] = 'waiting';
    }
  }
  else {
    // Invalidate single language.
    $parsed['refresh:' . $langcode] = 'waiting';
  }
  \Drupal::state()->set('system.javascript_parsed', $parsed);
  return $parsed;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
