function _locale_refresh_translations

Same name in other branches
  1. 9 core/modules/locale/locale.module \_locale_refresh_translations()
  2. 10 core/modules/locale/locale.module \_locale_refresh_translations()
  3. 11.x core/modules/locale/locale.module \_locale_refresh_translations()

Refresh related information after string translations have been updated.

The information that will be refreshed includes:

  • JavaScript translations.
  • Locale cache.
  • Render 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.

3 calls to _locale_refresh_translations()
LocaleLocaleLookupTest::testFixOldPluralStyle in core/modules/locale/tests/src/Functional/LocaleLocaleLookupTest.php
Test old plural style @count[number] fix.
locale_translate_batch_refresh in core/modules/locale/locale.bulk.inc
Implements callback_batch_operation().
TranslateEditForm::submitForm in core/modules/locale/src/Form/TranslateEditForm.php
Form submission handler.

File

core/modules/locale/locale.module, line 1071

Code

function _locale_refresh_translations($langcodes, $lids = []) {
    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([
            'lid' => $lids,
            'type' => 'javascript',
        ]))) {
            array_map('_locale_invalidate_js', $langcodes);
        }
    }
    // Throw locale.save_translation event.
    \Drupal::service('event_dispatcher')->dispatch(LocaleEvents::SAVE_TRANSLATION, new LocaleEvent($langcodes, $lids));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.