Commit 7380b77
Albert
feat(i18n): add English localization with in-app language picker
The app shipped with Chinese strings hard-coded in SwiftUI views.
Because SwiftUI treats Text("…") / Button("…") / .help("…") as
LocalizedStringKey lookups, all that's needed for full English
support is a string catalog — no code rewrite of the views.
Changes:
- Resources/Localizable.xcstrings: Xcode String Catalog with the
165 unique UI strings (162 extracted from views + 3 new ones
for the picker itself). Source language is zh-Hans; each entry
carries a vetted English translation.
- project.yml: declare developmentLanguage zh-Hans and
KNOWN_REGIONS "en zh-Hans Base" so the build pipeline compiles
the catalog into per-locale .lproj/Localizable.strings.
- SettingsService.PreferredLanguage enum (system / zh-Hans / en),
persisted to UserDefaults at key fd.preferredLanguage.
- SettingsView: new "语言 / Language" picker bound to the enum.
- FreeDisplayApp: applies the resolved Locale via
.environment(\.locale, ...) on the MenuBarView root so SwiftUI
re-renders with the chosen language without an app restart.
Verified with xcodebuild Release: BUILD SUCCEEDED, only pre-existing
Swift 6 concurrency warnings (no new errors).1 parent c4bd222 commit 7380b77
6 files changed
Lines changed: 2896 additions & 2 deletions
File tree
- FreeDisplay.xcodeproj
- FreeDisplay
- App
- Resources
- Services
- Views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| 196 | + | |
194 | 197 | | |
195 | 198 | | |
196 | 199 | | |
| |||
254 | 257 | | |
255 | 258 | | |
256 | 259 | | |
257 | | - | |
258 | | - | |
| 260 | + | |
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| 265 | + | |
263 | 266 | | |
264 | 267 | | |
265 | 268 | | |
266 | 269 | | |
| 270 | + | |
267 | 271 | | |
268 | 272 | | |
269 | 273 | | |
| |||
279 | 283 | | |
280 | 284 | | |
281 | 285 | | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| |||
406 | 411 | | |
407 | 412 | | |
408 | 413 | | |
| 414 | + | |
409 | 415 | | |
410 | 416 | | |
411 | 417 | | |
| |||
433 | 439 | | |
434 | 440 | | |
435 | 441 | | |
| 442 | + | |
436 | 443 | | |
437 | 444 | | |
438 | 445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
0 commit comments