Skip to content
better-i18n.com
Sur cette page

BetterI18n's Swift SDK brings the same translation workflow you know from the JS SDK to native iOS apps. It supports iOS 15+, macOS 12+, and watchOS 8+.

The core primitive is I18nStore — an @ObservableObject that handles fetching, caching, and locale switching reactively. Wrap your root view with I18nProvider and every SwiftUI view in the tree gets access via @EnvironmentObject.

Swift
I18nProvider(core: BetterI18n(config: I18nConfig(
    projectId: "my-org/my-app",
    defaultLocale: "en"
))) {
    ContentView()
}

Features #

  • Offline-first — Two-phase load: cached translations appear instantly, CDN refresh happens in the background.
  • Reactive — @Published locale, isLoaded, isRefreshing, and error — your UI updates automatically.
  • Locale switching — setLocale() persists the preference to storage and re-fetches translations for the new locale.
  • Widget support — AppGroup storage bridges translations to WidgetKit extensions without a network call.

Guides #

  • Setup — Install via SPM and configure I18nProvider in your app entry point.
  • API Reference — Complete reference for I18nConfig, I18nStore, BetterI18n, and Translator.
  • Widget Extension — Bridge translations to a WidgetKit extension via App Groups.

AI Tooling #

Now that you've integrated the SDK, your AI agent can check coverage, translate keys, and publish — all without leaving your editor.

  • MCP Server — Translate keys, check coverage, and publish — all from your editor via Cursor, Claude Code, or Windsurf.
  • Agent Skill — Permanent better-i18n knowledge for your AI agent — SDK patterns, CDN behavior, key conventions. No prompts needed each session.