
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@andreasnicolaou/rtl-detect
Advanced tools
Modern, standards-based RTL (Right-to-Left) language detection for JavaScript/TypeScript. Detects if a locale is RTL, gets text direction, and lists all Unicode/ISO RTL languages.
Modern, standards-based RTL (Right-to-Left) language detection for JavaScript/TypeScript. Detects if a locale is RTL, gets text direction, and lists all Unicode/ISO RTL languages.
'rtl' or 'ltr') for any locale# npm
npm install @andreasnicolaou/rtl-detect
# yarn
yarn add @andreasnicolaou/rtl-detect
# pnpm
pnpm add @andreasnicolaou/rtl-detect
For direct browser usage without a build step:
<!-- unpkg CDN (latest version, unminified) -->
<script src="https://unpkg.com/@andreasnicolaou/rtl-detect/dist/index.umd.js"></script>
<!-- unpkg CDN (latest version, minified) -->
<script src="https://unpkg.com/@andreasnicolaou/rtl-detect/dist/index.umd.min.js"></script>
<!-- jsDelivr CDN (unminified) -->
<script src="https://cdn.jsdelivr.net/npm/@andreasnicolaou/rtl-detect/dist/index.umd.js"></script>
<!-- jsDelivr CDN (minified) -->
<script src="https://cdn.jsdelivr.net/npm/@andreasnicolaou/rtl-detect/dist/index.umd.min.js"></script>
Note: The library will be available as
rtlLanguageDetectoron the global scope when loaded via CDN in the browser.
import {
isRtlLanguage,
getTextDirection,
getRtlLanguageCodes,
parseLocale,
RtlLanguageDetector,
} from '@andreasnicolaou/rtl-detect';
isRtlLanguage('ar'); // true
getTextDirection('fa-IR'); // 'rtl'
const rtlCodes = getRtlLanguageCodes();
const parsed = parseLocale('ar-EG');
RtlLanguageDetector.isRtlLanguage('he'); // true
const {
isRtlLanguage,
getTextDirection,
getRtlLanguageCodes,
parseLocale,
RtlLanguageDetector,
} = require('@andreasnicolaou/rtl-detect');
isRtlLanguage('ar'); // true
getTextDirection('fa-IR'); // 'rtl'
const rtlCodes = getRtlLanguageCodes();
const parsed = parseLocale('ar-EG');
RtlLanguageDetector.isRtlLanguage('he'); // true
<script src="https://unpkg.com/@andreasnicolaou/rtl-detect/dist/index.umd.min.js"></script>
<script>
const { isRtlLanguage, getTextDirection, getRtlLanguageCodes, parseLocale } = rtlLanguageDetector;
isRtlLanguage('ar'); // true
getTextDirection('fa-IR'); // 'rtl'
const rtlCodes = getRtlLanguageCodes();
const parsed = parseLocale('ar-EG');
rtlLanguageDetector.isRtlLanguage('he'); // true
</script>
| Function/Export | Signature | Description |
|---|---|---|
| isRtlLanguage | (locale: string): boolean | Returns true if the locale or language code is right-to-left. |
| getTextDirection | (locale: string): 'rtl' | 'ltr' | Returns the text direction for the given locale. |
| getRtlLanguageCodes | (): readonly string[] | Returns a frozen array of all supported RTL language codes. |
| parseLocale | (locale: string): ParsedLocaleInfo | undefined | Parses a locale string into its language and country code components. Automatically strips encoding/variant suffixes (e.g., .UTF-8, @calendar=gregorian). |
| RtlLanguageDetector | class | Static class with all the above as static methods. |
| Type | Definition | Description |
|---|---|---|
TextDirection | 'rtl' | 'ltr' | Text direction, either right-to-left or left-to-right |
ParsedLocaleInfo | { language: string; countryCode?: string } | Parsed locale object with language and optional country code |
This library uses an immutable list of RTL language codes (Unicode/ISO-compliant) to determine text direction for any locale or language code. It works in Node.js, browsers, and TypeScript projects, and is fully type-safe.
MIT
Contributions are welcome! Please open issues or pull requests for improvements or new features.
FAQs
Modern, standards-based RTL (Right-to-Left) language detection for JavaScript/TypeScript. Detects if a locale is RTL, gets text direction, and lists all Unicode/ISO RTL languages.
We found that @andreasnicolaou/rtl-detect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.