A tiny and simple package for detecting the direction of a locale.
npm install dir-detectInstall using your favorite package manager
pnpm
pnpm install dir-detectyarn
yarn add dir-detectimport { getDirection, isRTL } from 'dir-detect';
// isRTL
console.log(isRTL('en')); // false
console.log(isRTL('ar')); // true
// getDirection
console.log(getDirection('en')); // 'ltr'
console.log(getDirection('ar')); // 'rtl'Checks if a locale is right-to-left.
Gets the direction of a locale. Returns 'rtl' or 'ltr'.
The data for RTL languages and scripts is based on information from the following sources:
Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub
Thanks again for your support, it is much appreciated! 🙏
MIT © Shahrad Elahi and contributors.