MOTOSHARE ๐Ÿš—๐Ÿ๏ธ
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
๐Ÿš€ Everyone wins.

Start Your Journey with Motoshare

Mastering Localizable.xcstrings for iOS Localization

Uncategorized

Apple has always emphasized building apps that feel native to users worldwide. One powerful tool that simplifies this process is Localizable.xcstrings, introduced by Apple as a modern replacement for the older .strings files. This guide explains what Localizable.xcstrings is, its purpose, architecture, workflow, and how you can get started.


๐Ÿ” What is Localizable.xcstrings?

Localizable.xcstrings is a structured localization file format introduced by Apple in Xcode 12 and iOS 14+. It replaces traditional .strings files with a key-value JSON format, enhancing localization support with metadata, context, pluralization, and variant handling.

This format works with Xcodeโ€™s String Catalog, providing a more intuitive and scalable way to manage localized content across languages and regions.

Key Benefits Over .strings:

  • Supports contextual information for translators
  • Handles pluralization and formatting natively
  • Fully integrated into Xcodeโ€™s localization workflow
  • Reduces errors and ambiguities in translation

๐Ÿ’ก Major Use Cases of Localizable.xcstrings

1. App Localization

Translate app UI text, labels, alerts, tooltips, and other interface strings into multiple languages seamlessly.

2. Dynamic Content Presentation

Localize plural forms (e.g., 1 item vs. 2 items) using Appleโ€™s ICU-based syntax.

3. Enhanced Translator Experience

Provide context and notes for translators directly within the localization file.

4. Team Collaboration

Facilitates better coordination between developers, designers, and translators by reducing ambiguity in translations.

5. Automated Export/Import

Streamline translation workflows using Xcode or third-party tools to export .xcstrings to common translation platforms.


๐Ÿ— How Localizable.xcstrings Works (with Architecture)

๐Ÿ“ฆ Architecture Overview:

  1. Xcode Source Code & UI Strings
    • Developers annotate localizable strings using NSLocalizedString or Swift String(localized:).
  2. Localization Extraction
    • Xcode extracts these strings into a centralized .xcstrings file using a structured JSON format.
  3. String Catalog (Strings Dict)
    • The .xcstrings file stores translation keys with:
      • Base string
      • Context (optional)
      • Variants (plural, gender, etc.)
      • Comments for translators
  4. Runtime Resolution
    • At runtime, iOS selects the appropriate localized string based on the deviceโ€™s language settings.
  5. App Delivery
    • Compiled .xcstrings become part of the app bundle, loaded dynamically at runtime.

๐Ÿงฌ Sample Structure of Localizable.xcstrings

{
  "example.string": {
    "localizations": {
      "en": {
        "stringUnit": {
          "value": "Hello, World!",
          "comment": "Greeting shown on the main screen"
        }
      },
      "es": {
        "stringUnit": {
          "value": "ยกHola, Mundo!",
          "comment": "Saludo que se muestra en la pantalla principal"
        }
      }
    }
  }
}


๐Ÿ”„ Basic Workflow of Localizable.xcstrings

Step-by-Step Workflow:

  1. Define Strings in Code Use NSLocalizedString or Swiftโ€™s native String(localized:).
  2. Create .xcstrings via String Catalog In Xcode, go to File โ†’ New โ†’ File โ†’ String Catalog โ†’ Name it Localizable.
  3. Add Locales In the File Inspector, click โ€œLocalizeโ€ฆโ€ and add required languages (e.g., French, German).
  4. Edit Translations Input translations in the table-like UI or JSON structure. Add notes for translators if needed.
  5. Export/Import for Translation Export .xliff for translation and re-import once translations are complete.
  6. Build & Test Build the app and run in different locales using Xcode scheme settings or simulator.

๐Ÿš€ Step-by-Step Getting Started Guide

๐Ÿ› ๏ธ Step 1: Create a String Catalog

  1. Open Xcode โ†’ File โ†’ New โ†’ File โ†’ String Catalog
  2. Name it Localizable.xcstrings
  3. Click “Create”

๐ŸŒ Step 2: Localize Your Catalog

  1. Select the .xcstrings file in the navigator.
  2. Go to File Inspector (right panel).
  3. Click โ€œLocalizeโ€ฆโ€
  4. Choose the base language (e.g., English).
  5. Then click โ€œ+โ€ to add other languages.

โœ๏ธ Step 3: Add Translatable Strings

In code:

Text("welcome.message") // With localization

In your .xcstrings, this key (welcome.message) is added automatically if using String(localized:) in Swift.

Manually in JSON format:

{
  "welcome.message": {
    "localizations": {
      "en": {
        "stringUnit": {
          "value": "Welcome to our app!",
          "comment": "Shown on the welcome screen"
        }
      },
      "fr": {
        "stringUnit": {
          "value": "Bienvenue dans notre application!",
          "comment": "Affichรฉ ร  l'รฉcran de bienvenue"
        }
      }
    }
  }
}


๐Ÿ” Step 4: Export for Translation

  1. In Xcode: Product โ†’ Export for Localization
  2. Choose .xliff format for translators
  3. Share and later re-import using Product โ†’ Import Localizations

๐Ÿงช Step 5: Test Translations

  1. Run your app
  2. Change the device or simulator language
  3. Verify the localized content appears correctly
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x