Skip to content

Commit d2c8baa

Browse files
committed
Add Localization
1 parent 7da050b commit d2c8baa

File tree

5 files changed

+219
-18
lines changed

5 files changed

+219
-18
lines changed

Demo/What's New?.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@
314314
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
315315
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
316316
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
317-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
317+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
318318
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
319319
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
320-
MACOSX_DEPLOYMENT_TARGET = 11.0;
320+
MACOSX_DEPLOYMENT_TARGET = 12.0;
321321
MARKETING_VERSION = 4.2;
322322
PRODUCT_BUNDLE_IDENTIFIER = io.startway.WhatsNew;
323323
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -349,10 +349,10 @@
349349
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
350350
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
351351
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
352-
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
352+
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
353353
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
354354
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
355-
MACOSX_DEPLOYMENT_TARGET = 11.0;
355+
MACOSX_DEPLOYMENT_TARGET = 12.0;
356356
MARKETING_VERSION = 4.2;
357357
PRODUCT_BUNDLE_IDENTIFIER = io.startway.WhatsNew;
358358
PRODUCT_NAME = "$(TARGET_NAME)";

Demo/What's New?/zh-Hant.lproj/data.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
[
2+
{
3+
"version": "4.2",
4+
"subVersion": "4.2.0",
5+
"new": [
6+
{
7+
"icon": "hammer",
8+
"title": "小型",
9+
"subtitle": "更新",
10+
"body": "一些錯誤修正和UI更新"
11+
},
12+
{
13+
"icon": "macpro.gen3.server",
14+
"title": "無服務器",
15+
"subtitle": "設計",
16+
"body": "免費開源! ❤️‍🔥"
17+
},
18+
{
19+
"icon": "arrow.triangle.pull",
20+
"title": "貢獻",
21+
"subtitle": "一起",
22+
"body": "提出請求,變得更好! 🎉"
23+
}
24+
]
25+
},
226
{
327
"version": "4.1",
428
"subVersion": "4.1.0",

Package.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.7
1+
// swift-tools-version: 5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33
//
44
// Created by Ming on 11/6/2022.
@@ -8,10 +8,11 @@ import PackageDescription
88

99
let package = Package(
1010
name: "SwiftNEW",
11+
defaultLocalization: "en",
1112
platforms: [
12-
.iOS(.v14),
13-
.watchOS(.v7),
14-
.macOS(.v11),
13+
.iOS(.v15),
14+
.watchOS(.v8),
15+
.macOS(.v12),
1516
.custom("xros", versionString: "1.0")
1617
],
1718
products: [
@@ -30,6 +31,7 @@ let package = Package(
3031
"SwiftVB",
3132
"Drops"
3233
]
34+
// ,resources: [.process("Resources")]
3335
)
3436
]
3537
)
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"sourceLanguage" : "en",
3+
"strings" : {
4+
"Continue" : {
5+
"extractionState" : "manual",
6+
"localizations" : {
7+
"en" : {
8+
"stringUnit" : {
9+
"state" : "translated",
10+
"value" : "Continue"
11+
}
12+
},
13+
"zh-Hant" : {
14+
"stringUnit" : {
15+
"state" : "translated",
16+
"value" : "繼續"
17+
}
18+
},
19+
"zh-HK" : {
20+
"stringUnit" : {
21+
"state" : "translated",
22+
"value" : "繼續"
23+
}
24+
}
25+
}
26+
},
27+
"History" : {
28+
"extractionState" : "manual",
29+
"localizations" : {
30+
"en" : {
31+
"stringUnit" : {
32+
"state" : "translated",
33+
"value" : "History"
34+
}
35+
},
36+
"zh-Hant" : {
37+
"stringUnit" : {
38+
"state" : "translated",
39+
"value" : "歷史"
40+
}
41+
},
42+
"zh-HK" : {
43+
"stringUnit" : {
44+
"state" : "translated",
45+
"value" : "歷史"
46+
}
47+
}
48+
}
49+
},
50+
"Loading..." : {
51+
"extractionState" : "manual",
52+
"localizations" : {
53+
"en" : {
54+
"stringUnit" : {
55+
"state" : "translated",
56+
"value" : "Loading..."
57+
}
58+
},
59+
"zh-Hant" : {
60+
"stringUnit" : {
61+
"state" : "translated",
62+
"value" : "載入中......"
63+
}
64+
},
65+
"zh-HK" : {
66+
"stringUnit" : {
67+
"state" : "translated",
68+
"value" : "載入中......"
69+
}
70+
}
71+
}
72+
},
73+
"Return" : {
74+
"extractionState" : "manual",
75+
"localizations" : {
76+
"en" : {
77+
"stringUnit" : {
78+
"state" : "translated",
79+
"value" : "Return"
80+
}
81+
},
82+
"zh-Hant" : {
83+
"stringUnit" : {
84+
"state" : "translated",
85+
"value" : "返回"
86+
}
87+
},
88+
"zh-HK" : {
89+
"stringUnit" : {
90+
"state" : "translated",
91+
"value" : "返回"
92+
}
93+
}
94+
}
95+
},
96+
"Show History" : {
97+
"extractionState" : "manual",
98+
"localizations" : {
99+
"en" : {
100+
"stringUnit" : {
101+
"state" : "translated",
102+
"value" : "Show History"
103+
}
104+
},
105+
"zh-Hant" : {
106+
"stringUnit" : {
107+
"state" : "translated",
108+
"value" : "顯示歷史"
109+
}
110+
},
111+
"zh-HK" : {
112+
"stringUnit" : {
113+
"state" : "translated",
114+
"value" : "顯示歷史"
115+
}
116+
}
117+
}
118+
},
119+
"Version" : {
120+
"extractionState" : "manual",
121+
"localizations" : {
122+
"en" : {
123+
"stringUnit" : {
124+
"state" : "translated",
125+
"value" : "Version"
126+
}
127+
},
128+
"zh-Hant" : {
129+
"stringUnit" : {
130+
"state" : "translated",
131+
"value" : "版本"
132+
}
133+
},
134+
"zh-HK" : {
135+
"stringUnit" : {
136+
"state" : "translated",
137+
"value" : "版本"
138+
}
139+
}
140+
}
141+
},
142+
"What's New in" : {
143+
"extractionState" : "manual",
144+
"localizations" : {
145+
"en" : {
146+
"stringUnit" : {
147+
"state" : "translated",
148+
"value" : "What's New in"
149+
}
150+
},
151+
"zh-Hant" : {
152+
"stringUnit" : {
153+
"state" : "translated",
154+
"value" : "最新功能"
155+
}
156+
},
157+
"zh-HK" : {
158+
"stringUnit" : {
159+
"state" : "translated",
160+
"value" : "最新功能"
161+
}
162+
}
163+
}
164+
}
165+
},
166+
"version" : "1.0"
167+
}

