# i18n & RTL

> Localize React Native pickers: Intl month, weekday and AM/PM names, 12/24h clock, first day of week, date order and automatic right-to-left layout.

# Internationalization & RTL

Every name the pickers display comes from the JavaScript `Intl` API for the `locale` you pass (or the device default), and every UI string is a prop.

## What `locale` controls

| Component | Derived from `locale` |
| --- | --- |
| `Calendar` / `DatePicker` | Month title, weekday names, first day of week, day accessibility labels |
| `DateWheelPicker` | Month names, column order (D/M/Y vs M/D/Y vs Y/M/D) |
| `TimePicker` / `TimeRangePicker` | 12h vs 24h, AM/PM labels |
| `DateTimePicker` | The day labels, plus the calendar and time as above |
| `MonthPicker` | Month names |
| `CountryPicker` / `PhoneField` | Country names, where the engine has them |
| `TimeZonePicker` | Time zone names, where the engine has them |

```tsx live
import { useState } from 'react';
import { View, Text } from 'react-native';
import { DatePicker, TimePicker } from 'patine-ui';

export default function Example() {
  const [d, setD] = useState<Date | null>(new Date());
  const [t, setT] = useState(new Date());
  return (
    <View style={{ gap: 12 }}>
      <Text style={{ fontWeight: '600' }}>he-IL</Text>
      <DatePicker value={d} onValueChange={setD} locale="he-IL" />
      <Text style={{ fontWeight: '600' }}>ar-EG</Text>
      <TimePicker value={t} onValueChange={setT} locale="ar-EG" />
    </View>
  );
}
```

Pass your app's language, for example from `expo-localization` or `i18next`:

```tsx
import { getLocales } from 'expo-localization';
const locale = getLocales()[0]?.languageTag; // 'fr-CA'

<DatePicker locale={locale} … />
```

### Hermes and `Intl`

Hermes (the default engine) supports `Intl.DateTimeFormat` on iOS and Android. If a locale or feature is missing at runtime, every helper falls back to English names instead of throwing. `firstDayOfWeek` uses `Intl.Locale` week info where available; otherwise it defaults to Sunday, so pass `firstDayOfWeek={1}` explicitly if you need Monday everywhere.

Hermes can't list or name countries and time zones (`Intl.DisplayNames`, `Intl.supportedValuesOf`), so [`CountryPicker`](../components/country-picker) and [`TimeZonePicker`](../components/time-zone-picker) ship their lists. Names show in the user's language where the engine provides them, and in English otherwise.

## Translating UI strings

| Component | String props (defaults) |
| --- | --- |
| Picker sheets | `confirmLabel` (`Done`, `OK` in Material), `cancelLabel` (`Cancel`), `title` |
| `Select` | `placeholder` (`Select…`), `label`, `sheetTitle`, `searchPlaceholder` (`Search`), `emptyText` (`No results`) |
| `SelectList` | `searchPlaceholder`, `emptyText`, `loadingText` (`Loading…`), `searchPrompt` (`Type to search`) |
| `CountryPicker` | `placeholder` (`Select a country`), `searchPlaceholder` (`Search countries`), `preferredLabel` (`Suggested`), `allCountriesLabel` (`All countries`) |
| `PhoneField` | `label`, `countrySheetTitle` (`Country code`) |
| `TimeZonePicker` | `placeholder` (`Select a time zone`), `searchPlaceholder` (`Search time zones`), `preferredLabel` (`Your time zone`), `allTimeZonesLabel` (`All time zones`) |
| `EmojiPicker` | `searchPlaceholder` (`Search emoji`), `emptyText` (`No emoji found`), `categoryLabels` |
| `TimePicker` | `dayPeriodLabels` (from the locale) |
| `TimeRangePicker` | `startLabel` (`Start`), `endLabel` (`End`) |
| `DurationPicker` | `labels` (`h`, `min`, `s`) |
| `ColorPicker` | `labels`: tab, slider and button names (`Grid`, `Hue`, `Opacity`, `Copy`…) |
| `Calendar`, `WeekStrip` | `formatTitle` |
| `ActionSheet` | `cancelLabel` (`Cancel`) |
| `Slider` | `thumbLabels` (`Minimum`, `Maximum`) for screen readers |
| `InputOTP`, `Rating` | `accessibilityLabel` (`Verification code`, `Rating`) |

```tsx
const { t } = useTranslation();

<DatePickerSheet confirmLabel={t('done')} cancelLabel={t('cancel')} title={t('pickDate')} … />
<Select placeholder={t('select')} searchPlaceholder={t('search')} emptyText={t('noResults')} … />
```

## Right-to-left

All layouts use logical `start` / `end` properties, so they mirror automatically when `I18nManager.isRTL` is true:

- Calendar arrows swap direction, and swipe direction follows.
- The range band grows from the correct side.
- Select check marks, icons and chips sit on the logical end / start.
- Multi-wheel columns follow the row direction.

Enable RTL the standard React Native way:

```ts
import { I18nManager } from 'react-native';
I18nManager.allowRTL(true);
I18nManager.forceRTL(true); // requires an app reload
```

### On the web

React Native Web has no RTL layout flag: set `dir="rtl"` on `<html>` (Patine reads it), or pass `dir="rtl"` to `PatineProvider`. The provider hands the direction to React Native Web, so `marginStart`, `paddingEnd` and `start` land on the right side, overlays (dialogs, sheets, menus) follow it too, and every `Text` aligns to the start edge whatever its script, so a Latin name in a Hebrew list lines up with the Hebrew around it. Setting both keeps the browser's own parts (scrollbars, inputs) in the same direction.

```tsx
<PatineProvider dir={locale === 'he' ? 'rtl' : 'ltr'}>…</PatineProvider>
```

## Search in any language

The select search folds case and **diacritics** (`é` → `e`) and strips **Hebrew niqqud**, so users don't need to type accents. Use `keywords` to make options findable in other languages or by synonyms:

```ts
{ label: 'Germany', value: 'DE', keywords: ['Deutschland', 'Allemagne', 'גרמניה'] }
```
