Skip to content

Commit 8a6ca94

Browse files
committed
Greatly simplify and streamline README contents
1 parent eded215 commit 8a6ca94

File tree

1 file changed

+38
-85
lines changed

1 file changed

+38
-85
lines changed

README.md

Lines changed: 38 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,122 +2,75 @@
22

33
# TranslateKit SDK
44

5-
The TranslateKit SDK is a Swift package that streamlines the localization workflow in Xcode by providing:
5+
What SF Symbols is for Icons, TranslateKit is for Text!
66

7-
1. **Common Platform-Consistent Translations**: An enum with a rich set of consistently localized texts covering a large variety of typical app content - no need to localize everything yourself!
8-
2. **Semantic Key Generation**: A Swift macro that automatically generates meaningful translation keys based on code context, while leveraging Xcode's String Catalogs.
7+
Eliminate localization overhead in your Swift apps with 1000+ pre-localized strings and semantic key generation. Make app localization simple, accurate, and delightful.
98

10-
## Features
9+
## Key Features
1110

12-
### Common Translations
13-
14-
TranslateKit provides over 1,000 strings in four categories, already localized to all ~40 languages supported by Apple platforms:
15-
16-
- **Actions** (`TK.Action`): Interactive UI elements (e.g. "Done", "Add", "Cancel")
17-
- **Labels** (`TK.Label`): Non-interactive text that describes UI elements like (e.g. "Settings", "Yes", "Link")
18-
- **Placeholders** (`TK.Placeholder`): Temporary text while loading or waiting for user input (e.g. "Enter email…", "Loading…", "e.g. [email protected]")
19-
- **Messages** (`TK.Message`): Full sentences for user communication (e.g. "Are you sure?", "Please try again.")
20-
21-
Since these strings are pre-localized, using them won't add any entries to your String Catalog. Just use them directly:
11+
### 1. Pre-localized Common Strings
12+
Access 1,000+ ready-to-use strings in ~40 Apple platform languages across four categories. Since these are pre-localized, they won't add entries to your String Catalog – just use them directly:
2213

2314
```swift
24-
Button(TK.Action.save) { // "Save" in English, "Sichern" in German, etc.
25-
saveData()
26-
}
15+
// Actions: Interactive UI elements
16+
Button(TK.Action.save) { saveData() } // "Save" → "Sichern" (German)
2717

28-
if error {
29-
Text(TK.Message.anErrorOccurred) // "An Error Occurred" / "Ein Fehler ist aufgetreten"
30-
}
18+
// Labels: Non-interactive text
19+
Label(TK.Label.notifications, systemImage: "bell") // "Notifications" → "Benachrichtigungen"
3120

32-
Label(TK.Label.notifications, systemImage: "bell") // "Notifications" / "Benachrichtigungen"
21+
// Placeholders: Temporary text
22+
TextField(TK.Label.firstName, text: $firstName, // "First Name" → "Vorname"
23+
prompt: TK.Placeholder.firstNameExample) // "e.g. Jane" → "z.B. Erika"
3324

34-
TextField(
35-
TK.Label.firstName, // "First Name" / "Vorname"
36-
text: $firstName,
37-
prompt: TK.Placeholder.firstNameExample // "e.g. Jane" / "z.B. Erika"
38-
)
25+
// Messages: Full sentences
26+
Text(TK.Message.anErrorOccurred) // "An Error Occurred" → "Ein Fehler ist aufgetreten"
3927
```
4028

41-
Discovering the right translations during programming is easy thanks to autocompletion:
42-
1. Just type `TK.` to get the list of the 4 supported categories and select one, e.g. `Action` or `Label`
43-
2. Now enter what you're looking for, for example type `acc` to get fuzzy-matched results like `accept`, `grantAccess`, and `addAccount`
44-
3. Note that before you select an entry, you can see both the English translation and a usage hint in the documentation popover
29+
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:
4530

