Skip to content

Commit

Permalink
Editorial: Better align BestAvailableLocale with BCP 47
Browse files Browse the repository at this point in the history
Per RFC 4647 section 3.4 - Lookup
(https://www.rfc-editor.org/rfc/rfc4647.html#section-3.4 ),
> Single letter or digit subtags (including both the letter 'x', which
> introduces private-use sequences, and the subtags that introduce
> extensions) are removed at the same time as their closest trailing
> subtag.

This is relevant for a requested locale such as "en-x-y-z-foo", which
should be truncated first to "en-x-y-z" and then to "en" ("y" is removed
at the same time as its closest trailing subtag "z" and "x" is removed
at the same time as its closest trailing subtag "y", which means all
three are removed in one step).

However, the change is still editorial because BestAvailableLocale is
never called with _availableLocales_ that would contain a language tag
like "en-x-y".
  • Loading branch information
gibson042 committed Mar 2, 2024
1 parent ca1c0ce commit 01b3230
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spec/negotiation.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ <h1>
1. Repeat,
1. If _availableLocales_ contains _candidate_, return _candidate_.
1. Let _pos_ be the index into _candidate_ of the last occurrence of *"-"* (code unit 0x002D HYPHEN-MINUS). If that character does not occur, return *undefined*.
1. If _pos_ &ge; 2 and the substring of _candidate_ from _pos_ - 2 to _pos_ - 1 is *"-"*, set _pos_ to _pos_ - 2.
1. Repeat, while _pos_ &ge; 2 and the substring of _candidate_ from _pos_ - 2 to _pos_ - 1 is *"-"*,
1. Set _pos_ to _pos_ - 2.
1. Set _candidate_ to the substring of _candidate_ from 0 to _pos_.
</emu-alg>

Expand Down

0 comments on commit 01b3230

Please sign in to comment.