@solidnative-dev/localization
Validated startup locale and effective native layout direction (ltr / rtl) for Solid Native applications. Reads React Native's I18nManager TurboModule directly without evaluating I18nManager.js.
Installation#
sh
pnpm add @solidnative-dev/localizationNo extra native dependency is required—uses React Native's built-in I18nManager TurboModule.
Usage#
ts
import { getReactNativeLocalizationSnapshot } from "@solidnative-dev/localization/react-native";
const localization = getReactNativeLocalizationSnapshot();
// { localeTag: "de-CH", layoutDirection: "ltr", ... }Entrypoints#
| Import | Key exports |
|---|---|
@solidnative-dev/localization | readLocalizationSnapshot, LocalizationSnapshot, NativeLayoutDirection, LocalizationAdapter, LOCALIZATION_MAX_LOCALE_TAG_LENGTH (128) |
@solidnative-dev/localization/react-native | getReactNativeLocalizationSnapshot |
Behavior & platform notes#
- Startup snapshot by design: Android and iOS apply locale and RTL layout direction at process/activity startup and require a restart to change. This package intentionally returns a frozen snapshot rather than exposing
forceRTL/allowRTLmutations that cannot update a running Fabric surface. - Locale normalization: Android's underscore-separated locale identifiers are normalized to BCP-47 hyphenated tags. Because React Native's iOS
I18nManageromits the locale string, iOS reads the HermesIntl.DateTimeFormatlocale while keeping nativeisRTLand style-swap flags. - iOS
Info.plistrequirement: Shipping iOS apps must declare supported localizations (including at least one RTL localization viaCFBundleLocalizationsor localized resources) before natural RTL activates. - Android Activity alignment:
@solidnative-dev/fabric-host'sSolidNativeSurfacesynchronizes React Native's package-scopedI18nUtilpreferences from the Activity's effective locale before surface creation so the Activity, snapshot, and Yoga layout direction agree.