getLocaleDirection

getLocaleDirection(locale) returns text direction for a locale tag:

This function uses `Intl.Locale`.

ts
1import { getLocaleDirection } from '@beforesemicolon/intl'2 3getLocaleDirection('en-US') // "ltr"4getLocaleDirection('ar') // "rtl"5getLocaleDirection('fa') // "rtl"6getLocaleDirection('zh-Hant') // "ltr"

Signature

ts
1function getLocaleDirection(locale: string): 'ltr' | 'rtl'

Practical notes

ts
1document.documentElement.dir = getLocaleDirection(selectedLocale)
edit this doc