function _locale_invalidate_js in Drupal 10
Same name and namespace in other branches
- 8 core/modules/locale/locale.module \_locale_invalidate_js()
- 6 includes/locale.inc \_locale_invalidate_js()
- 7 includes/locale.inc \_locale_invalidate_js()
- 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 1200 - 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 $lcode => $data) {
$parsed['refresh:' . $lcode] = 'waiting';
}
}
else {
// Invalidate single language.
$parsed['refresh:' . $langcode] = 'waiting';
}
\Drupal::state()
->set('system.javascript_parsed', $parsed);
return $parsed;
}