Skip to content

Commit 6373fe9

Browse files
committed
feat: initial iOS xcstrings localization example
0 parents  commit 6373fe9

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

.github/workflows/translate.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Translate
2+
on:
3+
push:
4+
branches: [main]
5+
permissions:
6+
contents: write
7+
jobs:
8+
translate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Lingo.dev
13+
uses: lingodotdev/lingo.dev@main
14+
with:
15+
api-key: ${{ secrets.LINGODOTDEV_API_KEY }}

MyApp/Localizable.xcstrings

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
"sourceLanguage": "en",
3+
"version": "1.0",
4+
"strings": {
5+
"welcome_title": {
6+
"comment": "Main screen title shown after login",
7+
"extractionState": "manual",
8+
"localizations": {
9+
"en": {
10+
"stringUnit": {
11+
"state": "translated",
12+
"value": "Welcome back!"
13+
}
14+
}
15+
}
16+
},
17+
"settings_title": {
18+
"comment": "Navigation bar title for settings screen",
19+
"extractionState": "manual",
20+
"localizations": {
21+
"en": {
22+
"stringUnit": {
23+
"state": "translated",
24+
"value": "Settings"
25+
}
26+
}
27+
}
28+
},
29+
"logout_button": {
30+
"comment": "Button label in settings screen - triggers sign out",
31+
"extractionState": "manual",
32+
"localizations": {
33+
"en": {
34+
"stringUnit": {
35+
"state": "translated",
36+
"value": "Log out"
37+
}
38+
}
39+
}
40+
},
41+
"items_count": {
42+
"comment": "Shown below a list of items, e.g. '3 items'",
43+
"extractionState": "manual",
44+
"localizations": {
45+
"en": {
46+
"variations": {
47+
"plural": {
48+
"one": {
49+
"stringUnit": {
50+
"state": "translated",
51+
"value": "%lld item"
52+
}
53+
},
54+
"other": {
55+
"stringUnit": {
56+
"state": "translated",
57+
"value": "%lld items"
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}
64+
},
65+
"search_placeholder": {
66+
"comment": "Placeholder text in the search bar",
67+
"extractionState": "manual",
68+
"localizations": {
69+
"en": {
70+
"stringUnit": {
71+
"state": "translated",
72+
"value": "Search..."
73+
}
74+
}
75+
}
76+
},
77+
"empty_state_title": {
78+
"comment": "Title shown when no items exist yet",
79+
"extractionState": "manual",
80+
"localizations": {
81+
"en": {
82+
"stringUnit": {
83+
"state": "translated",
84+
"value": "No items yet"
85+
}
86+
}
87+
}
88+
},
89+
"empty_state_description": {
90+
"comment": "Description below the empty state title, encouraging the user to create their first item",
91+
"extractionState": "manual",
92+
"localizations": {
93+
"en": {
94+
"stringUnit": {
95+
"state": "translated",
96+
"value": "Tap the + button to create your first item."
97+
}
98+
}
99+
}
100+
},
101+
"delete_confirmation": {
102+
"comment": "Alert message asking the user to confirm deletion of an item",
103+
"extractionState": "manual",
104+
"localizations": {
105+
"en": {
106+
"stringUnit": {
107+
"state": "translated",
108+
"value": "Are you sure you want to delete this item? This action cannot be undone."
109+
}
110+
}
111+
}
112+
}
113+
}
114+
}

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# iOS App Localization Example
2+
3+
Demonstrates automated localization for iOS Xcode String Catalogs (`.xcstrings`) using [Lingo.dev](https://lingo.dev) CLI and GitHub Actions.
4+
5+
> **Full walkthrough:** [lingo.dev/en/guides/ios-app-localization](https://lingo.dev/en/guides/ios-app-localization)
6+
7+
## What's inside
8+
9+
- `MyApp/Localizable.xcstrings` - source strings (English)
10+
- `i18n.json` - Lingo.dev CLI configuration
11+
- `.github/workflows/translate.yml` - GitHub Actions workflow
12+
13+
## Quick start
14+
15+
1. Fork this repo
16+
2. Add `LINGODOTDEV_API_KEY` to **Settings > Secrets and variables > Actions**
17+
3. Push a change to source strings in `Localizable.xcstrings`
18+
4. Translations appear automatically via commit to main
19+
20+
## How it works
21+
22+
The Lingo.dev CLI reads the String Catalog, identifies new or changed entries using a lockfile, translates the delta through a configured localization engine, and writes all target languages back into the same `.xcstrings` file. The GitHub Actions workflow runs this on every push to main.
23+
24+
## Locales
25+
26+
- **Source:** `en`
27+
- **Targets:** `es`, `fr`, `de`, `ja`
28+
29+
## Links
30+
31+
- [Guide: iOS App Localization with Xcode String Catalogs](https://lingo.dev/en/guides/ios-app-localization)
32+
- [Lingo.dev CLI docs](https://lingo.dev/en/docs/cli)
33+
- [GitHub Actions integration](https://lingo.dev/en/docs/integrations/github)
34+
- [Create a free account](https://lingo.dev)

i18n.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://lingo.dev/schema/i18n.json",
3+
"version": "1.15",
4+
"locale": {
5+
"source": "en",
6+
"targets": ["es", "fr", "de", "ja"]
7+
},
8+
"buckets": {
9+
"xcode-xcstrings": {
10+
"include": ["MyApp/Localizable.xcstrings"]
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)