Library will help you to detect if the locale is right-to-left language.
npm install intl-locale-textinfo-polyfillThis 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 (getTextInfo()) proposal (notably,
locales with underscores as in the form en_US are not accepted).
``js
import Locale from 'intl-locale-textinfo-polyfill';
const { direction } = new Locale('he').getTextInfo();
// "rtl"
`
`js
import 'intl-locale-textinfo-polyfill/lib/polyfill.js';
const { direction } = new Intl.Locale('he').getTextInfo();
// direction will be "rtl"`
This returns an object with the language direction for the locale.
Examples:
`jsdirection
const { direction } = new Intl.Locale('ar-JO').getTextInfo();
// will be "rtl"`
`jsdirection
const { direction } = new Intl.Locale('ar').getTextInfo();
// will be "rtl"`
`jsdirection
const { direction } = new Intl.Locale('en-US').getTextInfo();
// will be "ltr"``