iOS

AI translation for iOS apps with Lingo.dev CLI

What is iOS?

iOS is Apple's mobile operating system that powers iPhone and iPad devices.

What is Lingo.dev CLI?

Lingo.dev is an AI-powered translation platform. The Lingo.dev CLI reads source files, sends translatable content to large language models, and writes translated files back to your project.

About this guide

This guide explains how to set up Lingo.dev CLI in an iOS app. You'll learn how to create a String Catalog in Xcode, configure a translation pipeline, and test the results in the iOS simulator.

Step 1. Create a String Catalog

  1. Open your project in Xcode.
  2. Navigate to File > New > File from Template.
  3. Select String Catalog from the template options.
  4. Click Next.
  5. Click Create.

By default, the name of the String Catalog file is Localizable.xcstrings.

Step 2. Create localizable strings

  1. Open the String Catalog file.
  2. Select the source locale (e.g., English).
  3. Click the + icon to add a new string.
  4. Enter a key, such as "welcome".
  5. Enter a value, such as "Hello, world".

Step 3. Configure the CLI

In the root of your Xcode project, create an i18n.json file:

{
  "$schema": "https://lingo.dev/schema/i18n.json",
  "version": 1.8,
  "locale": {
    "source": "en",
    "targets": ["es"]
  },
  "buckets": {
    "xcode-xcstrings": {
      "include": ["Localizable.xcstrings"]
    }
  }
}

This file defines:

  • the String Catalog file(s) that Lingo.dev CLI should translate
  • the languages to translate between

In this case, the configuration translates the String Catalog from English to Spanish.

To learn more, see i18n.json configuration.

Step 4. Translate the content

  1. Sign up for a Lingo.dev account.

  2. Log in to Lingo.dev via the CLI:

    npx lingo.dev@latest login
    
  3. Run the translation pipeline:

    npx lingo.dev@latest run
    

    The CLI will update your Localizable.xcstrings file with the translated content and create an i18n.lock file for keeping track of what has been translated (to prevent unnecessary retranslations).

Step 5. Use the translations

In your Swift code, reference the localized strings using their keys:

Text("welcome")

Step 6. Preview the translations

  1. Navigate to Product > Scheme > Edit Scheme.
  2. In the dialog that appears, select Run.
  3. Switch to the Options tab.
  4. From the App Language drop-down, select the language to test.
  5. Click Close.
  6. Run the app via the simulator.