4631
![Showcasing Autocompletion in Xcode](https://github.com/FlineDev/TranslateKit/blob/main/Images/Autocomplete.jpeg?raw=true)
4732

48-
Super convenient, right?
49-
50-
### Smart Key Generation with `#tk` Macro
51-
52-
For your own translations, the TranslateKit SDK provides the `#tk` macro that automatically generates semantic keys based on the context:
33+
### 2. Smart Key Generation
34+
The `#tk` macro eliminates the tedious work of manual key management by automatically generating semantic keys based on code context:
5335

5436
```swift
5537
struct SettingsView: View {
56-
let documentName: String
57-
58-
var body: some View {
59-
Button(#tk("Save Changes")) { // Key: SettingsView.Body.saveChanges
60-
handleSave()
61-
}
62-
63-
// Short 'c' parameter for a comment providing additional context (when needed)
64-
Text(#tk("Save changes to \(documentName)?", c: "e.g. 'Save changes to MyNumbers.csv'"))
65-
}
66-
}
67-
```
68-
69-
The macro expands the above two `#tk` macros to proper auto-extractable String Catalog code:
70-
71-
```swift
72-
struct SettingsView: View {
73-
let documentName: String
38+
let documentName: String
7439

75-
var body: some View {
76-
Button(
77-
String(
78-
localized: "SettingsView.Body.saveChanges",
79-
defaultValue: "Save Changes"
80-
)
81-
) {
82-
handleSave()
83-
}
40+
var body: some View {
41+
// Generates key: SettingsView.Body.saveChanges
42+
Button(#tk("Save Changes")) { handleSave() }
8443

85-
Text(
86-
String(
87-
localized: "SettingsView.Body.saveChangesTo",
88-
defaultValue: "Save changes to \(documentName)?",
89-
comment: "e.g. 'Save changes to Talk.keynote'"
90-
)
91-
)
92-
}
44+
// Add context with 'c' parameter to help translators
45+
Text(#tk("Save changes to \(documentName)?",
46+
c: "e.g. 'Save changes to MyNumbers.csv'"))
47+
}
9348
}
9449
```
9550

96-
Note that String Catalogs support a separate "key" AND separate "source" translation, just like Strings files did back in the day. But due to how extraction is happening from baked-in SwiftUI views, nowadays most developers end up having the key and source translation to be equal. To do this, you'd have to write the verbose `String(localized:defaultValue:comment:)` function you see in the expanded code above. And every single time, you'd need to type the key manually, adding a lot of extra thinking time and work load on the developer.
51+
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:
9752

9853
![Macro Expansion in Xcode](https://github.com/FlineDev/TranslateKit/blob/main/Images/MacroExpansion.jpeg?raw=true)
9954

100-
That's what the `#tk` macro solves, as all you need to do is to wrap your source translation String literal in `#tk("...")` and the macro takes care of giving your translation key a proper semantic name like `SettingsView.Body.saveChanges`. This added context can be helpful for both human translators and AI translation tools (like the [TranslateKit Mac app](https://translatekit.app)) to understan the context better and provide more accurate contextual translations.
55+
These semantic keys help group related translations and provide crucial context to translators and translation tools (like the [TranslateKit Mac app](https://translatekit.app)), leading to more accurate translations while making your localization files easier to maintain.
10156

102-
## Using in Swift Packages
57+
## Swift Package Usage
10358

104-
If you want to use TranslateKit in a Swift package or modularized app, use `#tkm` instead of `#tk`. It works exactly the same but uses `Bundle.module` to reference the correct String Catalog file in the expanded code. Full instructions to localize a Swift package:
59+
For Swift packages, use `#tkm` instead of `#tk` to reference the correct String Catalog file:
10560

106-
1. Add `defaultLocalization` to your package manifest:
61+
1. Add defaultLocalization to your manifest:
10762
```swift
10863
.target(
109-
name: "MyModule",
110-
defaultLocalization: "en",
111-
// ...
64+
name: "MyModule",
65+
defaultLocalization: "en"
11266
)
11367
```
11468

115-
2. Add a String Catalog (`Localizable.xcstrings`) to your module
69+
2. Add `Localizable.xcstrings` to your module
11670

117-
3. Use the `#tkm` macro instead of `#tk`:
71+
3. Use the `#tkm` macro:
11872
```swift
11973
Text(#tkm("Last seen %@", c: "Time when user was last active"))
120-
// Expands to use 'bundle: .module' rather than the main bundle
12174
```
12275

12376
## Contributing
@@ -149,11 +102,11 @@ I created this library for my own Indie apps (download & rate them to thank me!)
149102
<strong>TranslateKit: App Localizer</strong>
150103
</a>
151104
<br />
152-
Indie-focused app localization with unmatched accuracy. Fast & easy: AI & proofreading, 125+ languages, market insights. Budget-friendly, free to try.
105+
AI-powered app localization with unmatched accuracy. Fast & easy: AI & proofreading, 125+ languages, market insights. Budget-friendly, free to try.
153106
</td>
154107
<td>Mac</td>
155108
</tr>
156-
<tr>
109+
<tr>
157110
<td>
158111
<a href="https://apps.apple.com/app/apple-store/id6502914189?pt=549314&ct=github.com&mt=8">
159112
<img src="https://raw.githubusercontent.com/FlineDev/HandySwiftUI/main/Images/Apps/FreemiumKit.webp" width="64" />
@@ -164,7 +117,7 @@ I created this library for my own Indie apps (download & rate them to thank me!)
164117
<strong>FreemiumKit: In-App Purchases</strong>
165118
</a>
166119
<br />
167-
Simple In-App Purchases and Subscriptions for Apple Platforms: Automation, Paywalls, A/B Testing, Live Notifications, PPP, and more.
120+
Simple In-App Purchases and Subscriptions: Automation, Paywalls, A/B Testing, Live Notifications, PPP, and more.
168121
</td>
169122
<td>iPhone, iPad, Mac, Vision</td>
170123
</tr>
@@ -194,7 +147,7 @@ I created this library for my own Indie apps (download & rate them to thank me!)
194147
<strong>FreelanceKit: Time Tracking</strong>
195148
</a>
196149
<br />
197-
Simple & affordable time tracking with a native experience for all devices. iCloud sync & CSV export included.
150+
Simple & affordable time tracking with a native experience for all devices. iCloud sync & CSV export included.
198151
</td>
199152
<td>iPhone, iPad, Mac, Vision</td>
200153
</tr>

0 commit comments

Comments
 (0)