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
Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ See [below](#language-tag-handling) for more on the details of how language tags
47
47
Here is the basic usage of the translator API, with no error handling:
48
48
49
49
```js
50
-
consttranslator=awaitai.translator.create({
50
+
consttranslator=awaitTranslator.create({
51
51
sourceLanguage:"en",
52
52
targetLanguage:"ja"
53
53
});
@@ -65,7 +65,7 @@ Note that the `create()` method call here might cause the download of a translat
65
65
A similar simplified example of the language detector API:
66
66
67
67
```js
68
-
constdetector=awaitai.languageDetector.create();
68
+
constdetector=awaitLanguageDetector.create();
69
69
70
70
constresults=awaitdetector.detect(someUserText);
71
71
for (constresultof results) {
@@ -84,7 +84,7 @@ For more details on the ways low-confidence results are excluded, see [the speci
84
84
If there are certain languages you need to be able to detect for your use case, you can include them in the `expectedInputLanguages` option when creating a language detector:
This will allow the implementation to download additional resources like language detection models if necessary, and will ensure that the promise is rejected with a `"NotSupportedError"``DOMException` if the browser is unable to detect the given input languages.
@@ -102,7 +102,7 @@ Here is an example that adds capability checking to log more information and fal
@@ -146,7 +146,7 @@ async function translateUnknownCustomerInput(textToTranslate, targetLanguage) {
146
146
For cases where using the API is only possible after a download, you can monitor the download progress (e.g. in order to show your users a progress bar) using code such as the following:
147
147
148
148
```js
149
-
consttranslator=awaitai.translator.create({
149
+
consttranslator=awaitTranslator.create({
150
150
sourceLanguage,
151
151
targetLanguage,
152
152
monitor(m) {
@@ -189,7 +189,7 @@ The "usage" concept is specific to the implementation, and could be something li
189
189
This allows detecting failures due to overlarge inputs and giving clear feedback to the user, with code such as the following:
In some cases, instead of providing errors after the fact, the developer needs to be able to communicate to the user how close they are to the limit. For this, they can use the `inputQuota` property and the `measureInputUsage()` method on the translator or language detector objects:
207
207
208
208
```js
209
-
consttranslator=awaitai.translator.create({
209
+
consttranslator=awaitTranslator.create({
210
210
sourceLanguage:"en",
211
211
targetLanguage:"jp"
212
212
});
@@ -247,7 +247,7 @@ The API comes equipped with a couple of `signal` options that accept `AbortSigna
@@ -281,7 +281,7 @@ A future option might be to instead have the API return back the splitting of th
281
281
282
282
The current design envisions that `availability()` methods will _not_ cause downloads of language packs or other material like a language detection model. Whereas, the `create()` methods _can_ cause downloads. In all cases, whether or not creation will initiate a download can be detected beforehand by the corresponding `availability()` method.
283
283
284
-
After a developer has a `AITranslator` or `AILanguageDetector` object, further calls are not expected to cause any downloads. (Although they might require internet access, if the implementation is not entirely on-device.)
284
+
After a developer has a `Translator` or `LanguageDetector` object, further calls are not expected to cause any downloads. (Although they might require internet access, if the implementation is not entirely on-device.)
285
285
286
286
This design means that the implementation must have all information about the capabilities of its translation and language detection models available beforehand, i.e. "shipped with the browser". (Either as part of the browser binary, or through some out-of-band update mechanism that eagerly pushes updates.)
287
287
@@ -297,7 +297,7 @@ Some sort of mitigation may be necessary here. We believe this is adjacent to ot
297
297
* Partitioning download status by top-level site, introducing a fake download (which takes time but does not actually download anything) for the second-onward site to download a language pack.
298
298
* Only exposing a fixed set of languages to this API, e.g. based on the user's locale or the document's main language.
299
299
300
-
As a first step, we require that detecting the availability of translation/detection be done via individual calls to `ai.translator.availability()` and `ai.languageDetector.availability()`. This allows browsers to implement possible mitigation techniques, such as detecting excessive calls to these methods and starting to return `"unavailable"`.
300
+
As a first step, we require that detecting the availability of translation/detection be done via individual calls to `Translator.availability()` and `LanguageDetector.availability()`. This allows browsers to implement possible mitigation techniques, such as detecting excessive calls to these methods and starting to return `"unavailable"`.
301
301
302
302
Another way in which this API might enhance the web's fingerprinting surface is if translation and language detection models are updated separately from browser versions. In that case, differing results from different versions of the model provide additional fingerprinting bits beyond those already provided by the browser's major version number. Mandating that older browser versions not receive updates or be able to download models from too far into the future might be a possible remediation for this.
303
303
@@ -320,10 +320,10 @@ That said, we are aware of [research](https://arxiv.org/abs/2005.08595) on trans
320
320
The current design requires multiple async steps to do useful things:
0 commit comments