Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #314123

    Hi,
    I have unchecked the flag option in the WPML settings as I only need a text version of the language selector.
    However I still only see the flags. Any help would be really appreciated.
    http://www.toticorp.com
    Thanks
    E

    #314130

    I tried this solution but then everything is hidden. even the flags:
    https://kriesi.at/support/topic/display-language-switcher-in-wpml-and-enfold/

    Any help is appreciated
    Thanks
    E.

    #314157

    ok some more info as I have updated the flags to display “text” (French, English) instead of actual flags. But that’s not the solution I would like to keep as it looks really bad on retina display and I would really like this to be actual HTML text.

    Thanks again
    E.

    #314208

    Hi!

    You can add this code to the child theme functions.php file:

    
    if(!function_exists('avia_append_lang_flags'))
    	{
    		//first append search item to main menu
    		add_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 20, 2 );
    		add_filter( 'avf_fallback_menu_items', 'avia_append_lang_flags', 20, 2 );
    		
    		function avia_append_lang_flags( $items, $args )
    		{
    		    if ((is_object($args) && $args->theme_location == 'avia'))
    		    {
    		        global $avia_config, $sitepress;
    		
    		        if(empty($avia_config['wpml_language_menu_position'])) $avia_config['wpml_language_menu_position'] = apply_filters('avf_wpml_language_switcher_position', 'main_menu');
    		        if($avia_config['wpml_language_menu_position'] != 'main_menu') return $items;
    		
    		        $languages = icl_get_languages('skip_missing=0&orderby=custom');
    		
    		        if(is_array($languages))
    		        {
    		            $num_el = $total_el = count($languages);
    
    		            foreach($languages as $lang)
    		            {
    		               $num_el--;
    		                $currentlang = (ICL_LANGUAGE_CODE == $lang['language_code']) ? 'avia_current_lang' : '';
    		
    		                if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']);
    
    		                $style = ($num_el != $total_el) ? ' padding-left:5px;' : '';
    		
    		                $items .= "<li class='language_".$lang['language_code']." $currentlang'><a style='padding-right:0;{$style}' href='".$lang['url']."'>";
    		                $items .= "	<span class='language_flag'>".strtoupper($lang['language_code'])."</span>";
    		                if($num_el > 0) $items .= " | ";
    		                $items .= "</a></li>";
    
    		            }
    		        }
    		    }
    		    return $items;
    		}
    	}
    
    

    It will replace the default language switcher which uses images (flags) with text based links. Original thread: https://kriesi.at/support/topic/wmpl-country-code-instead-of-flags/

    Regards,
    Peter

    #388295

    Hi Dude thanks so much. It’s showing it in text format now, however is it possible to spell out the language name instead of the abbreviation?
    Like so: Français | English

    Link to home page of staging site: http://b85.a2f.myftpupload.com/

    Thanks so much for all your help
    Edna

    #388936

    Hi!

    Try adding this on Quick CSS:

    .avia_wpml_language_switch li .language_code {
    display: none;
    }
    
    span.language_translated {
    display: block !important;
    }

    Regards,
    Ismael

    #389378

    Thanks Ismael,
    It worked wonderfully.

    This is the block of css I use now:

    /* Remove language flags and replace with language name */
    .avia_wpml_language_switch li .language_flag img { display: none; }
    .avia_wpml_language_switch li .language_code { display: none !important; }
    .avia_wpml_language_switch li .language_translated {display: block !important; font-size: 14px;}
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘WPML language selector in main menu’ is closed to new replies.