Xcode .strings files

AI translation for Xcode .strings files with Lingo.dev CLI

What are Xcode .strings files?

Xcode .strings files are Apple's format for storing localized text in iOS and macOS applications. They use a simple key-value format with support for comments and special characters.

For example:

/* Basic examples */
"welcome_message" = "Hello, world!";
"login_button" = "Log In";
"error_message" = "Something went wrong";

/* Escaped characters */
"quote_example" = "She said \"Hello world!\"";
"newline_example" = "First line\nSecond line";

/* Unicode and special characters */
"unicode_example" = "Hello 世界 🌍";
"emoji" = "👋 Hello! 🎉";

What is Lingo.dev CLI?

Lingo.dev CLI is a free, open-source CLI for translating apps and content with AI. It's designed to replace traditional translation management software while integrating with existing pipelines.

To learn more, see Overview.

About this guide

This guide explains how to translate Xcode .strings files with Lingo.dev CLI.

You'll learn how to:

  • Create a project from scratch
  • Configure a translation pipeline
  • Generate translations with AI

Prerequisites

To use Lingo.dev CLI, ensure that Node.js v18+ is installed:

❯ node -v
v22.17.0

Step 1. Set up a project

In your project's directory, create an i18n.json file:

{
  "$schema": "https://lingo.dev/schema/i18n.json",
  "version": "1.10",
  "locale": {
    "source": "en",
    "targets": ["es"]
  },
  "buckets": {}
}

This file defines the behavior of the translation pipeline, including what languages to translate between and where the localizable content exists on the file system.

To learn more about the available properties, see i18n.json.

Step 2. Configure the source locale

The source locale is the original language and region that your content was written in. To configure the source locale, set the locale.source property in the i18n.json file:

{
  "$schema": "https://lingo.dev/schema/i18n.json",
  "version": "1.10",
  "locale": {
    "source": "en",
    "targets": ["es"]
  },
  "buckets": {}
}

The source locale must be provided as a BCP 47 language tag.

For the complete list of the locale codes that Lingo.dev CLI supports, see Supported locale codes.

Step 3. Configure the target locales

The target locales are the languages and regions you want to translate your content into. To configure the target locales, set the locale.targets property in the i18n.json file:

{
  "$schema": "https://lingo.dev/schema/i18n.json",
  "version": "1.10",
  "locale": {
    "source": "en",
    "targets": ["es"]
  },
  "buckets": {}
}

Step 4. Create the source content

If you haven't already, create one or more Xcode .strings files that contain the content to be translated. These files must be located at a path that includes the source locale somewhere in the path (e.g., as a directory name like en/ or as part of the filename like messages.en.strings).

Step 5. Create a bucket

  1. In the i18n.json file, add a "xcode-strings" object to the buckets object:

    {
      "$schema": "https://lingo.dev/schema/i18n.json",
      "version": "1.10",
      "locale": {
        "source": "en",
        "targets": ["es"]
      },
      "buckets": {
        "xcode-strings": {}
      }
    }
    
  2. In the "xcode-strings" object, define an array of one or more include patterns:

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

    These patterns define which files to translate.

    The patterns themselves:

    • must contain [locale] as a placeholder for the configured locale
    • can point to file paths (e.g., "[locale]/Localizable.strings")
    • can use asterisks as wildcard placeholders (e.g., "[locale]/*.strings")

    Recursive glob patterns (e.g., **/*.strings) are not supported.

Step 6. Configure an LLM

Lingo.dev CLI uses large language models (LLMs) to translate content with AI. To use one of these models, you need an API key from a supported provider.

To get up and running as quickly as possible, we recommend using Lingo.dev Engine — our own, hosted platform that offers 10,000 tokens of free, monthly usage:

  1. Sign up for a Lingo.dev account.

  2. Run the following command:

    npx lingo.dev@latest login
    

    This will open your default browser and ask you to authenticte.

  3. Follow the prompts.

Step 7. Generate the translations

In the directory that contains the i18n.json file, run the following command:

npx lingo.dev@latest run

This command:

  1. Reads the i18n.json file.
  2. Finds the files that need to be translated.
  3. Extracts the translatable content from the files.
  4. Uses the configured LLM to translate the extracted content.
  5. Writes the translated content back to the file system.

The first time translations are generated, an i18n.lock file is created. This file keeps track of what content has been translated, preventing unnecessary retranslations on subsequent runs.

Example

en/example.strings

/* Basic examples */
"welcome_message" = "Hello, world!";
"login_button" = "Log In";
"error_message" = "Something went wrong";

"user_profile_title" = "User Profile";

/* Escaped characters */
"quote_example" = "She said \"Hello world!\"";
"newline_example" = "First line\nSecond line";

/* Unicode and special characters */
"unicode_example" = "Hello 世界 🌍";
"emoji" = "👋 Hello! 🎉";
"accents" = "Café, naïve, résumé";

/* Valid entries */
"settings_title" = "Settings";
"save_button" = "Save";

es/example.strings

/* Basic examples */
"welcome_message" = "¡Hola, mundo!";
"login_button" = "Iniciar Sesión";
"error_message" = "Algo salió mal";

"user_profile_title" = "Perfil de Usuario";

/* Escaped characters */
"quote_example" = "Ella dijo \"Hola mundo!\"";
"newline_example" = "Primera línea\nSegunda línea";

/* Unicode and special characters */
"unicode_example" = "Hola 世界 🌍";
"emoji" = "👋 ¡Hola! 🎉";
"accents" = "Café, naïve, résumé";

/* Valid entries */
"settings_title" = "Configuración";
"save_button" = "Guardar";

i18n.json

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

i18n.lock

version: 1
checksums:
  c0001027bc43a90fe59344ea57847e7a:
    welcome_message: 0468579ef2fbc83c9d520c2f2f1c5059
    login_button: 0029e5a35676c0051e761fcd046ef9ee
    error_message: a3cd2f01c073f1f5ff436d4b132d39cf
    user_profile_title: bee775ff7216747b2111e93cefa57ddc
    quote_example: c519c83fe2629c0e9a6e7a14f64b6317
    newline_example: ae9313a2231a16f17e2367a4e5b322ee
    backslash_example: acf69a7273edf9f932f66027f699bbbe
    mixed_escapes: 9285b600baf307f7c060e20dc5778fad
    tab_example: 1451b8323511459dac68316a2594bb82
    multiline_literal: a4c5d1c388a06e29d96833e4d2f14a26
    multiline_mixed: f5d741606567d78281bc455074eb8f6c
    multiline_with_quotes: c82ec05ec488644808917b9c958da8cc
    after_comment: b7c19db10622cb67d4dd28270e85a428
    after_multiline_comment: 759d0ffce80451996a5a45b33a0870cc
    long_value: a54e8485e571c671e35865ba72cbcaf5
    unicode_example: 2de42b1aef6d20b314928b9c2554759d
    emoji: 1b387c2b5ce6c2cd608081ebcb5e6a94
    accents: 8c054e17f9b960d9317ca110a6fedf8c
    spaces_only: 8af60e2ee58a2e1e42071066e9c225da
    many_quotes: e2ff57b8058ab2c03c5b07cf901a7a48
    missing_semicolon: b2b5f0c3f552a348188de51bd4fcf511
    settings_title: 8df6777277469c1fd88cc18dde2f1cc3
    save_button: f7a2929f33bc420195e59ac5a8bcd454