Skip to content

Internationalization in Apple

Learn how to create a basic implementation of field-level translation in an Apple project.

In your space, open SettingsInternationalizationLanguages and add es (Spanish).

  • In the article content type block schema, set the title and content fields as translatable.
  • Go to each article, select the Spanish language, and provide translated content. You can also use AI Translations.

Update ExampleApp.swift to determine the language from the device locale.

Example/ExampleApp.swift
@main
struct ExampleApp: App {
@State private var path = NavigationPath()
private static let availableLanguages = ["es"]
private let client = StoryblokClient(
library: Block.self,
accessToken: "YOUR_ACCESS_TOKEN",
version: {
#if DEBUG
.draft
#else
.published
#endif
}(),
region: .eu, // Choose the correct region from your Space.
language: Locale.preferredLanguages
.map { Locale(identifier: $0).language.languageCode?.identifier ?? $0 }
.first { availableLanguages.contains($0) }
)

First, an array with all language codes configured in the space is defined.

Next, Locale.preferredLanguages lists the user’s preferred languages in order of preference, and the first match among the languages available in the space is passed to the StoryblokClient initializer via its language parameter.

To test the implementation, change the device language to Spanish under SettingsGeneralLanguage & Region, or add a Spanish localization to your project to enable a per-app language preference. The app now renders the translated article content.

Was this page helpful?

What went wrong?

This site uses reCAPTCHA and Google's Privacy Policy (opens in a new window).Terms of Service (opens in a new window) apply.