Expo

Localize Utilities

Device locale, timezone, and formatting utilities with react-native-localize fallback.

iOSAndroid

Overview

The localize module provides device locale detection, timezone, date/number/currency formatting, and measurement system detection. It requires react-native-localize for accurate native locale data and falls back to Intl APIs when unavailable.

Installation

npx expo install react-native-localize
Required Packages(1 package)
pnpm add react-native-localize

Expo Configuration

Add react-native-localize as a plugin in your app.config.ts with the locales your app supports:

{
  plugins: [
    [
      'react-native-localize',
      { locales: ['en', 'tr', 'de', 'fr'] }
    ]
  ]
}

Note: Without this plugin config, locale detection may not work correctly on iOS. The locales array determines which languages your app declares support for.

Usage

import {
  getDeviceLocale,
  getDeviceLanguage,
  getDeviceCountry,
  getDeviceTimeZone,
  uses24HourClock,
  usesMetricSystem,
  formatDate,
  formatNumber,
  formatCurrency,
} from '@/lib/docyrus/localize';

// Device info
const locale = getDeviceLocale();        // 'tr-TR'
const lang = getDeviceLanguage();        // 'tr'
const country = getDeviceCountry();      // 'TR'
const tz = getDeviceTimeZone();          // 'Europe/Istanbul'
const is24h = uses24HourClock();         // true
const metric = usesMetricSystem();       // true

// Formatting
formatDate(new Date(), { dateStyle: 'long' });   // '5 Mart 2026'
formatNumber(1234.56);                            // '1.234,56'
formatCurrency(99.99, 'TRY');                     // '₺99,99'

API Reference

Device Info

FunctionReturn TypeDescription
getDeviceLocale()stringFull locale tag (e.g., 'tr-TR'). Falls back to 'en-US'
getDeviceLanguage()stringLanguage code (e.g., 'tr'). Falls back to 'en'
getDeviceCountry()string | undefinedCountry code (e.g., 'TR')
getDeviceTimeZone()stringIANA timezone (e.g., 'Europe/Istanbul'). Falls back to 'UTC'
uses24HourClock()booleanWhether device uses 24-hour clock
usesMetricSystem()booleanWhether device uses metric system
getPreferredLocales()string[]All preferred locale tags

Formatting

FunctionParametersDescription
formatNumber(value, options?, locale?)number, Intl.NumberFormatOptions?, string?Locale-aware number formatting
formatDate(date, options?, locale?)Date, Intl.DateTimeFormatOptions?, string?Locale-aware date formatting
formatCurrency(value, currencyCode?, locale?)number, string?, string?Currency formatting (default: 'USD')
getCurrencySymbol(currencyCode)stringGet currency symbol (e.g., '₺' for 'TRY')

Fallback Behavior

FeatureWith react-native-localizeWithout (Intl fallback)
Locale detectionDevice's preferred locale listIntl.DateTimeFormat resolved locale
TimezoneRNLocalize.getTimeZone()Intl.DateTimeFormat resolved timezone
24h clockRNLocalize.uses24HourClock()AM/PM presence check
Metric systemRNLocalize.usesMetricSystem()Country code heuristic (US, LR, MM → imperial)

Compatibility

PlatformSupport
Expo GoYes
Dev ClientYes
Bare RNYes (auto-linked)

On this page