You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
230
237
231
-
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 <a class="allow-2119" href="#language-tag-completeness-implementation-defined">the "should"-level guidance</a>, 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`".
238
+
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`".
232
239
233
240
Combined with the use of [$LookupMatchingLocaleByBestFit$], this means {{Proofreader/availability()}} will give the following answers:
A <dfn>language availabilities partition</dfn> 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]]
258
-
259
264
A <dfn>language availabilities double</dfn> is a [=struct=] with the following [=struct/items=]:
260
265
261
266
* <dfn for="language availabilities double">input languages</dfn>, a [=language availabilities partition=]
To <dfn export>get the language availabilities partition</dfn> given a description |purpose| of the purpose for which we're checking language availability:
266
-
267
-
1. Let |partition| be «[ "{{Availability/available}}" → an empty [=set=], "{{Availability/downloading}}" → an empty [=set=], "{{Availability/downloadable}}" → an empty [=set=] ]».
268
-
269
-
1. [=list/For each=] human language |languageTag|, represented as a [=Unicode canonicalized locale identifier=], for which the user agent [=model availability/currently supports=] |purpose|:
270
-
271
-
1. [=set/Append=] |languageTag| to |partition|["{{Availability/available}}"].
272
-
273
-
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:
274
-
275
-
1. [=set/Append=] |languageTag| to |partition|["{{Availability/downloading}}"].
276
-
277
-
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:
278
-
279
-
1. [=set/Append=] |languageTag| to |partition|["{{Availability/downloadable}}"].
280
-
281
-
1. [=Assert=]: |partition|["{{Availability/available}}"], |partition|["{{Availability/downloading}}"], and |partition|["{{Availability/downloadable}}"] are disjoint.
282
-
283
-
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:
284
-
285
-
1. Let |missingLanguageTags| be the [=set=] of missing language tags necessary for that union to meet the language tag set completeness rules.
286
-
287
-
1. [=set/For each=] |languageTag| of |missingLanguageTags|:
288
-
289
-
1. <span id="language-tag-completeness-implementation-defined"></span>[=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.
290
-
291
-
1. Return |partition|.
292
-
</div>
293
-
294
-
<div algorithm>
295
-
To <dfn export>compute language availability</dfn> 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.
296
-
297
-
1. Let |availability| be "{{Availability/available}}".
298
-
299
-
1. [=set/For each=] |language| of |requestedLanguages|:
300
-
301
-
1. Let |unavailable| be true.
302
-
303
-
1. [=list/For each=] |availabilityToCheck| of « "{{Availability/available}}", "{{Availability/downloading}}", "{{Availability/downloadable}}" »:
304
-
305
-
1. Let |languagesWithThisAvailability| be |partition|[|availabilityToCheck|].
306
-
307
-
1. Let |bestMatch| be [$LookupMatchingLocaleByBestFit$](|languagesWithThisAvailability|, « |language| »).
308
-
309
-
1. If |bestMatch| is not undefined, then:
310
-
311
-
1. [=list/Replace=] |language| with |bestMatch|.\[[locale]] in |requestedLanguages|.
312
-
313
-
1. Set |availability| to the [=Availability/minimum availability=] given |availability| and |availabilityToCheck|.
314
-
315
-
1. Set |unavailable| to false.
316
-
317
-
1. [=iteration/Break=].
318
-
319
-
1. If |unavailable| is true, then return "{{Availability/unavailable}}".
Every {{Proofreader}} has a <dfn for="Proofreader">include correction type</dfn>, 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
545
490
<h2 id="security">Security considerations</h2>
546
491
547
492
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]].
0 commit comments