Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #1176737

    The WPML Language Switcher displays languages without translations when used with the Enfold theme.

    Example: The language switcher offers translations for French even if no content in that given language is provided:

    • If I go to /de/blog/ and click on the FR language flag, I get directed to the homepage.
    • If I go to /de/veranstaltungen/ and click on the FR language, I get a page without any events.

    The option to skip missing languages is activated in the WPML settings.

    The issue was reported to WPML team as well here: https://wpml.org/de/forums/topic/language-switcher-offers-languages-in-which-no-content-is-available/

    • This topic was modified 4 years, 9 months ago by LMS.
    #1177176

    Hey LMS,

    Thank you for the inquiry.

    The Enfold > Blog Layout > Blog Layout setting is set to “Use the advance layout builder..”, but the blog page itself is empty, so it’s not displaying anything. We added the Blog Posts element in the blog page. Please make sure that the settings or theme options for each language are set correctly.

    Best regards,
    Ismael

    #1178382

    Hi Ismael,

    Thanks for the tip with the blog page. Added the module also in English.

    However, the language switch issue for which I initially raised the ticket is still not solved. Could you please take a look at this? WPML team looked into this. We did not find this issue when using a standard theme. Hence, we suspect that this is an issue with the Enfold template.

    Could you please check again?

    Kind regards,
    Sebastian

    #1178600

    Hi,

    Thank you for the update.

    The site redirects to the home page when you switch to FR because the FR blog page doesn’t exists, or it’s not set properly in the FR theme options. You have to create a blog page in the FR language and set it accordingly. (see private field)

    Best regards,
    Ismael

    #1178790

    Hi Ismael,

    I set the WPML settings to skip the language if no translation is available and not direct to the homepage. Hence, for the blog, the behavior is not as expected.

    Regarding the other example, the calendar page: i have neither a page set up in French nor defined any calendar entries. Hence, this is also not expected behavior.

    Could you please take another look?

    Cheers,
    Sebastian

    #1179406

    Hi,

    Thank you for the clarification.

    This is probably an issue with the theme’s language switcher; it doesn’t take into consideration pages without translations, so the flags are still visible. You may have to remove the default language flags from the theme and render the actual switcher from WPML. Please check this thread.

    // https://kriesi.at/support/topic/wpml-language-switcher-still-not-working/#post-1122733

    Best regards,
    Ismael

    #1180111

    Hi Ismael,

    I tried multiple combinations of all solution linked in this or associated posts.

    1. Removing one of the language switchers that is not compatible with WPML works on my site with this piece of code:

    // Remove the default flag configurations
    add_action('after_setup_theme','avia_remove_main_menu_flags');
    function avia_remove_main_menu_flags(){
    	remove_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 20, 2 );
    	remove_filter( 'avf_fallback_menu_items', 'avia_append_lang_flags', 20, 2 );
    	remove_action( 'avia_meta_header', 'avia_wpml_language_switch', 10);
    }

    2. Using the following code adds a WPML compatible language switcher next to the social media icons. However, it is not displayed correctly (languages in words only and strange styling). It does NOT react to the settings to configure the menu in WPML > Languages:

    // Render the default language switcher (activate header meta)
    add_action('avia_meta_header', 'ava_icl_language_selector');
    function ava_icl_language_selector(){
    	do_action('icl_language_selector');
    }

    3. When setting the language switcher to display in the main menu via WPML > Languages, it will display the correct WPML language menu.

    Next to this menu, the Enfold menu switcher is displayed. This CANNOT be hidden with the following CSS as provided in your threads. Reason: the class is not found in the source code.

    .avia_wpml_language_switch, .avia_wpml_language_switch li {
        display: none !important;
    }

    I checked the source code and seems to listen to the following CSS (which effectively hides it):

    /* hide Enfold language switcher */
    .av-language-switch-item, .av-language-switch-item li {
    	display: none !important;
    }
    

    I was not able to find a way to display the WPML switcher using flags in the social media bar when set accordingly in WPML when using the solutions provided above.

    I could inject the custom WPML language switcher via the following code:

    add_action('avia_meta_header', 'ava_icl_language_selector');
    function ava_icl_language_selector(){
    	// do_action('wpml_add_language_selector');
    }

    It is then displayed in the sub menu next to the social media icons. However it does not blend in nicely with the overall design and needs serious tweaking via CSS on multiple levels which I gave up.

    To have something to work with I now kept the setting displaying the switch in the main menu.

    Can you please review the above again and let me know how I can manage to simply add the language switcher to the social media bar?

    Thanks,
    Sebastian

    • This reply was modified 4 years, 9 months ago by LMS.
    #1180775

    Hi,

    Thank you for the update.

    However it does not blend in nicely with the overall design and needs serious tweaking via CSS on multiple levels which I gave up.

    This is why the theme has its own flag switcher. Unfortunately, that is the only way to add the default switcher and the style has to be adjusted manually.

    Have you tried to adjust the position of the language switcher from the main menu? You can probably set the position to absolute, then adjust the top and right property manually until it’s positioned beside the social icons.

    Best regards,
    Ismael

    #1182661

    Hi Ismael,

    This is what I got from WPML support:

    Your Language Switcher is not coming from WPML.
    It is from your theme here \wp-content\themes\enfold\config-wpml\config.php:L256 avia_wpml_language_switch() function.

    Please try
    1. Remove the theme Language Switcher and add WPML Language Switcher to the menu. Currently, Language Switcher is assigned to a menu but that menu is not being displayed anywhere. OR

    2.
    Change this
    icl_get_languages( 'skip_missing=0&orderby=custom' )
    to
    icl_get_languages( 'skip_missing=1&orderby=custom' )
    in the above function.

    They also said I should forward to you the request to use WPML setting instead of hardcoded values that you created the switcher with.

    Is this something that can be done?

    #1182955

    Hi,

    Thank you for the info.

    Your Language Switcher is not coming from WPML.

    Yes, the flag switcher is generated by the theme as we previously mentioned. You can try the following code to render the language switcher inside the main menu container and skip the languages without translation.

    function ava_icl_language_selector(){
    	$languages = icl_get_languages('skip_missing=1');
    	foreach($languages as $l){
    		if(!$l['active']) $langs[] = '<a href="'.$l['url'].'">'.$l['translated_name'].'</a>';
    	}
    	echo join(', ', $langs);
    }
    add_action('ava_inside_main_menu', 'ava_icl_language_selector');
    

    Best regards,
    Ismael

    #1183285

    Hi Ismael,
    Thanks for the code. It needs to be URL decoded to be working. However, it will not display the names of the languages in the target language.
    I did a different workaround for now using the following code and doing CSS styling accordingly:

    
    add_action('avia_meta_header', 'ava_icl_language_selector');
    function ava_icl_language_selector(){
    	// custom WPML language switch
    	do_action('wpml_add_language_selector');
    
    }
    
    • This reply was modified 4 years, 9 months ago by LMS.
    #1183745

    Hi,

    I did a different workaround for now using the following code and doing CSS styling accordingly:

    Alright. Does it satisfy your requirement? Let us know if you need further help with this one.

    Best regards,
    Ismael

    #1184331

    Hi Ismael,

    Actually, I am ok with the injection of the currency and language switcher into the meta header. However, I would love to have the header layout different, i.e. moving the meta header not to stretch over the logo. Do you have a manual on how to move the meta header to sit to the right of the logo instead over it.

    Logo | Meta Header
    Logo | Main Nav

    Thanks,
    Sebastian

    #1185062

    Hi,

    Thank you for the update.

    Would you like to move the language or flag switcher to the right side of the header? This css code should help.

    .wpml-ls-legacy-list-horizontal, .wcml-horizontal-list {
    	float: right;
    }

    Best regards,
    Ismael

    #1186181

    Hi Ismael,

    I don’t want to align the module differently within the header. What I am after is a solution of having two menu lines next to the logo. One line for the currency and language switcher and one for the main navigation. This is a rather simple header layout. Is there a solution offered by you for this?

    Cheers,
    Sebastian

    #1186596

    Hi,

    Yes, it is possible. You can move the language switcher within the menu container and adjust the positions accordingly using css. Try to replace the snippet in the functions.php file with the following code.

    function ava_icl_language_selector(){
    	do_action('wpml_add_language_selector');
    }
    add_action('ava_after_main_menu', 'ava_icl_language_selector');

    This will render the language switcher beside the main menu.

    If you don’t want to change the filter and keep the header meta container, you can try this css code instead.

    #header_meta {
    	position: absolute;
    	right: 0;
    }

    This will move the header meta container closer to the main menu container. Adjust the css code as you wish.

    Best regards,
    Ismael

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.