> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# usePrimerLocalization

> Hook that returns the SDK's resolved locale, its translated strings, and currency and date formatters.

> [!WARNING]
>
> Primer Checkout React Native SDK is currently in **beta** (v3.0.0-beta.1).
> The API is subject to change before the stable release.

`usePrimerLocalization` returns the locale that Primer Checkout uses for the text it draws, with functions to translate the SDK's strings and to format amounts and dates in that locale. Use it to make text in your own UI match the language of the SDK components.

## Signature

```tsx theme={"dark"}
function usePrimerLocalization(): LocalizationResult;
```

Import the hook with `import { usePrimerLocalization } from '@primer-io/react-native'`. `LocalizationResult` and `TranslationParams` are exported as types.

The hook does not need [`PrimerCheckoutProvider`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider). You can call it anywhere in your app.

## Returns

| Field | Type | Description |
| - | - | - |
| `locale` | `string` | The supported locale the SDK resolved from the device locale, for example `'de'` or `'pt-BR'`. See [How the locale is resolved](#how-the-locale-is-resolved). |
| `t` | `(key: string, params?: TranslationParams) => string` | Returns the SDK string for `key` in `locale`. |
| `formatCurrency` | `(amountInMinorUnits: number, currencyCode: string) => string` | Formats an amount given in minor units, for example `1050` with `'EUR'`. |
| `formatDate` | `(date: Date, options?: Intl.DateTimeFormatOptions) => string` | Formats a date with `Intl.DateTimeFormat` in `locale`. |

`TranslationParams` is `Record<string, string | number>`.

### t

`t(key, params)` looks the key up in the strings for `locale`. A key missing there falls back to English. A key missing in English too returns the key itself. Both fallbacks log a warning.

`params` fills `{{name}}` placeholders in the string. When you pass `params`, a placeholder without a matching param stays in the text and a warning is logged. Without `params`, the string is returned as is.

### formatCurrency

`formatCurrency` converts the amount from minor units with the currency's number of decimals, which comes from currency data bundled with the SDK, and formats it with `Intl.NumberFormat` in `locale`. An unknown currency code is formatted with 2 decimals. If `Intl.NumberFormat` throws, the result is the number followed by the currency code, for example `10.50 EUR`.

### formatDate

`formatDate` passes `options` to `Intl.DateTimeFormat`. If formatting throws, the result is the date's ISO string.

## Usage

```tsx theme={"dark"}
import { Text } from 'react-native';
import { usePrimerCheckout, usePrimerLocalization } from '@primer-io/react-native';

export function PayLabel() {
  const { clientSession } = usePrimerCheckout();
  const { t, formatCurrency } = usePrimerLocalization();

  const amount = clientSession?.totalAmount;
  const currency = clientSession?.currencyCode;

  return (
    <Text>
      {amount != null && currency
        ? t('primer_common_button_pay_amount', { amount: formatCurrency(amount, currency) })
        : t('primer_common_button_pay')}
    </Text>
  );
}
```

For a total of `1050` in `EUR`, this renders "Pay €10.50" on a device set to English. Amounts in the [client session](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/checkout-data.md#clientsession) are in minor units, so pass them to `formatCurrency` as they are.

> [!NOTE]
>
> The string keys are internal to the SDK and are not a stable API. The SDK can change or remove keys between releases. For text you control, use the text props of the components, see [What you can change](#what-you-can-change).

## How the locale is resolved

Primer Checkout reads the device locale from `Intl.DateTimeFormat().resolvedOptions().locale` and picks the first match:

1. The device locale, if the SDK has strings for it, for example `pt-BR`.
2. Its base language, for example `de` for a device set to `de-AT`.
3. English, `en`.

### Supported locales

The SDK has strings for 57 locales:

`ar`, `az`, `bg`, `bs`, `ca`, `cs`, `da`, `de`, `el`, `en`, `es`, `es-AR`, `es-MX`, `et`, `fa`, `fi`, `fil`, `fr`, `he`, `hi`, `hr`, `hu`, `hy`, `id`, `it`, `ja`, `ka`, `kk`, `ko`, `ku`, `ky`, `lt`, `lv`, `mk`, `ms`, `nb`, `nl`, `nl-BE`, `pl`, `pt`, `pt-BR`, `ro`, `ru`, `sk`, `sl`, `sq`, `sr`, `sv`, `th`, `tr`, `uk`, `ur-PK`, `uz`, `vi`, `zh-CN`, `zh-HK`, `zh-TW`.

See [Supported locales](https://primer.io/docs/checkout/primer-checkout/configuration/localization.md) for the language names.

## What you can change

To change one piece of text, use the text props of the component, such as `label` and `placeholder` on the [card inputs](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs.md), or `title`, `subtitle`, `retryLabel` and `otherMethodLabel` on the [status screens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/status-screens.md).

## See also

> [card] [Supported locales](https://primer.io/docs/checkout/primer-checkout/configuration/localization.md)
>
> Language names for every locale

> [card] [Status screens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/status-screens.md)
>
> Screens with text props you can set

> [card] [Card inputs](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs.md)
>
> Labels and placeholders of the card fields

> [card] [Checkout data](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/checkout-data.md)
>
> Client session amounts to format


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.