Home›Support›English Support›[Resolved] Language selector twig template aria-label and title attributes not rendering in final markup
[Resolved] Language selector twig template aria-label and title attributes not rendering in final markup
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is preparing for the launch of their site and during WCAG testing, discovered that the language selector does not contain aria-labels or titles. Despite these attributes being set in the Twig templates for both legacy dropdown and legacy dropdown on click, they are not present in the rendered markup. Solution: We recommend converting the custom language switcher from a .twig template to a PHP-based implementation, as Twig will be removed entirely from WPML in future releases. Regarding the missing aria-labels, this issue has been reported to our development team, and it will be improved. However, we cannot guarantee a specific timeline for this fix.
Please note that this solution might be outdated or not applicable to your particular case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Background of the issue:
I am preparing for the launch of our site and running it through WCAG testing. The language selector does not contain aria-labels or titles. We are on the latest version of the plugin and have reviewed the plugin code, which shows both aria-label and title are set in the Twig templates for both legacy dropdown and legacy dropdown on click. However, neither aria-label nor title make it into the rendered markup for the language selector. The issue can be seen at: hidden link.
Symptoms:
Aria-labels and titles are not present in the rendered markup for the WPML language selector.
Questions:
Why are the aria-label and title attributes not rendering in the final markup for the language selector?
How can I ensure that aria-labels and titles appear in the rendered markup?
Thank you for the informative response. We're using the WPML Language Switcher component (header/menu). You're advising that the twig templates which are still present in the current code are no longer utilized by the code? Can you advise if WPML has addressed the long outstanding issue of aria-labels and/or title attributes on language links in the OOTB WPML Language Switcher component? Or, after paying for the WPML product, we now have an additional spend for development of a WCAG compliant language switcher?
Twig will be removed entirely from WPML in future releases, so I strongly recommend converting your custom language switcher from a .twig template to a PHP-based implementation.
Regarding the aria-label issue: it has already been reported to our development team and is under consideration for a near-future fix. However, I cannot guarantee when — or if — it will be implemented, as it depends on priorities and other ongoing development tasks.
Clarifying my previous comments, we are NOT using a custom language switcher. We are using the out-of-the-box language switcher, provided by WPML, with NO modifications.
Your response indicates the WPML product does NOT support WCAG compliance, and we will in fact need to develop our own language switcher for WCAG compliance. This is unfortunate that WPML has not previously addressed this, especially since adding aria labels is such an insignificant lift from a development perspective.