Mobile App Localization for iOS Developers

Want to make your iOS app speak every language? Localization doesn’t have to be painful. With Humanicer’s API, you can automate translations whilst keeping your Xcode project perfectly structured.

Why Localization Matters

Going global means adapting your app for different languages and regions. But manually managing Localizable.strings and InfoPlist.strings files is tedious. That’s where Humanicer comes in—it handles translations whilst preserving your Xcode file formats.

Localizing InfoPlist.strings

Your app’s metadata needs localization too. Here’s how to translate InfoPlist.xcstrings (Xcode 15+’s newer format that replaces the traditional .strings files):

Key Tip: To localize strings in your Info.plist file (like app name or permission descriptions), you’ll need to:

  1. Create InfoPlist.strings (or .xcstrings) files in your language directories (e.g., fr.lproj)
  2. Add entries like: "CFBundleDisplayName" = "Mon App";
  3. Reference these keys in your actual Info.plist file

For a complete guide, see: How to localize a string inside the iOS info.plist file

curl -X POST "https://humanicer.com/v1/localize" \
--header 'Content-Type: application/json' \
--header 'X-API-Key: your_api_key' \
--data '{
    "text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xcstrings\n    format=\"1\"\n    developmentRegion=\"en\"\n    type=\"localizable\"\n    filename=\"Localizable\">\n    <dict>\n        <key>HELLO_WORLD</key>\n        <dict>\n            <key>comment</key>\n            <string>A friendly greeting shown to users</string>\n            <key>translation</key>\n            <string>Hello, World!</string>\n        </dict>\n        <key>WELCOME_MESSAGE</key>\n        <dict>\n            <key>comment</key>\n            <string>Message to welcome users upon app launch</string>\n            <key>translation</key>\n            <string>Welcome to our app!</string>\n        </dict>\n    </dict>\n</xcstrings>",
    "target_platform": "mobile",
    "target_language": "fr"
}'

You’ll get back properly escaped .strings content:

{
  "processing_time_ms":6253,
  "remaining_uses":53,
  "reset_time":"2025-05-01T00:00:00Z",
  "result":{
    "character_count":524,
    "language":"fr",
    "localized_text":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xcstrings format=\"1\" developmentRegion=\"fr\" type=\"localizable\" filename=\"Localizable\">\n    <dict>\n        <key>HELLO_WORLD</key>\n        <dict>\n            <key>comment</key>\n            <string>Une salutation amicale pour l'utilisateur</string>\n            <key>translation</key>\n            <string>Bonjour tout le monde !</string>\n        </dict>\n        <key>WELCOME_MESSAGE</key>\n        <dict>\n            <key>comment</key>\n            <string>Message de bienvenue au lancement de l'appli</string>\n            <key>translation</key>\n            <string>Découvrez notre appli !</string>\n        </dict>\n    </dict>\n</xcstrings>",
    "original_text":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xcstrings format=\"1\" developmentRegion=\"en\" type=\"localizable\" filename=\"Localizable\">\n    <dict>\n        <key>HELLO_WORLD</key>\n        <dict>\n            <key>comment</key>\n            <string>A friendly greeting shown to users</string>\n            <key>translation</key>\n            <string>Hello, World!</string>\n        </dict>\n        <key>WELCOME_MESSAGE</key>\n        <dict>\n            <key>comment</key>\n            <string>Message to welcome users upon app launch</string>\n            <key>translation</key>\n            <string>Welcome to our app!</string>\n        </dict>\n    </dict>\n</xcstrings>",
    "platform":"mobile",
    "platform_metrics":{
      "compliance_checks":true,
      "platform_fit_score":0.7,
      "readability_score":-0.31319571428571436
    },
    "word_count":42
  }
}%

The API returns perfectly formatted .xcstrings files ready to drop into your Xcode project. Whilst we show both formats here for backward compatibility, the .xcstrings format is recommended for new projects as it provides better tooling support in Xcode 15+.

Translating Localizable.strings

For your app’s UI strings, the process is just as simple (using the traditional .strings format which remains fully supported):

curl -X POST "https://humanicer.com/v1/localize" \
--header 'Content-Type: application/json' \
--header 'X-API-Key: your_api_key' \
--data '{
    "text": "Hello, World!\nWelcome to our app!",
    "target_platform": "mobile",
    "target_language": "fr"
}'

You’ll get back properly escaped .strings content:

