Skip to content

Commit 33ed5ce

Browse files
authored
Localisation has been configured. #43 (#44)
1 parent ac59e9a commit 33ed5ce

File tree

44 files changed

+315
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+315
-79
lines changed

Surcharges/Applications/Project.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ let surcharges = Target.target(
8888
sources: ["Sources/Commons/**", "Sources/Prod/**"],
8989
resources: .resources(
9090
[
91+
"Resources/Localise/**",
9192
.glob(
9293
pattern: .relativeToManifest("Resources/Prod/**"),
9394
excluding: [.relativeToManifest("Resources/Prod/.gitkeep")]
94-
)
95-
], privacyManifest: .default
95+
),
96+
],
97+
privacyManifest: .default
9698
),
9799
dependencies: productionDependencies + externalDependencies,
98100
settings: Settings.settings(
@@ -114,11 +116,13 @@ let surchargesDev = Target.target(
114116
sources: ["Sources/Commons/**", "Sources/Dev/**"],
115117
resources: .resources(
116118
[
119+
"Resources/Localise/**",
117120
.glob(
118121
pattern: .relativeToManifest("Resources/Dev/**"),
119122
excluding: [.relativeToManifest("Resources/Dev/.gitkeep")]
120-
)
121-
], privacyManifest: .default
123+
),
124+
],
125+
privacyManifest: .default
122126
),
123127
dependencies: developmentDependencies + externalDependencies,
124128
settings: Settings.settings(
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
InfoPlist.strings
3+
Resources
4+
5+
Created by Bonsung Koo on 30/01/2025.
6+
Copyright © 2025 Surcharges. All rights reserved.
7+
*/
8+
9+
"NSCameraUsageDescription"= "Surcharges uses your camera to take your receipt.";
10+
"NSLocationWhenInUseUsageDescription"= "Surcharges uses your location to provide nearest places to you.";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
Localizable.strings
3+
Resources
4+
5+
Created by Bonsung Koo on 30/01/2025.
6+
Copyright © 2025 Surcharges. All rights reserved.
7+
*/
8+
9+
/* This file must be empty. */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
InfoPlist.strings
3+
Resources
4+
5+
Created by Bonsung Koo on 30/01/2025.
6+
Copyright © 2025 Surcharges. All rights reserved.
7+
*/
8+
9+
"NSCameraUsageDescription"= "영수증 사진을 촬영하기 위해 카메라를 사용합니다.";
10+
"NSLocationWhenInUseUsageDescription"= "당신 주변의 상점을 검색하기 위해 위치 정보를 사용합니다.";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
Localizable.strings
3+
Resources
4+
5+
Created by Bonsung Koo on 30/01/2025.
6+
Copyright © 2025 Surcharges. All rights reserved.
7+
*/
8+
9+
/* This file must be empty. */

Surcharges/DataLayer/Networks/Sources/API/Response.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension API {
7171
case .badRequest:
7272
throw .badRequest
7373
case .forbidden:
74-
throw .forbidden
74+
throw .forbidden(reason: .region(availableRegions: ["nz"]))
7575
case .unauthorised:
7676
throw .unauthorised
7777
case .notFound:

Surcharges/DataLayer/Networks/Sources/Commons/NetworkError.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@
99
import Foundation
1010

1111
public enum NetworkError: Error {
12+
13+
public enum ForbiddenReason: Identifiable, Equatable, Sendable {
14+
case region(availableRegions: [String])
15+
16+
public var id: String {
17+
switch self {
18+
case .region(let availableRegions):
19+
return availableRegions.joined(separator: "")
20+
}
21+
}
22+
}
23+
1224
case systemError
1325
case badRequest
1426
case unauthorised
15-
case forbidden
27+
case forbidden(reason: ForbiddenReason)
1628
case notFound
1729
case methodNotAllowed
1830
case deprecatedAPI

Surcharges/DataLayer/Repositories/Sources/errorHandler.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ extension RepositoryProtocol {
1717
switch error {
1818
case .unauthorised:
1919
await appStatusService.notifyAppStatus(.toast(.unauthorised))
20-
case .forbidden:
21-
await appStatusService.notifyAppStatus(.toast(.outOfNZ))
20+
case .forbidden(let reason):
21+
switch reason {
22+
case .region(let availableRegions):
23+
await appStatusService.notifyAppStatus(.toast(.outOfRegion(availableRegions: availableRegions)))
24+
}
2225
case .systemError:
2326
await appStatusService.notifyAppStatus(.toast(.noInternet))
2427
case .deprecatedAPI:

Surcharges/PresentationLayer/UIs/Main/Sources/MainView.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
9393
)
9494

9595
} header: {
96-
Text("Search for \"\(_viewModel.searchedText)\"")
96+
Text(R.string.localizable.searchFor(_viewModel.searchedText))
9797
.font(.title3)
9898
.blurBackground()
9999
}
@@ -141,7 +141,7 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
141141
.buttonStyle(.plain)
142142
.contentTransition(.symbolEffect(.replace))
143143
.alert(
144-
"Use Location is Denied",
144+
R.string.localizable.alertUseLocationDeniedTitle(),
145145
isPresented: $_showLocationDeniedAlert
146146
) {
147147

@@ -150,17 +150,17 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
150150
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
151151

152152
} label: {
153-
Text("Go to Settings")
153+
Text(R.string.localizable.goToSettings())
154154
}
155155

156156
Button(role: .cancel) {
157157
_showLocationDeniedAlert.toggle()
158158
} label: {
159-
Text("Close")
159+
Text(R.string.localizable.close())
160160
}
161161

162162
} message: {
163-
Text("Allow to use your location")
163+
Text(R.string.localizable.alertUseLocationDeniedMessage())
164164
}
165165
.popoverTip(_useLocationTip, arrowEdge: .leading) { action in
166166
withAnimation {
@@ -169,7 +169,7 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
169169
_useLocationTip.invalidate(reason: .actionPerformed)
170170
}
171171

172-
TextField("Search your destination", text: $_viewModel.searchText)
172+
TextField(R.string.localizable.searchBoxPlaceholder(), text: $_viewModel.searchText)
173173
.textFieldStyle(.roundedBorder)
174174
.font(.body)
175175
.disabled(_viewModel.isLoading)
@@ -191,7 +191,7 @@ public struct MainView<VM: MainViewModelProtocol, Router: MainRouterProtocol>: V
191191
await _viewModel.search()
192192
}
193193
} label: {
194-
Text("Search")
194+
Text(R.string.localizable.searchButtonTitle())
195195
.font(.body)
196196
.disabled(!_viewModel.canSearch)
197197
}

Surcharges/PresentationLayer/UIs/Main/Sources/SearchResult/NoResultView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct NoResultView: View {
3030
.font(.largeTitle)
3131
}
3232

33-
Text("Oops!\nNo results found for \"\(_searchedText)\"")
33+
Text(R.string.localizable.noResultForSearch(_searchedText))
3434
.font(.subheadline)
3535
.multilineTextAlignment(.center)
3636

0 commit comments

Comments
 (0)