How do I load taxonomy terms basing on the current language? I am using the following code.

$language =  \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();
$terms = \Drupal::entityTypeManager()-&gt;getStorage('taxonomy_term')-&gt;loadTree('category', 0, 1);


How can I change it so it load the taxonomy terms basing on $language?
Use EntityRepositoryInterface::getTranslationFromContext:

$terms_translated = [];
foreach ($terms as $key =&gt; $term) {
  $terms_translated[$key] = \Drupal::service('entity.repository')
    -&gt;getTranslationFromContext($term, $language);
}


BTW, you don't need to provide a language code, because the current content language is the default value for the second parameter in getTranslationFromContext() and in a standard multilanguage site this is equal to the current language.