You have to add the following snippet to functions.php file of your theme.

The code was originally in this link but with the language code, like “en” for English, “gr” for Greece etc.

The following code shows the language flag instead.

function new_nav_menu_items($items,$args) 
{
    if (function_exists('icl_get_languages')) 
    {
        $languages = icl_get_languages('skip_missing=0');
        if(1 < count($languages))
        {
            $items .= '<li class="menu-item">';
            foreach($languages as $l)
            {
                if(!$l['active'])
                {
                    $items .='<a href="'.$l['url'].'"><img src="'. $l['country_flag_url'] . '" ></a>';
                }
            }
            $items .= '</li>';
        }
    }
    return $items;
}

add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );