Skip to content

Commit 91af943

Browse files
committed
Nerf supportedLanguages() to slightly help with privacy
1 parent 916dbed commit 91af943

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,13 @@ If no language can be detected with reasonable confidence, this API returns an e
155155
To get a list of languages which the current browser can translate, we can use the following code:
156156

157157
```js
158-
for (const { language, availability } of await translation.supportedLanguages()) {
158+
for (const language of await translation.supportedLanguages()) {
159159
let text = languageTagToHumanReadable(lang, "en"); // see appendix
160-
if (availibility === "after-download") {
161-
text += "*";
162-
}
163-
164160
languageDropdown.append(new Option(text, language));
165161
}
166162
```
167163

168-
Here `availability` is either `"after-download"` or `"readily"`.
164+
This method does not distinguish between languages which are available `"readily"` vs. `"after-download"`, because giving that information for all languages at once is too much of a [privacy issue](#privacy-considerations). Instead, the developer must make individual calls to `canTranslate()`, which gives the browser more opportunities to apply privacy mitigations.
169165

170166
## Detailed design
171167

@@ -180,7 +176,7 @@ interface Translation {
180176
Promise<TranslationAvailability> canDetect();
181177
Promise<LanguageDetector> createDetector();
182178
183-
Promise<sequence<AvailableLanguage>>> supportedLanguages();
179+
Promise<sequence<DOMString>>> supportedLanguages();
184180
};
185181
186182
[Exposed=(Window,Worker)]
@@ -214,11 +210,6 @@ dictionary TranslationLanguageOptions {
214210
DOMString sourceLanguage;
215211
};
216212
217-
dictionary AvailableLanguage {
218-
DOMString language;
219-
TranslationAvailability availability;
220-
};
221-
222213
dictionary LanguageDetectionResult {
223214
DOMString? detectedLanguage;
224215
double confidence;
@@ -280,7 +271,9 @@ Some sort of mitigation may be necessary here. We believe this is adjacent to ot
280271

281272
* Grouping language packs to reduce the number of bits, so that downloading one language also downloads others in its group.
282273
* 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.
283-
* Only exposing a fixed set of languages to this API, e.g. based on the user's locale.
274+
* Only exposing a fixed set of languages to this API, e.g. based on the user's locale or the document's main language.
275+
276+
As a first step, we require that detecting the availability of translation for a given language pair be done via individual calls to `canTranslate()`. This allows browsers to implement possible mitigation techniques, such as detecting excessive calls to `canTranslate()` and starting to return `"no"`.
284277

285278
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.
286279

0 commit comments

Comments
 (0)