How to print user role id with dynamic variable of language?
You're using $lg inside single quotes ('), because of which PHP is considering it as static text. If you want to use variable inside quotes, use double quotes ("). Check this ans for more details.

Try below code, to print role based on language:

&lt;?php
global $user, $language;
$user_fields = user_load($user-&gt;uid);
// $lg = $user_fields-&gt;language;
$role = (!empty($user_fields-&gt;field_role[$language-&gt;language]) ? $user_fields-&gt;field_role[$language-&gt;language][0]['value'] : $user_fields-&gt;field_role['en'][0]['value'])
echo $role;
?&gt;