diff --git a/index.bs b/index.bs index 0e0f826..e095192 100644 --- a/index.bs +++ b/index.bs @@ -15,6 +15,13 @@ Assume Explicit For: yes Die On: warning +
+spec: writing-assistance-apis + type: dfn; text: computing language availability + type: dfn; text: getting the language availabilities partition + type: dfn; text: language availabilities partition ++
urlPrefix: https://tc39.es/ecma402/; spec: ECMA-402
type: dfn; text: [[AvailableLocales]]; url: sec-internal-slots
@@ -228,7 +235,7 @@ enum CorrectionType { "spelling", "punctuation", "capitalization", "grammar" };
A common setup seen in today's software is to support two types of written Chinese: "traditional Chinese" and "simplified Chinese". Let's suppose that the user agent supports proofreading text written in traditional Chinese with no downloads, and simplified Chinese after a download.
- One way this could be implemented would be for [=proofreader language availabilities double=] to return that "`zh-Hant`" is in the [=language availabilities double/input languages=]["{{Availability/available}}"] set, and "`zh`" and "`zh-Hans`" are in the [=language availabilities double/input languages=]["{{Availability/downloadable}}"] set. This return value conforms to the requirements of the language tag set completeness rules, in ensuring that "`zh`" is present. Per the "should"-level guidance, the implementation has determined that "`zh`" belongs in the set of downloadable input languages, with "`zh-Hans`", instead of in the set of available input languages, with "`zh-Hant`".
+ One way this could be implemented would be for [=proofreader language availabilities double=] to return that "`zh-Hant`" is in the [=language availabilities double/input languages=]["{{Availability/available}}"] set, and "`zh`" and "`zh-Hans`" are in the [=language availabilities double/input languages=]["{{Availability/downloadable}}"] set. This return value conforms to the requirements of the language tag set completeness rules, in ensuring that "`zh`" is present. Per the [=get the language availabilities partition=] algorithm steps, the implementation has determined that "`zh`" belongs in the set of downloadable input languages, with "`zh-Hans`", instead of in the set of available input languages, with "`zh-Hant`".
Combined with the use of [$LookupMatchingLocaleByBestFit$], this means {{Proofreader/availability()}} will give the following answers:
@@ -254,73 +261,11 @@ enum CorrectionType { "spelling", "punctuation", "capitalization", "grammar" };
Language availability
-A language availabilities partition is a [=map=] whose [=map/keys=] are "{{Availability/downloading}}", "{{Availability/downloadable}}", or "{{Availability/available}}", and whose [=map/values=] are [=sets=] of strings representing [=Unicode canonicalized locale identifiers=]. [[!ECMA-402]]
-
A language availabilities double is a [=struct=] with the following [=struct/items=]:
* input languages, a [=language availabilities partition=]
* correction explanation languages, a [=language availabilities partition=]
-
- To get the language availabilities partition given a description |purpose| of the purpose for which we're checking language availability:
-
- 1. Let |partition| be «[ "{{Availability/available}}" → an empty [=set=], "{{Availability/downloading}}" → an empty [=set=], "{{Availability/downloadable}}" → an empty [=set=] ]».
-
- 1. [=list/For each=] human language |languageTag|, represented as a [=Unicode canonicalized locale identifier=], for which the user agent [=model availability/currently supports=] |purpose|:
-
- 1. [=set/Append=] |languageTag| to |partition|["{{Availability/available}}"].
-
- 1. [=list/For each=] human language |languageTag|, represented as a [=Unicode canonicalized locale identifier=], for which the user agent believes it will be able to [=model availability/support=] |purpose|, but only after finishing a download that is already ongoing:
-
- 1. [=set/Append=] |languageTag| to |partition|["{{Availability/downloading}}"].
-
- 1. [=list/For each=] human language |languageTag|, represented as a [=Unicode canonicalized locale identifier=], for which the user agent believes it will be able to [=model availability/support=] |purpose|, but only after performing a not-currently-ongoing download:
-
- 1. [=set/Append=] |languageTag| to |partition|["{{Availability/downloadable}}"].
-
- 1. [=Assert=]: |partition|["{{Availability/available}}"], |partition|["{{Availability/downloading}}"], and |partition|["{{Availability/downloadable}}"] are disjoint.
-
- 1. If the [=set/union=] of |partition|["{{Availability/available}}"], |partition|["{{Availability/downloading}}"], and |partition|["{{Availability/downloadable}}"] does not meet the language tag set completeness rules, then:
-
- 1. Let |missingLanguageTags| be the [=set=] of missing language tags necessary for that union to meet the language tag set completeness rules.
-
- 1. [=set/For each=] |languageTag| of |missingLanguageTags|:
-
- 1. [=set/Append=] |languageTag| to one of the three sets. Which of the sets to append to is [=implementation-defined=], and should be guided by considerations similar to that of [$LookupMatchingLocaleByBestFit$] in terms of keeping "best fallback languages" together.
-
- 1. Return |partition|.
-
-
-
- To compute language availability given an [=ordered set=] of strings |requestedLanguages| and a [=language availabilities partition=] |partition|, perform the following steps. They return an {{Availability}} value, and they mutate |requestedLanguages| in place to update language tags to their best-fit matches.
-
- 1. Let |availability| be "{{Availability/available}}".
-
- 1. [=set/For each=] |language| of |requestedLanguages|:
-
- 1. Let |unavailable| be true.
-
- 1. [=list/For each=] |availabilityToCheck| of « "{{Availability/available}}", "{{Availability/downloading}}", "{{Availability/downloadable}}" »:
-
- 1. Let |languagesWithThisAvailability| be |partition|[|availabilityToCheck|].
-
- 1. Let |bestMatch| be [$LookupMatchingLocaleByBestFit$](|languagesWithThisAvailability|, « |language| »).
-
- 1. If |bestMatch| is not undefined, then:
-
- 1. [=list/Replace=] |language| with |bestMatch|.\[[locale]] in |requestedLanguages|.
-
- 1. Set |availability| to the [=Availability/minimum availability=] given |availability| and |availabilityToCheck|.
-
- 1. Set |unavailable| to false.
-
- 1. [=iteration/Break=].
-
- 1. If |unavailable| is true, then return "{{Availability/unavailable}}".
-
- 1. Return |availability|.
-
-
The {{Proofreader}} class
Every {{Proofreader}} has a include correction type, a [=boolean=] or default to false, set during creation.
@@ -545,4 +490,3 @@ Please see [[WRITING-ASSISTANCE-APIS#privacy]] for a discussion of privacy consi
Security considerations
Please see [[WRITING-ASSISTANCE-APIS#security]] for a discussion of security considerations for the translator and language detector APIs. That text was written to apply to all APIs sharing the same infrastructure, as noted in [[#dependencies]].
-