-
AuthorPosts
-
January 21, 2020 at 2:26 pm #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, 10 months ago by LMS.
January 22, 2020 at 1:30 pm #1177176Hey 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,
IsmaelJanuary 25, 2020 at 4:59 pm #1178382Hi 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,
SebastianJanuary 27, 2020 at 8:58 am #1178600Hi,
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,
IsmaelJanuary 27, 2020 at 9:20 pm #1178790Hi 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,
SebastianJanuary 29, 2020 at 12:57 pm #1179406Hi,
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,
IsmaelJanuary 31, 2020 at 12:20 am #1180111Hi 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, 10 months ago by LMS.
February 3, 2020 at 3:37 am #1180775Hi,
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,
IsmaelFebruary 8, 2020 at 10:25 pm #1182661Hi 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:L256avia_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. OR2.
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?
February 10, 2020 at 7:45 am #1182955Hi,
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,
IsmaelFebruary 10, 2020 at 9:52 pm #1183285Hi 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.
February 12, 2020 at 5:13 am #1183745Hi,
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,
IsmaelFebruary 13, 2020 at 10:57 pm #1184331Hi 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 NavThanks,
SebastianFebruary 17, 2020 at 4:12 am #1185062Hi,
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,
IsmaelFebruary 19, 2020 at 9:35 pm #1186181Hi 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,
SebastianFebruary 21, 2020 at 3:13 am #1186596Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.