From ec11b6d474b571f04617b098cd9484b56d4c9e40 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Sun, 29 Oct 2023 13:53:40 +0100 Subject: [PATCH] lib: add navigator.language & navigator.languages --- doc/api/globals.md | 34 +++++++++++++++++++++++++++++++++ lib/internal/navigator.js | 23 ++++++++++++++++++++++ test/parallel/test-navigator.js | 18 +++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/doc/api/globals.md b/doc/api/globals.md index ebaaf2a6e0012e..fe7a998708c72c 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -637,6 +637,40 @@ logical processors available to the current Node.js instance. console.log(`This process is running on ${navigator.hardwareConcurrency} logical processors`); ``` +### `navigator.language` + + + +* {string} + +The `navigator.language` read-only property returns a string representing the +preferred language of the Node.js instance. + +The value is representing the language version as defined in RFC <5646>. +The default value is `'en-US'`. + +```js +console.log(`The preferred language of the Node.js instance has the tag '${navigator.language}'`); +``` + +### `navigator.languages` + + + +* {Array} + +The `navigator.languages` read-only property returns an array of strings +representing the preferred languages of the Node.js instance. +The default value is `['en-US']`. + +```js +console.log(`The preferred languages are '${navigator.language}'`); +``` + ### `navigator.userAgent`