包详细信息

intl-locale-textinfo-polyfill

brettz96.9kBSD-3-Clause2.1.1

Library will help you to detect if the locale is right-to-left language.

intl-locale, intl, rtl-detect, locale direction

自述文件

intl-locale-textinfo-polyfill

This library will help you to detect if the locale is right-to-left language or not.

It implements part of this now Stage 3 intl-locale-info proposal.

The library has begun as a fork of rtl-detect, but it strives to adhere to the Intl.Locale (textInfo) proposal (notably, locales with underscores as in the form en_US are not accepted).

Usage

import the library as a ponyfill

import Locale from 'intl-locale-textinfo-polyfill';

const { direction } = new Locale('he').textInfo;
// "rtl"

import the library as a polyfill

import 'intl-locale-textinfo-polyfill/lib/polyfill.js';

const { direction } = new Intl.Locale('he').textInfo;
// `direction` will be "rtl"

Intl.Locale#textInfo

This returns an object with the language direction for the locale.

Examples:

const { direction } = new Intl.Locale('ar-JO').textInfo;
// `direction` will be "rtl"
const { direction } = new Intl.Locale('ar').textInfo;
// `direction` will be "rtl"
const { direction } = new Intl.Locale('en-US')).textInfo;
// `direction` will be "ltr"

更新日志

CHANGES for intl-locale-textinfo-polyfill

2.1.1

  • fix: TS index import issue with outFile

2.1.0

  • fix: force setting of Intl.Locale in polyfill

2.0.2

  • fix: TS types

2.0.1

  • fix: clarify regex and allow variation segment
  • fix: add missing items; remove Kurdish (most likely script is Latin)
  • fix: RTL scripts

2.0.0

  • fix: add types

1.0.1

  • fix: add Dari (prs)

1.0.0

  • Initial version