Skip to content

Internationalization in Apple Platforms

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

In your space, open Settings → Internationalization → Languages and add es (Spanish).

  • In the article content type block schema, set the title and content fields as translatable.
  • Open 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.
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, the code defines an array with all language codes configured in the space.

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

To test the implementation, change the device language to Spanish under Settings → General → Language & 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.