Sources/SwiftNEW/SwiftNEW.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SwiftVB
99
import Drops
1010
#endif
1111

12-
@available(iOS 14, watchOS 7.0, macOS 11.0, *)
12+
@available(iOS 15, watchOS 8.0, macOS 12.0, *)
1313
public struct SwiftNEW: View {
1414
@AppStorage("version") var version = 1.0
1515
@AppStorage("build") var build: Double = 1
@@ -90,7 +90,8 @@ public struct SwiftNEW: View {
9090

9191
if loading {
9292
VStack {
93-
Text("Loading...").padding(.bottom)
93+
Text(String(localized: "Loading...", bundle: .module))
94+
.padding(.bottom)
9495
ProgressView()
9596
}
9697
}
@@ -165,8 +166,10 @@ public struct SwiftNEW: View {
165166
if align == .center {
166167
appIcon
167168
}
168-
Text("What's New in").bold().font(.largeTitle)
169-
Text("Version \(Bundle.versionBuild)").bold().font(.title).foregroundColor(.secondary)
169+
Text(String(localized: "What's New in", bundle: .module))
170+
.bold().font(.largeTitle)
171+
Text("\(String(localized: "Version", bundle: .module)) \(Bundle.versionBuild)")
172+
.bold().font(.title).foregroundColor(.secondary)
170173
}
171174
if align == .trailing {
172175
appIcon
@@ -176,8 +179,10 @@ public struct SwiftNEW: View {
176179
#elseif os(macOS) || os(xrOS)
177180
public var headings: some View {
178181
VStack {
179-
Text("What's New in").bold().font(.largeTitle)
180-
Text("Version \(Bundle.versionBuild)").bold().font(.title).foregroundColor(.secondary)
182+
Text(String(localized: "What's New in", bundle: .module))
183+
.bold().font(.largeTitle)
184+
Text("\(String(localized: "Version", bundle: .module)) \(Bundle.versionBuild)")
185+
.bold().font(.title).foregroundColor(.secondary)
181186
}
182187
}
183188
#endif
@@ -187,7 +192,7 @@ public struct SwiftNEW: View {
187192
if align == .trailing {
188193
Spacer()
189194
}
190-
Text("Show History")
195+
Text(String(localized: "Show History", bundle: .module))
191196
Image(systemName: "arrow.up.bin")
192197
if align == .leading {
193198
Spacer()
@@ -209,7 +214,8 @@ public struct SwiftNEW: View {
209214
if align == .trailing {
210215
Spacer()
211216
}
212-
Text("Continue").bold()
217+
Text(String(localized: "Continue", bundle: .module))
218+
.bold()
213219
Image(systemName: "arrow.right.circle.fill")
214220
if align == .leading {
215221
Spacer()
@@ -233,7 +239,8 @@ public struct SwiftNEW: View {
233239
VStack(alignment: align) {
234240
Spacer()
235241

236-
Text("History").bold().font(.largeTitle)
242+
Text(String(localized: "History", bundle: .module))
243+
.bold().font(.largeTitle)
237244

238245
Spacer()
239246

@@ -283,7 +290,8 @@ public struct SwiftNEW: View {
283290
if align == .trailing {
284291
Spacer()
285292
}
286-
Text("Return").bold()
293+
Text(String(localized: "Return", bundle: .module))
294+
.bold()
287295
Image(systemName: "arrow.down.circle.fill")
288296
if align == .leading {
289297
Spacer()

0 commit comments

Comments
 (0)