Skip to content

Commit c6ae236

Browse files
authored
Create localized strings file (#637)
1 parent 947e6da commit c6ae236

File tree

14 files changed

+625
-52
lines changed

14 files changed

+625
-52
lines changed

ios/HackerNews.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@
692692
ONLY_ACTIVE_ARCH = YES;
693693
SDKROOT = iphoneos;
694694
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
695+
SWIFT_EMIT_LOC_STRINGS = YES;
695696
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
696697
};
697698
name = Debug;
@@ -747,6 +748,7 @@
747748
MTL_FAST_MATH = YES;
748749
SDKROOT = iphoneos;
749750
SWIFT_COMPILATION_MODE = wholemodule;
751+
SWIFT_EMIT_LOC_STRINGS = YES;
750752
SWIFT_OPTIMIZATION_LEVEL = "-O";
751753
VALIDATE_PRODUCT = YES;
752754
};
@@ -782,6 +784,7 @@
782784
"@executable_path/Frameworks",
783785
);
784786
LIBRARY_SEARCH_PATHS = "\"$(PROJECT_DIR)/Frameworks/Reaper.xcframework\"";
787+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
785788
MARKETING_VERSION = 3.10;
786789
OTHER_LDFLAGS = "-fprofile-instr-generate";
787790
OTHER_SWIFT_FLAGS = "-profile-generate -profile-coverage-mapping";
@@ -826,6 +829,7 @@
826829
"@executable_path/Frameworks",
827830
);
828831
LIBRARY_SEARCH_PATHS = "\"$(PROJECT_DIR)/Frameworks/Reaper.xcframework\"";
832+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
829833
MARKETING_VERSION = 3.10;
830834
PRODUCT_BUNDLE_IDENTIFIER = com.emergetools.hackernews;
831835
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1030,6 +1034,7 @@
10301034
MTL_FAST_MATH = YES;
10311035
SDKROOT = iphoneos;
10321036
SWIFT_COMPILATION_MODE = wholemodule;
1037+
SWIFT_EMIT_LOC_STRINGS = YES;
10331038
SWIFT_OPTIMIZATION_LEVEL = "-O";
10341039
VALIDATE_PRODUCT = YES;
10351040
};
@@ -1064,6 +1069,7 @@
10641069
"@executable_path/Frameworks",
10651070
);
10661071
LIBRARY_SEARCH_PATHS = "\"$(PROJECT_DIR)/Frameworks/Reaper.xcframework\"";
1072+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
10671073
MARKETING_VERSION = 3.10;
10681074
PRODUCT_BUNDLE_IDENTIFIER = com.emergetools.hackernews;
10691075
PRODUCT_NAME = "$(TARGET_NAME)";

ios/HackerNews/Auth/LoginRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct LoginRow: View {
4141
}
4242

4343
func loginText() -> String {
44-
return loggedIn ? "Logout" : "Login"
44+
return loggedIn ? String(localized: "auth.button.logout") : String(localized: "auth.button.login")
4545
}
4646

4747
func glowColor() -> Color {

ios/HackerNews/Auth/LoginScreen.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct LoginScreen: View {
3939
Spacer()
4040
.frame(maxHeight: 16)
4141

42-
TextField("Username", text: $loginState.username)
42+
TextField(String(localized: "auth.field.username"), text: $loginState.username)
4343
.textInputAutocapitalization(.none)
4444
.padding()
4545
.background(Color.background)
@@ -49,7 +49,7 @@ struct LoginScreen: View {
4949
.stroke(Color.background.opacity(0.5), lineWidth: 1)
5050
)
5151

52-
SecureField("Password", text: $loginState.password)
52+
SecureField(String(localized: "auth.field.password"), text: $loginState.password)
5353
.padding()
5454
.background(Color.background)
5555
.clipShape(RoundedRectangle(cornerRadius: 12))
@@ -59,16 +59,16 @@ struct LoginScreen: View {
5959
)
6060

6161
if loginState.showError {
62-
Text("Invalid username or password")
62+
Text("auth.error.invalidCredentials")
6363
.foregroundColor(.red)
6464
.font(.ibmPlexMono(.regular, size: 14))
6565
}
6666

6767

6868
HStack(spacing: 0) {
69-
Text("By signing in, you agree to the ")
69+
Text("auth.agreement.prefix")
7070
.font(.ibmPlexSans(.regular, size: 12))
71-
Text("Hacker News Guidelines")
71+
Text("auth.agreement.guidelines")
7272
.font(.ibmPlexSans(.regular, size: 12))
7373
.foregroundColor(.blue)
7474
.underline()
@@ -97,7 +97,7 @@ struct LoginScreen: View {
9797
}
9898
},
9999
label: {
100-
Text("Submit")
100+
Text("auth.button.submit")
101101
.font(.ibmPlexMono(.bold, size: 16))
102102
.frame(maxWidth: .infinity)
103103
.frame(height: 40)

ios/HackerNews/Bookmarks/BookmarksScreen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct BookmarksScreen: View {
1616
Group {
1717
if model.bookmarks.isEmpty {
1818
ZStack {
19-
Text("Long-press a story to bookmark it.")
19+
Text("bookmarks.emptyState")
2020
.font(.ibmPlexSans(.medium, size: 18))
2121
}
2222
} else {
@@ -47,7 +47,7 @@ struct BookmarksScreen: View {
4747
.background(.ultraThinMaterial)
4848
.containerShape(.rect(cornerRadius: 24, style: .continuous))
4949

50-
Text("Bookmarks")
50+
Text("bookmarks.title")
5151
.font(.ibmPlexMono(.bold, size: 24))
5252
.padding(.horizontal, 16)
5353
}

ios/HackerNews/Comments/CommentComposer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ struct CommentComposer: View {
1616
HStack(alignment: .center) {
1717
Image(systemName: "message.fill")
1818
.font(.system(size: 12))
19-
Text("Add a comment")
19+
Text("comments.composer.title")
2020
.font(.ibmPlexSans(.medium, size: 12))
2121
}
2222
TextField(
23-
"Words of wisdom",
23+
String(localized: "comments.composer.placeholder"),
2424
text: $state.text
2525
)
2626
.textFieldStyle(.roundedBorder)

ios/HackerNews/Comments/CommentRow.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ struct CommentRow: View {
5757
.clipShape(Capsule())
5858

5959
Menu {
60-
Button("Report Comment") {
60+
Button(String(localized: "comments.action.report")) {
6161
flagComment(state)
6262
}
63-
Button(state.hidden ? "Show" : "Collapse") {
63+
Button(state.hidden ? String(localized: "comments.action.show") : String(localized: "comments.action.collapse")) {
6464
toggleComment()
6565
}
6666
} label: {

ios/HackerNews/Comments/CommentsHeader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct CommentsHeader: View {
6464
.clipShape(Capsule())
6565

6666
Menu {
67-
Button("Report Post", action: flagPost)
67+
Button(String(localized: "post.action.report"), action: flagPost)
6868
} label: {
6969
Image(systemName: "ellipsis")
7070
.font(.system(size: 12))

ios/HackerNews/Feed/FeedScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private struct FeedListView: View {
9393
model.toggleBookmark(content)
9494
} label: {
9595
Label(
96-
content.bookmarked ? "Remove Bookmark" : "Bookmark",
96+
content.bookmarked ? String(localized: "bookmarks.action.remove") : String(localized: "bookmarks.action.bookmark"),
9797
systemImage: content.bookmarked ? "book.fill" : "book"
9898
)
9999
}

0 commit comments

Comments
 (0)