# General Translation Platform: getLocaleDirection
URL: https://generaltranslation.com/en-US/docs/platform/core/reference/gt-class-methods/locales/get-locale-direction.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Return the text direction for a locale. API reference for getLocaleDirection.

General Translation returns `'ltr'` for left-to-right languages or `'rtl'` for right-to-left languages.

## Overview [#overview]

Call `getLocaleDirection` on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance with an optional locale code. When omitted, it uses the instance's `targetLocale`.

```typescript
const gt = new GT({ sourceLocale: 'en', targetLocale: 'ar' });

const direction = gt.getLocaleDirection('ar');
console.log(direction); // "rtl"

const englishDirection = gt.getLocaleDirection('en-US');
console.log(englishDirection); // "ltr"
```

Signature:

```typescript
getLocaleDirection(locale?: string): 'ltr' | 'rtl'
```

*Note: `getLocaleDirection` runs locally using `Intl.Locale` and does not require an API key. It uses the instance's `targetLocale` when `locale` is omitted. For lookups without a `GT` instance, see the standalone [`getLocaleDirection`](/docs/platform/core/reference/utility-functions/locales/get-locale-direction).*

## How it works [#how-it-works]

- **Direction detection.** Returns `'ltr'` for left-to-right languages (most languages worldwide) and `'rtl'` for right-to-left languages (Arabic, Hebrew, Persian, Urdu, and others).
- **Locale fallback.** When `locale` is omitted, the instance's `targetLocale` is used.
- **Missing locale.** Throws an `Error` if no locale is provided and the instance has no `targetLocale` configured.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`locale`](#locale) | BCP-47 locale code to check text direction for. | `string` | Yes | `this.targetLocale` |

### `locale` [#locale]

**Type** `string` · **Optional** · **Default** `this.targetLocale`

BCP-47 locale code to check text direction for. If not provided, uses the instance's `targetLocale`.

## Returns [#returns]

**Type** `'ltr' | 'rtl'`

The text direction for the locale:

- `'ltr'`: left-to-right (most languages).
- `'rtl'`: right-to-left (Arabic, Hebrew, Persian, Urdu, etc.).

Throws an `Error` if no locale is provided and the instance has no `targetLocale` configured.

## Examples [#examples]

```typescript
const gt = new GT({ sourceLocale: 'en', targetLocale: 'ar' });

// Check different language directions
console.log(gt.getLocaleDirection()); // "rtl" (uses targetLocale 'ar')
console.log(gt.getLocaleDirection('en')); // "ltr"
console.log(gt.getLocaleDirection('ar')); // "rtl"
console.log(gt.getLocaleDirection('he')); // "rtl"
console.log(gt.getLocaleDirection('fa')); // "rtl"
console.log(gt.getLocaleDirection('fr')); // "ltr"
```

## Notes [#notes]

- Returns `'ltr'` for all left-to-right languages (most languages worldwide).
- Returns `'rtl'` for right-to-left languages (Arabic, Hebrew, Persian, etc.).

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
