Background of the issue:
I want to display the flags to change language on every page of my site, including pages set to 'not translatable', like the product's attributes page.
Symptoms:
I couldn't find any documentation to help me display language flags on non-translatable pages.
Questions:
How can I display language flags on every page, including non-translatable ones?
Before this thread gets assigned to my colleague, I'd like to offer some initial guidance or potential solutions.
If a page isn’t translated, the other languages won’t appear in the language switcher. However, you can still display the current language name or flag.
To do this, go to "WPML > Languages" and edit the language switcher. In the language switcher customizer, enable the "Current language" option as shown in this screenshot: hidden link, and save the changes.
If you want the other languages to appear in the language switcher even when the page is not translated, you have two options:
- Set the Post Type Translation Preference:
- Go to "WPML > Settings → Post Type Translation" and set the post type containing the page to "Translatable – use translation if available or fallback to default language".
Alternatively, you can achieve this with a custom coding solution. However, please note that support for custom coding is beyond the scope of our support policy. If needed, you may consider hiring a developer experienced in customizing WPML from here: https://wpml.org/contractors/
I hope it helps. let us know if you need further assistance. We'll be happy to help.
Hello and thank you for your answer. Unfortunately we can't use "Translatable – use translation if available or fallback to default language" because we're using filters plugin and they if we check this option, we need then to translate all the attributes which are brands (and that would be weird since brand are just brands, they can't be translated) to be able to filter by this attributes in other languages than the original. (see previous exchanges with support)
Aren't there any other way to do it without it ? It seems like it should be an option because of cases like sizes attributes. We wouldn't translate size and still we should be able to display the attribute pages with flags to be able to go from a language to another (since these pages actually works in all languages and display products with good translations).
If that's by code, can you give some info on how to do it (even if not precisely the way to to id but at least which hooks and stuff do to).
Hello and thank you. It's getting better.
it displays the language switcher but not the good links, it sends the user to the translated homepage of the site, not the same page (product attribute).
Any way we could change this ?
I tried to add the arguments in the "preserve arguments" input : taxonomy,term but it doesn't work. They are the good arguments but urlrewrite is on so maybe the plugin doesn't get them.
Thank you
Thank you for the update. In the case of missing translations, the language switcher typically redirects to the homepage if the "Link to the missing translation's homepage" option is enabled. However, since you want the user to be redirected to the current page (in the default language) when the translation is missing, this behavior cannot be achieved using WPML's built-in features alone. A custom coding approach will be required.
The hook that might align with achieving this functionality is wpml_active_languages. This hook allows you to modify the URLs of the language switcher dynamically. You can use it to check if a translation exists for the current page and, if not, redirect the user to the default language version of the current page.
As I mentioned earlier, providing support for custom coding is beyond the scope of our support, and for that reason, I can assist by sharing potential suggestions to guide you. I hope you understand the limitations.
If you have any other questions or need clarification, feel free to reach out. I'll be happy to help.
Best regards,
Prosenjit
The topic ‘[Closed] I want to display the flags to change language everywhere’ is closed to new replies.