PrismUI’s internationalization module builds on top of Apple’s standard localization infrastructure — xcstrings catalogs,Documentation Index
Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt
Use this file to discover all available pages before exploring further.
LocalizedStringKey, and Foundation formatters — while adding higher-level helpers for RTL layouts, CLDR-compliant pluralization, and multi-locale previews. Everything in this module integrates naturally with SwiftUI’s \.locale and \.layoutDirection environment values.
Registering localized strings
PrismLocalizedKey pairs a localization key with a developer comment, which tooling uses to generate Xcode’s .xcstrings catalog. Register keys at the call site using .prismLocalized(_:comment:table:):
PrismStringExporter.shared.register(_:) on view appearance. You can query the exporter to audit which keys are in use:
PrismLocalizedKey exposes a .localizedStringKey property that returns a SwiftUI LocalizedStringKey, so you can use it directly in Text initializers:
RTL layout support
Apply.prismLayoutDirection(_:) to a view to set an explicit or automatic layout direction:
PrismLayoutDirection has three cases:
| Case | Behavior |
|---|---|
.leftToRight | Forces \.layoutDirection to .leftToRight. |
.rightToLeft | Forces \.layoutDirection to .rightToLeft. |
.auto | Derives direction from \.locale — RTL for Arabic, Hebrew, Farsi, Urdu, Pashto, Sindhi, Yiddish, and Kurdish. |
Bidirectional stacks
UsePrismBidirectionalStack when you need an HStack that automatically mirrors child order in RTL layouts:
Resolving directional edges
PrismDirectionalEdge maps logical leading/trailing edges to physical screen edges for a given layout direction:
Pluralization
PrismPluralRule implements CLDR plural categories for English, Arabic, Russian, and CJK/South-East Asian languages. Use it together with PrismPluralizedText to render pluralized strings declaratively:
PrismPluralCategory cases map directly to CLDR plural rule operands:
| Case | Typical usage |
|---|---|
.zero | Arabic zero form. |
.one | Singular — English 1 item. |
.two | Arabic dual form. |
.few | Russian 2–4, Arabic 3–10. |
.many | Russian 5–20, Arabic 11–99. |
.other | General/default — English n items. |
PrismPluralRule.shared.category(for:locale:) directly to resolve the category programmatically:
Japanese, Chinese, Korean, Vietnamese, and Thai always return
.other because those languages do not distinguish plural forms.Locale-aware formatters
PrismUI ships three locale-aware formatters that wrap Foundation’s format styles.Numbers
PrismNumberFormatter formats Double values with four styles:
Dates
PrismDateFormatter formats Date values with five styles:
Relative time
PrismRelativeTimeFormatter computes the difference between two dates and returns a human-readable string:
Multi-locale preview
PrismMultiLocalePreview renders your view side by side in up to six locales, including correct RTL direction. Use it inside Xcode previews to catch layout issues before shipping.
\.locale and \.layoutDirection environment values, so Arabic and Hebrew panels automatically mirror the layout.
PrismMultiLocalePreview.defaultLocales is a static property you can read to build custom locale lists on top of the defaults without duplicating the list.