Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For attributes which can contain a mix of languages, provide markup for language of parts #8280

Open
ChasBelov opened this issue Sep 12, 2022 · 5 comments
Labels
i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.

Comments

@ChasBelov
Copy link

ChasBelov commented Sep 12, 2022

WCAG 2.0 AA requires the meeting of Success Criterion 3.1.2, Language of Parts, such that content that is in a language that is not the page's language can be marked as being in a different language. If that content is in an attribute which would be read aloud by a screen reader, there is currently no non-kludgey way to mark content which is in a mix of languages.

For example, given an image which bears the text "This is the text. Este es el texto." as an image of text, the correct alt text for that image would contain all of the text shown. However, there is no way to mark that alt text correctly for language.

<img src="/image001.png" alt="This is the text. Este es el texto." />

is insufficient. Syntax such as the following might solve this issue:

On a page marked as being lang="en":

<img src="/image001.png" alt="This is the text.","Este es el texto."{lang="es"} />

On a page marked as being lang="es":

<img src="/image001.png" alt="This is the text."{lang="en"},"Este es el texto." />

Attributes which would need this support include, but may not be limited to:

alt
title
aria-label

@brennanyoung
Copy link

I can report that Live regions (such as HTML5's <output>) do not handle lang properly. Typically the content of Live Regions is provided by client side scripting (so where do we post the lang attribute?).
One live region ARIA role (feed) is intended for <article> elements. Hypothetically, each article in a feed may have a different lang setting. Is the current spec sufficiently clear that these variations need to be communicated accurately to the accessibility tree?

@ChasBelov
Copy link
Author

@brennanyoung Thank you for that insight, which I was not aware of. I respectfully suggest you file that as a separate issue. This particular issue (#8280) is specifically concerned with language of parts within HTML attributes. I do have a comment on your post, and will be happy to add it once you've created a new issue, so please add a cross-reference to your issue here.

@r12a r12a added the i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. label Sep 15, 2022
@brennanyoung
Copy link

brennanyoung commented Sep 15, 2022

Thanks Chas.

As well as aria-label and the others you mentioned the attributes listed under https://www.w3.org/TR/wai-aria-1.2/#translatable-states-and-properties may be added

aria-placeholder
aria-roledescription
aria-valuetext

Other attributes that may be relevant here are those that derive text from other elements, such as
aria-describedby
aria-details
aria-labelledby
aria-errormessage

If element A gets its name, details, description or error message from the text nodes inside element B, how should "lang" work? Should B dictate the language? Should a lang on A override a lang on B?

Maybe some kind of fallback algorithm, like with font-family or accessible name computation?

So, part of the problem is that we need to clarify how we would prefer it to behave! I'm not sure.

@r12a
Copy link

r12a commented Sep 15, 2022

As well as the 'inline' change of language mentioned above, there is also a problem if the textContent is in one language but the attribute is in another. For example, this kind of language switch may appear at the top of an English page:

<a href="myfile.es.html" lang="es" alt="Spanish translation">Español</a>

(Fwiw, these issues are the reason the i18n WG recommends never to put localisable text in attributes. See https://www.w3.org/TR/international-specs/#markup_elements_attributes)

@brennanyoung
Copy link

FYI HTML defines several translatable attributes, so this is not just an ARIA thing.
https://html.spec.whatwg.org/multipage/dom.html#translatable-attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.
Development

No branches or pull requests

3 participants