Identifies admin language from the user preferences.
$languages: An array of valid language objects.
A valid language code on success, FALSE otherwise.
function language_from_user_admin($languages) {
// User preference (only for authenticated users).
global $user;
if ($user->uid && !empty($user->preferred_admin_langcode) && isset($languages[$user->preferred_admin_langcode]) && path_is_admin(current_path())) {
return $user->preferred_admin_langcode;
}
// No language preference from the user or not on an admin path.
return FALSE;
}