I have setup language and translation in Drupal8 that affects my URL for example
myurl.com/ru
myurl.com/us
myurl.com/fr
What I need to do if find out which country is being accessed so I can add a variable to the twig theme layer
This is the hook that is working fine
/**
* Implements hook_preprocess_HOOK() for menu.html.twig.
*/
function pnc_preprocess_menu(&$variables) {
$code_to_access_language_url = 'this is a test';
kint($variables);
$variables['access_translation'] = $code_to_access_language_url;
//print $code_to_access_language_url;exit;
}
I have found that under kint() there a lot of public methods for translation but I am not sure how I access them or which one to access. I know I could regex the url, but there has to be a cleaner way to do it?