Skip to content

Xcode Localization

Replexica seamlessly integrates with Xcode's localization system, making it a breeze to manage translations for your iOS, macOS, watchOS, and 🥽 visionOS apps.

This guide will show you how to set up and use Replexica with Xcode's .xcstrings format.

Setting Up

First, you'll need to set up your i18n.json config file. Here's how it should look for Xcode projects:

json
{
  "version": 1,
  "locale": {
    "source": "en",
    "targets": ["es", "fr", "de"]
  },
  "buckets": {
    "xcode": {
      "include": ["my-app/Localizable.xcstrings"]
    }
  }
}

TIP

Note that unlike other formats, we don't use the [locale] pattern in the path. That's because Xcode stores all localizations in a single .xcstrings file.

How It Works

The Localizable.xcstrings file is a JSON-based format that Xcode uses to manage localizations. It contains all your strings for all languages in one place. Replexica is smart enough to parse this format and update it correctly.

When you run Replexica, it will:

  1. Read your Localizable.xcstrings file;
  2. Identify new or changed strings;
  3. Translate them to your target languages;
  4. Update the Localizable.xcstrings file with the new translations.

Translating

To translate, simply run:

bash
npx replexica@latest i18n

Replexica will handle the rest, updating your Localizable.xcstrings file with new translations.

Available Languages

To see what languages Replexica supports:

bash
npx replexica@latest show locale sources  # List available source languages
npx replexica@latest show locale targets  # List available target languages

Use these to choose the right locale codes for your Xcode project.

Why This Approach?

Replexica's method for Xcode localization is effective because:

  1. It works directly with Xcode's native .xcstrings format, ensuring compatibility with your existing workflow;
  2. It updates all languages in one go, keeping your localization file consistent;
  3. It uses AI to understand context, providing more accurate translations than traditional methods;
  4. It's incremental, only translating what's new or changed, saving time and processing power.

Pro Tips

  1. Pluralization: Xcode uses a specific syntax for pluralization. Replexica understands and correctly translates these:

    json
    {
      "Strings": {
        "items_count": {
          "extractionState": "manual",
          "localizations": {
            "en": {
              "variations": {
                "plural": {
                  "one": {
                    "stringUnit": {
                      "state": "translated",
                      "value": "%lld item"
                    }
                  },
                  "other": {
                    "stringUnit": {
                      "state": "translated",
                      "value": "%lld items"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  2. Storyboard and XIB files: While Replexica works directly with .xcstrings files, remember that Xcode can extract strings from your Storyboard and XIB files into the Localizable.xcstrings file. This means you can manage all your UI string translations in one place.

By leveraging these features, you can maintain a robust, scalable localization setup for your Xcode projects, seamlessly integrating with your existing development workflow.