{
    "processing_time_ms":5948,
    "remaining_uses":54,
    "reset_time":"2025-05-01T00:00:00Z",
    "result":{
        "character_count":38,
        "language":"fr",
        "localized_text":"Bonjour, Monde! Explore notre app!",
        "original_text":"Hello, World!\nWelcome to our app!",
        "platform":"mobile",
        "platform_metrics":{
            "compliance_checks":true,
            "platform_fit_score":0.8,
            "readability_score":0.9451107142857142
        },
        "word_count":7
    }
}% 

Automate the Localization Process

To automate the localization process, add this Xcode build phase script:

  1. Export all .strings or .xcstrings files from your iOS project
  2. Process them through Humanicer’s API with your target languages
  3. Import the translated files back into Xcode

Example 1: Single Localization (English to French)

The script reads an English .xcstrings or .strings file, sends its content to Humanicer’s API for French translation, and then writes the localized result to a new file.

import requests
import json

# Configuration
API_KEY = "your_api_key"
API_URL = "https://humanicer.com/v1/localize"
TARGET_LANGUAGE = "fr"
INPUT_FILE = "Localizable_en.xcstrings"  # Input file in English
OUTPUT_FILE = "Localizable_fr.xcstrings"  # Output file in French

def translate_file(content, target_language):
    headers = {
        'Content-Type': 'application/json',
        'X-API-Key': API_KEY
    }
    data = {
        "text": content,
        "target_platform": "mobile",
        "target_language": target_language
    }
    response = requests.post(API_URL, headers=headers, data=json.dumps(data))
    response.raise_for_status()
    result_json = response.json()
    # Extract the localized text from the response
    localized_text = result_json["result"]["localized_text"]
    return localized_text

def main():
    # Read the source file
    with open(INPUT_FILE, "r", encoding="utf-8") as f:
        original_content = f.read()
    
    try:
        # Translate the content to French
        localized_content = translate_file(original_content, TARGET_LANGUAGE)
        
        # Write the localized content back to a new file
        with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
            f.write(localized_content)
        
        print(f"Localization complete. Output written to {OUTPUT_FILE}")
    except Exception as e:
        print("Error during localization:", e)

if __name__ == "__main__":
    main()

Example 2: Batch Localization (English to Multiple Languages)

The script reads the English file once and then sends translation requests for both French and Spanish. It writes outputs to separate files.

import requests
import json

# Configuration
API_KEY = "your_api_key"
API_URL = "https://humanicer.com/v1/localize"
TARGET_LANGUAGES = {
    "fr": "Localizable_fr.xcstrings",  # French output file
    "es": "Localizable_es.xcstrings"   # Spanish output file
}
INPUT_FILE = "Localizable_en.xcstrings"  # Input file in English

def translate_content(content, target_language):
    headers = {
        'Content-Type': 'application/json',
        'X-API-Key': API_KEY
    }
    data = {
        "text": content,
        "target_platform": "mobile",
        "target_language": target_language
    }
    response = requests.post(API_URL, headers=headers, data=json.dumps(data))
    response.raise_for_status()
    result_json = response.json()
    localized_text = result_json["result"]["localized_text"]
    return localized_text

def main():
    # Read the source file once
    with open(INPUT_FILE, "r", encoding="utf-8") as f:
        original_content = f.read()
    
    for lang, output_file in TARGET_LANGUAGES.items():
        try:
            print(f"Translating to {lang}...")
            localized_content = translate_content(original_content, lang)
            with open(output_file, "w", encoding="utf-8") as f:
                f.write(localized_content)
            print(f"Output written to {output_file}")
        except Exception as e:
            print(f"Error while translating to {lang}:", e)

if __name__ == "__main__":
    main()

These examples demonstrate how you can integrate Humanicer’s API into your development workflow. You can integrate these scripts into your build process, CI/CD pipeline, or even as git hooks to automatically update your localization files. Don’t forget to adjust the file paths, API key, and error handling as needed for your project.

Best Practices

  1. Keep comments: The API preserves your translation comments
  2. Batch process: Translate all languages at once
  3. Version control: The output matches Xcode’s expected format
  4. Quality checks: Humanicer scores translations for mobile app suitability

Getting Started

  1. Sign up at Humanicer for your API key
  2. Export your existing .strings or .xcstrings files
  3. Process them through the API
  4. Import the localized versions back into Xcode
// In your code, just use NSLocalizedString as usual
let greeting = NSLocalizedString("HELLO", comment: "Welcome greeting")

Localization just got 10x easier. Focus on building great features whilst Humanicer handles the translations. Your global users will thank you.