We have enabled English, Spanish, and French on our site. On Regional and language >> Languages detection we selected URL for Content language detection >> Detection Method. For Part of the URL that determines language, we selected Domain. We then set the following domains.
- English: example.com
- Spanish: es.example.com
- French: fr.example.com
How can we programmatically obtain the domain associated to each language? What code should we use in a preprocess function? Using the following code, we obtained the list of the language, but we are far from getting the domain that has been associated with each language.
function mymodule_preprocess_html(&$variables) {
// to get all enabled languages
$languages = \Drupal::languageManager()->getLanguages();
// Did not find method to retrieve the domain configuration.
foreach($languages as $key => $value) {
ksm($languages[$key]);
//stuck here on how to get domain configuration per language.
}
}