forked from fingerprintjs/fingerprintjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguages.ts
More file actions
26 lines (22 loc) · 833 Bytes
/
languages.ts
File metadata and controls
26 lines (22 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { isChromium, isChromium86OrNewer } from '../utils/browser'
export default function getLanguages(): string[][] {
const n = navigator
const result: string[][] = []
const language = n.language || n.userLanguage || n.browserLanguage || n.systemLanguage
if (language !== undefined) {
result.push([language])
}
if (Array.isArray(n.languages)) {
// Starting from Chromium 86, there is only a single value in `navigator.language` in Incognito mode:
// the value of `navigator.language`. Therefore the value is ignored in this browser.
if (!(isChromium() && isChromium86OrNewer())) {
result.push(n.languages)
}
} else if (typeof n.languages === 'string') {
const languages = n.languages as string
if (languages) {
result.push(languages.split(','))
}
}
return result
}