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

Adjust definition of valid language subtag (de46e4, bf051a, 5b7ae0) #1106

Merged
merged 8 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions __tests__/spelling-ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
- DOCX
- DPUB
- DNS
- BCP
- bcp
- Esc # esc key on a keyboard
- url
- voiceover
Expand All @@ -60,6 +62,7 @@
- EARL10-Schema
- labelable
- merchantability
- de-hello
- 14pt
- 18pt
- Helvetica
Expand Down
27 changes: 17 additions & 10 deletions _rules/element-lang-valid-de46e4.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ For each test target, the `lang` attribute has a [valid language subtag](#valid-

## Assumptions

This rule assumes that the presence of a `lang` attribute is being used to comply to WCAG. This rule doesn't test if the attribute is needed to comply to WCAG.
- This rule assumes that the presence of a `lang` attribute is being used to comply to WCAG. This rule doesn't test if the attribute is needed to comply to WCAG.

- This rule assumes that user agents and assistive technologies can programmatically determine [valid language subtags](#valid-language-subtag) even if these do not conform to the [BCP 47][] syntax.

- This rule assumes that [grandfathered tags][] are not used as these will not be recognized as [valid language subtags](#valid-language-subtag).

## Accessibility Support

Expand Down Expand Up @@ -73,33 +77,33 @@ The `lang` attribute has a value that is not empty ("") and has a valid primary
</html>
```

### Failed

#### Failed Example 1
#### Passed Example 3

The `lang` attribute value is not a valid primary language subtag.
The `lang` attribute value has a valid primary language subtag, but a syntactically invalid region subtag.

```html
<html>
<body>
<article lang="dutch"></article>
<p lang="en-US-GB"></p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is right - BCP 47 has an algorithm for determining best matching language in 'Matching of Language Tags' at the end of BCP 47:

In the lookup scheme, the language range is progressively truncated
from the end until a matching language tag is located

So lookup order is en-US-GB to en-US to en

</body>
</html>
```

#### Failed Example 2
### Failed

The `lang` attribute value has a valid primary language subtag, but a syntactically invalid region subtag.
#### Failed Example 1

The `lang` attribute value is not a valid primary language subtag.

```html
<html>
<body>
<p lang="en-US-GB"></p>
<article lang="dutch"></article>
</body>
</html>
```

#### Failed Example 3
#### Failed Example 2

The `lang` attribute value is not empty ("") and is not a valid primary language subtag.

Expand Down Expand Up @@ -148,3 +152,6 @@ The `lang` attribute value consists of only [ASCII whitespace](https://infra.spe
</body>
</html>
```

[grandfathered tags]: https://tools.ietf.org/html/bcp47#section-2.2.8
[bcp 47]: https://tools.ietf.org/html/bcp47#section-2.1
26 changes: 16 additions & 10 deletions _rules/html-page-lang-valid-bf051a.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ For each test target, the `lang` attribute has a [valid language subtag](#valid-

## Assumptions

This rule assumes that the presence of a `lang` attribute is being used to comply to WCAG. This rule doesn't test if the attribute is needed to comply to WCAG.
- This rule assumes that the presence of a `lang` attribute is being used to comply to WCAG. This rule doesn't test if the attribute is needed to comply to WCAG.

- This rule assumes that user agents and assistive technologies can programmatically determine [valid language subtags](#valid-language-subtag) even if these do not conform to the [BCP 47][] syntax.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reasonable assumption - BCP 47 has an algorithm for determining best matching language in 'Matching of Language Tags' at the end of BCP 47:

In the lookup scheme, the language range is progressively truncated
from the end until a matching language tag is located

Even if an implementor hasn't read this part of the spec, it's still likely they'll implement it because it's easy to implement and fairly obvious.


- This rule assumes that [grandfathered tags][] are not used as these will not be recognized as [valid language subtags](#valid-language-subtag).

## Accessibility Support

Expand All @@ -59,6 +63,14 @@ This `html` element has a `lang` attribute whose value is a [valid][valid langua
<html lang="fr"></html>
```

#### Passed Example 2

This `html` element has a `lang` attribute value that is a [valid language subtag][] even though the [region subtag][] is not.

```html
<html lang="en-US-GB"></html>
```

### Failed

#### Failed Example 1
Expand All @@ -71,21 +83,13 @@ This `html` element has a `lang` attribute whose value is not a [valid language

#### Failed Example 2

This `html` element has a `lang` attribute whose value is not a [valid language subtag][]. Even though the [primary language subtag][] is valid, the [region subtag] is not.

```html
<html lang="en-US-GB"></html>
```

#### Failed Example 3

This `html` element has a `lang` attribute whose value is not a [valid language subtag][].

```html
<html lang="123"></html>
```

#### Failed Example 4
#### Failed Example 3

This `html` element has a `lang` attribute whose value is not a [valid language subtag][].

Expand All @@ -106,3 +110,5 @@ This rule does not apply to `svg` elements.
[primary language subtag]: https://tools.ietf.org/html/bcp47#section-2.2.1 'Definition of primary language subtag'
[region subtag]: https://tools.ietf.org/html/bcp47#section-2.2.4 'Definition of region subtag'
[valid language subtag]: #valid-language-subtag 'Definition of valid language subtag'
[grandfathered tags]: https://tools.ietf.org/html/bcp47#section-2.2.8
[bcp 47]: https://tools.ietf.org/html/bcp47#section-2.1
8 changes: 7 additions & 1 deletion _rules/html-page-lang-xml-lang-match-5b7ae0.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ For each test target, the values of the [primary language subtags](https://tools

## Assumptions

This rule assumes that the presence of a `lang` attribute is being used to comply to WCAG. This rule doesn't test if the attribute is needed to comply to WCAG.
- This rule assumes that the presence of a `lang` attribute is being used to comply to WCAG. This rule doesn't test if the attribute is needed to comply to WCAG.

- This rule assumes that user agents and assistive technologies can programmatically determine [valid language subtags](#valid-language-subtag) even if these do not conform to the [BCP 47][] syntax.

- This rule assumes that [grandfathered tags][] are not used as these will not be recognized as [valid language subtags](#valid-language-subtag).

## Accessibility Support

Expand Down Expand Up @@ -153,3 +157,5 @@ This rule does not apply to `math` elements.
[extended language subtags]: https://tools.ietf.org/html/bcp47#section-2.2.2 'Definition of extended language subtag'
[primary language subtags]: https://tools.ietf.org/html/bcp47#section-2.2.1 'Definition of primary language subtag'
[valid language subtag]: #valid-language-subtag 'Definition of valid language subtag'
[grandfathered tags]: https://tools.ietf.org/html/bcp47#section-2.2.8
[bcp 47]: https://tools.ietf.org/html/bcp47#section-2.1
12 changes: 8 additions & 4 deletions pages/glossary/valid-language-subtag.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ unambiguous: true
objective: true
---

A _valid language subtag_ is a text string following the syntax as defined in [BCP 47](https://www.ietf.org/rfc/bcp/bcp47.txt), with a [primary language subtag](https://tools.ietf.org/html/bcp47#section-2.2.1) from the [language subtag registry](http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry).
A language tag consists of a [primary language subtag][] from the [language subtag registry][], optionally followed by a hyphen (`-`) and any sequence of characters.

Further reading:
_Note:_ This definition intentionally differs from the [BCP 47][] syntax as user agents and assistive technologies are more lenient in what they accept. The definition is however consistent with the behavior of the `:lang()` pseudo-selector as defined by [Selectors Level 3][]. For example, `de-hello` would be an accepted way to indicate German in current user agents and assistive technologies, despite not being valid according to [BCP 47][]. As a consequence of this definition, however, [grandfathered tags][] are not correctly recognized as valid language subtags.

- https://www.ietf.org/rfc/bcp/bcp47.txt
- http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
[bcp 47]: https://tools.ietf.org/html/bcp47#section-2.1
[grandfathered tags]: https://tools.ietf.org/html/bcp47#section-2.2.8
[language subtag registry]: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
[primary language subtag]: https://tools.ietf.org/html/bcp47#section-2.2.1
[selectors level 3]: https://drafts.csswg.org/selectors-3/#lang-pseudo
[subtag]: https://tools.ietf.org/html/bcp47#section-2.2