Xcode String Catalogs

The String Catalog (.xcstrings) format is Apple's modern localization system, designed to streamline internationalization for iOS, macOS, watchOS, and tvOS applications. It uses a JSON-based structure that is both human-readable and optimized for development tools.

String Catalogs are intended to replace the older Apple iOS .strings and .stringsdict formats.

Format

  • The format is based on JSON.
  • The file extension is .xcstrings.
  • Placeholder information follows the Apple String Format Specifiers reference.
  • String Catalogs are multi-language files containing translation information for multiple locales within a single file.
  • The format uses variations to manage different translation contexts:
    • Plurals: Handles pluralization rules.
    • Devices: Handles device-specific strings (e.g., iPhone, iPad, Mac). LingoHub currently stores the default device variation.
    • Substitutions: Enables type-safe placeholders for dynamic variable insertion.
  • LingoHub maps the Xcode string catalog state to segment states as follows:
    • newNEW.
    • staleDRAFT.
    • needs_reviewTRANSLATED.
    • translatedAPPROVED.

LingoHints can be included in a comment attribute:

"accessibility_settings": {
  "comment": "Show accessibility settings. <lh>{\"status\": \"DRAFT\",\"qc\": {\"min\": \"3\",\"max\": \"20\"},\"labels\": [\"q3-2024\"],\"not_translatable\": false}</lh>",
  "localizations": {
    "de": {
      "stringUnit": {
        "state": "translated",
        "value": "Barrierefreiheit"
      }
    }
  }
}

Example

{
  "sourceLanguage": "en",
  "strings": {
    "photos_count": {
      "extractionState": "manual",
      "localizations": {
        "de": {
          "state": "translated",
          "variations": {
            "plural": {
              "zero": "Keine Fotos",
              "one": "Ein Foto",
              "other": "%lld Fotos"
            }
          }
        },
        "en": {
          "state": "verified",
          "variations": {
            "plural": {
              "zero": "No photos",
              "one": "One photo",
              "other": "%lld photos"
            }
          }
        }
      }
    },
    "welcome_message": {
      "extractionState": "manual",
      "localizations": {
        "de": {
          "state": "translated",
          "variations": {
            "device": {
              "ipad": "Willkommen auf deinem iPad",
              "iphone": "Willkommen auf deinem iPhone",
              "mac": "Willkommen auf deinem Mac",
              "other": "Willkommen"
            }
          }
        }
      }
    }
  },
  "version": "1.0"
}

References