Helper function for clearing the languages cache of all local translators.
Can be used in oder to clear the cache for supported target languages after the translation abilities of an local have changed.
function tmgmt_local_clear_languages_cache() {
$results = \Drupal::entityQuery('tmgmt_translator')
->accessCheck(TRUE)
->condition('plugin', 'local')
->execute();
if ($results) {
foreach (Translator::loadMultiple($results) as $translator) {
$translator
->clearLanguageCache();
}
}
}