function _locale_refresh_translations

Refresh related information after string translations have been updated.

The information that will be refreshed includes:

  • JavaScript translations.
  • Locale cache.

Parameters

array $langcodes: Language codes for updated translations.

array $lids: (optional) List of string identifiers that have been updated / created. If not provided, all caches for the affected languages are cleared.

2 calls to _locale_refresh_translations()
locale_translate_batch_refresh in drupal/core/modules/locale/locale.bulk.inc
Refreshs translations after importing strings.
locale_translate_edit_form_submit in drupal/core/modules/locale/locale.pages.inc
Form submission handler for locale_translate_edit_form().

File

drupal/core/modules/locale/locale.module, line 989
Enables the translation of the user interface to languages other than English.

Code

function _locale_refresh_translations($langcodes, $lids = array()) {
  if (!empty($langcodes)) {

    // Update javascript translations if any of the strings has a javascript
    // location, or if no string ids were provided, update all languages.
    if (empty($lids) || ($strings = Drupal::service('locale.storage')
      ->getStrings(array(
      'lid' => $lids,
      'type' => 'javascript',
    )))) {
      array_map('_locale_invalidate_js', $langcodes);
    }
  }

  // Clear locale cache.
  cache()
    ->deleteTags(array(
    'locale' => TRUE,
  ));
}