Same name and namespace in other branches
  1. 6.x includes/locale.inc \_locale_invalidate_js()
  2. 7.x includes/locale.inc \_locale_invalidate_js()
  3. 8.9.x core/modules/locale/locale.module \_locale_invalidate_js()
  4. 9 core/modules/locale/locale.module \_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()
locale_configurable_language_delete in core/modules/locale/locale.module
Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
locale_configurable_language_insert in core/modules/locale/locale.module
Implements hook_ENTITY_TYPE_insert() for 'configurable_language'.
locale_configurable_language_update in core/modules/locale/locale.module
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 1182
Enables the translation of the user interface to languages other than English.

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;
}