Intl.Locale.prototype.getTextInfo()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Intl.Locale インスタンスの getTextInfo() メソッドは、ロケールに対して ltr (左書き) または rtl (右書き) で示される文字の並び順を返します。
メモ:
一部のブラウザーのあるバージョンでは、このメソッドが textInfo と呼ばれるアクセサープロパティとして実装されていました。しかしこの実装ではアクセスするたびに新しいオブジェクトを返すため、locale.textInfo === locale.textInfo が false を返してしまい、この状況を防ぐために、現在はメソッドとして実装されています。詳細については、ブラウザーの互換性の表を確認してください。
構文
js
getTextInfo()
引数
なし。
返値
UTS 35 の Layouts Elements で定義されているロケールデータに結び付けられたテキスト組版情報を表すオブジェクト。このオブジェクトは以下のプロパティを持ちます。
direction-
ロケールのテキストの方向を示す文字列。
"ltr"(左書き) または"rtl"(右書き) のいずれかです。
例
>テキスト情報の取得
指定された Locale で対応している書字方向を返します。
js
const ar = new Intl.Locale("ar");
console.log(ar.getTextInfo()); // { direction: "rtl" }
console.log(ar.getTextInfo().direction); // "rtl"
js
const es = new Intl.Locale("es");
console.log(es.getTextInfo()); // { direction: "ltr" }
console.log(es.getTextInfo().direction); // "ltr"
仕様書
| Specification |
|---|
| Intl Locale Info Proposal> # sec-Intl.Locale.prototype.getTextInfo> |