I load the vocabulary with
How can I can translate its label in the language currently used?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
It will be default by the current language.
There are only two ways to get something else, unfortunately:
a) Use ConfigEntityStorage::loadOverrideFree to load a config entity without overrides, then it is in the default language of that entity, which is what language() returns.
b) You can set the current config language and then load the entity. See for example user_mail function :
<?php // Get the current language and override it. $language_manager = \Drupal::languageManager(); $language = $language_manager->getLanguage($desired_langcode); $original_language = $language_manager->getConfigOverrideLanguage(); $language_manager->setConfigOverrideLanguage($language); // Do your thing here. // Restore the config language. $language_manager->setConfigOverrideLanguage($original_language);