TranslateKit

SF Symbols for Texts: 2000+ built-in translations in 40 languages + semantic localization key macro for Swift devs

85
0
Swift

TranslateKit SDK Logo

TranslateKit SDK

What SF Symbols is for Icons, TranslateKit is for Text!

Eliminate localization overhead in your Swift apps with 2000+ pre-localized strings and semantic key generation. Make app localization simple, accurate, and delightful.

Key Features

1. Pre-localized Common Strings

Access 2,000+ ready-to-use strings in ~40 Apple platform languages across four categories. These match the officially supported iOS system languages and utilize Apple’s own translations where available, ensuring consistency with the system UI.

Since they are pre-localized, they won’t add entries to your String Catalog – just use them directly:

// Actions: Interactive UI elements
Button(TK.Action.save) { saveData() }  // "Save" → "Sichern" (German)

// Labels: Non-interactive text
Label(TK.Label.notifications, systemImage: "bell")  // "Notifications" → "Benachrichtigungen"

// Placeholders: Temporary text
TextField(TK.Label.firstName, text: $firstName,  // "First Name" → "Vorname"
         prompt: TK.Placeholder.firstNameExample)  // "e.g. Jane" → "z.B. Erika"

// Messages: Full sentences
Text(TK.Message.anErrorOccurred)  // "An Error Occurred" → "Ein Fehler ist aufgetreten"

Discovering the right translations is effortless with autocompletion – type TK. to explore categories and fuzzy-match strings, with English previews and usage hints in the documentation popover:

Showcasing Autocompletion in Xcode

2. Smart Key Generation

The #tk macro eliminates the tedious work of manual key management by automatically generating semantic keys based on code context:

struct SettingsView: View {
  let documentName: String
    
  var body: some View {
    // Generates key: SettingsView.Body.saveChanges
    Button(#tk("Save Changes")) { handleSave() }
        
    // Add context with 'c' parameter to help translators
    Text(#tk("Save changes to \(documentName)?", 
             c: "e.g. 'Save changes to MyNumbers.csv'"))
  }
}

String Catalogs made it challenging to maintain best practices from the Strings-file era, where using semantic keys helped group related translations. The macro brings back this advantage while keeping String Catalogs’ benefits - you get semantic keys without writing verbose String(localized:defaultValue:comment:) calls:

Macro Expansion in Xcode

You can see in the image what the simple #tk macro call expands to, adding an auto-derived key. These semantic keys help group related translations and provide crucial context to translators and translation tools (like the TranslateKit Mac app), leading to more accurate translations while making your localization files easier to maintain.

Core Strings & Category-Specific Extensions

To keep TranslateKit lightweight while providing comprehensive coverage, the 2,000+ pre-localized strings are organized into two tiers:

  1. Core Strings (250+):
    Included in the base TranslateKit package, these strings are commonly used across all kinds of apps, making them universally applicable.

  2. Category-Specific Extensions (~100 per category):
    Each of the 26 App Store categories has an additional module with strings tailored to that category. For example:

    • Finance apps: import TranslateKitFinance
    • Productivity apps: import TranslateKitProductivity
    • Health & Fitness apps: import TranslateKitHealthAndFitness

    These modules also include the core strings, so you only need to import the one matching your app category.

With this modular approach, TranslateKit remains lightweight, adding only ~1MB to your app, making it suitable for any project – big or small.

Swift Package Usage

For Swift packages, use #tkm instead of #tk to reference the correct String Catalog file:

  1. Add defaultLocalization to your manifest:
let package = Package(
   name: "FormKit",
   defaultLocalization: "en",
   // ...
)
  1. Add Localizable.xcstrings to your module (right-click folder > “New File from Template…” > String Catalog)

  2. Use the #tkm macro with optional comment:

struct FormValidator {
   static func validatePassword(_ password: String) -> String? {
       guard password.count >= 8 else {
           return #tkm("Password must be at least 8 characters")
       }
       return nil
   }
}

Common reasons to localize Swift packages are that they may contain UI elements (e.g. modularized apps) or that they might provide error descriptions, which should be localized in most cases.

Contributing

Contributions – especially additions and corrections – are welcome!

Please feel free to submit a Pull Request. You don’t need to localize added entries to all languages yourself, just provide the one(s) you speak, we’ll take care of the other languages using TranslateKit. But please keep the entries sorted alphabetically when adding new ones!

For bigger changes, please open an issue first to discuss what you would like to change.

Showcase

I created this library for my own Indie apps (download & rate them to show your appreciation):

App Icon App Name & Description Supported Platforms
TranslateKit: App Localization
AI-powered app localization with unmatched accuracy. Fast & easy: AI & proofreading, 125+ languages, market insights. Budget-friendly, free to try.
Mac
FreemiumKit: In-App Purchases for Indies
Simple In-App Purchases and Subscriptions: Automation, Paywalls, A/B Testing, Live Notifications, PPP, and more.
iPhone, iPad, Mac, Vision
Pleydia Organizer: Movie & Series Renamer
Simple, fast, and smart media management for your Movie, TV Show and Anime collection.
Mac
FreelanceKit: Project Time Tracking
Simple & affordable time tracking with a native experience for all devices. iCloud sync & CSV export included.
iPhone, iPad, Mac, Vision
CrossCraft: Custom Crosswords
Create themed & personalized crosswords. Solve them yourself or share them to challenge others.
iPhone, iPad, Mac, Vision
FocusBeats: Pomodoro + Music
Deep Focus with proven Pomodoro method & select Apple Music playlists & themes. Automatically pauses music during breaks.
iPhone, iPad, Mac, Vision
Posters: Discover Movies at Home
Auto-updating & interactive posters for your home with trailers, showtimes, and links to streaming services.
Vision