Tagged: , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23914

    Hi,

    1- I don’t want to use WPML dropdown selector. I want to replace the flags with only text name and show it in the shrinking fixed header as another button, closer but over to the right to “home” buttons and other buttons (similar to the “contact” button position in this support website). It is possible?

    2- My intention is show only the “Spanish” button when visitors are seeing the site in “English” language. If they click “Spanish”, the site will change to Spanish language and only shows the “English” button. I found the following css rules but i still can’t tested.

    #[name of element] li {

    display:block;

    }

    #[name of element] li.active {

    display:none;

    }

    This rules will work?

    What is the [name of the element] for WPML text name?

    3- I’m using the Enfold child theme. I’m a newcomer to the web design. How should I modify the child theme in order to prevent the loss of this changes from later theme updates? I saw the Devin’s video tutorial for child theme and I suppose that I have to copy-paste wp-contentthemesenfoldconfig-wpmlconfig.php to wp-contentthemesenfold-childconfig-wpmlconfig.php and then modify the lines specified by Dude in other post:

    Open up wp-contentthemesenfoldconfig-wpmlconfig.php and replace:

    $output .= ” <span class=’language_flag’></span>”;

    with

    $output .= ” <span class=’language_flag’>”.$lang.”</span>”;

    or

    $output .= ” <span class=’language_flag’>”.$lang.”</span>”;

    I’ll be grateful for confirming this point.

    I don’t want to modify anything that I can break. :)

    Thanks.

    Regards!

    #121609

    1) I’m not sure if WPML allows you to add the language links to the main menu. Probably it’s possible by using the wp_nav_menu_items filter somehow but I’d contact the WPML devs. Our theme just supports a modified version of the language switcher out of the box.

    2+3) Insert following code into the child theme functions.php

    function avia_wpml_language_switch()
    {
    $languages = icl_get_languages('skip_missing=0&orderby=custom');
    $output = "";

    if(is_array($languages))
    {
    $output .= "<ul class='avia_wpml_language_switch'>";

    foreach($languages as $lang)
    {
    $currentlang = (ICL_LANGUAGE_CODE == $lang['language_code']) ? 'avia_current_lang' : '';

    $output .= "<li class='language_".$lang['language_code']."'><a href='".$lang['url']."'>";
    $output .= " <span class='language_flag'>".$lang['native_name']."</span>";
    $output .= " <span class='language_native'>".$lang['native_name']."</span>";
    $output .= " <span class='language_translated'>".$lang['translated_name']."</span>";
    $output .= " <span class='language_code'>".$lang['language_code']."</span>";
    $output .= "</a></li>";
    }

    $output .= "</ul>";
    }

    echo $output;
    }

    You can then use the avia_current_lang class to hide the flag:

    li.avia_current_lang{
    display: none !important;
    }

    #121610

    Hi again:

    The WPML devs give me this code for theme functions.php, and it works well.

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

    I hope It can be useful for other Enfold users.

    Regards.

    #121611

    Hey!

    Glad that the WPML team could provide the code.

    Regards,

    Peter

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘WPML text switcher in the fixed header (no flag, no dropdown)’ is closed to new replies.