Notification.lang

注: この機能は Web Worker 内で利用可能です。

安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。

langNotification インターフェイスの読み取り専用プロパティで、 Notification() コンストラクターの lang オプションで指定された通知の言語を示します。

言語自体は文字列でRFC 5646: 言語識別タグ (BCP 47) を表します。簡単なリファレンスとしては、 Sitepoint の ISO 2 letter language codes ページを見てください。

文字列で、言語タグを指定します。

次のスニペットは通知を発行するためのものです。単純な options オブジェクトが生成され、通知が Notification() コンストラクターを使用して発行されます。

js
const options = {
  body: "Do you like my body?",
  lang: "en-US",
};

const n = new Notification("Test notification", options);

console.log(n.lang); // should return 'en-US'

仕様書

Specification
Notifications API Standard
# dom-notification-lang

ブラウザーの互換性

BCD tables only load in the browser

関連情報