$browser_options[$langcode] =
$langcode;
} // Add languages based on language files in the translations directory.
if (count($files)) { foreach ($files as $langcode =>
$uri) { $select_options[$langcode] =
isset($standard_languages[$langcode]) ?
$standard_languages[$langcode][1
] :
$langcode;
$browser_options[$langcode] =
$langcode;
} } asort($select_options);
$request = Request::
createFromGlobals();
$browser_langcode = UserAgent::
getBestMatchingLangcode($request->server->
get('HTTP_ACCEPT_LANGUAGE', ''
),
$browser_options);
$form['langcode'
] =
[ '#type' => 'select',
'#title' => 'Choose language',
'#title_display' => 'invisible',
'#options' =>
$select_options,
// Use the browser detected language as default or English if nothing found.
'#default_value' => !
empty($browser_langcode) ?
$browser_langcode : 'en',
];
$link_to_english =
install_full_redirect_url(['parameters' =>
['langcode' => 'en'
]]);
$form['help'
] =
[ '#type' => 'item',