From 332aa0aa67b71de65f6ee89613b1e2c6b479bc40 Mon Sep 17 00:00:00 2001 From: uzlopak Date: Sun, 29 Oct 2023 03:30:16 +0100 Subject: [PATCH] lib: add navigator.language & navigator.languages --- doc/api/globals.md | 35 +++++++++++++++++++++++++++++++++ lib/internal/navigator.js | 19 ++++++++++++++++++ test/parallel/test-navigator.js | 18 +++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/doc/api/globals.md b/doc/api/globals.md index ebaaf2a6e0012e..e0df462c306452 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -637,6 +637,41 @@ 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`