Skip to content

shahradelahi/dir-detect

Repository files navigation

dir-detect

CI NPM Version MIT License Install Size

A tiny and simple package for detecting the direction of a locale.


📦 Installation

npm install dir-detect
Install using your favorite package manager

pnpm

pnpm install dir-detect

yarn

yarn add dir-detect

📖 Usage

import { 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'

📚 API

isRTL(locale: string): boolean

Checks if a locale is right-to-left.

getDirection(locale: string): Direction

Gets the direction of a locale. Returns 'rtl' or 'ltr'.

📑 References

The data for RTL languages and scripts is based on information from the following sources:

🤝 Contributing

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! 🙏

License

MIT © Shahrad Elahi and contributors.

About

↔️ A tiny and simple package for detecting the direction of a locale.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published