Skip to content

Commit 20a8ad8

Browse files
authored
chore: improve localization support (#54)
* chore: improve localization support * chore: revert integration test change * chore: fix code comment typo * revert project file
1 parent 4ff64da commit 20a8ad8

File tree

11 files changed

+175
-221
lines changed

11 files changed

+175
-221
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import SwiftUI
9+
10+
enum LocalizedStrings {
11+
/// en = "Liveness Check"
12+
static let get_ready_page_title = "amplify_ui_liveness_get_ready_page_title".localized()
13+
14+
/// en = "You will go through a face verification process to prove that you are a real person. Your screen's brightness will temporarily be set to 100% for highest accuracy."
15+
static let get_ready_page_description = "amplify_ui_liveness_get_ready_page_description".localized()
16+
17+
/// en = "Photosensitivity Warning"
18+
static let get_ready_photosensitivity_title = "amplify_ui_liveness_get_ready_photosensitivity_title".localized()
19+
20+
/// en = "This check displays colored lights. Use caution if you are photosensitive."
21+
static let get_ready_photosensitivity_description = "amplify_ui_liveness_get_ready_photosensitivity_description".localized()
22+
23+
/// en = "Photosensitivity Information"
24+
static let get_ready_photosensitivity_icon_a11y = "amplify_ui_liveness_get_ready_photosensitivity_icon_a11y".localized()
25+
26+
/// en = "Photosensitivity warning"
27+
static let get_ready_photosensitivity_dialog_title = "amplify_ui_liveness_get_ready_photosensitivity_dialog_title".localized()
28+
29+
/// en = "A small percentage of individuals may experience epileptic seizures when exposed to colored lights. Use caution if you, or anyone in your family, have an epileptic condition."
30+
static let get_ready_photosensitivity_dialog_description = "amplify_ui_liveness_get_ready_photosensitivity_dialog_description".localized()
31+
32+
/// en = "Follow the instructions to complete the check:"
33+
static let get_ready_steps_title = "amplify_ui_liveness_get_ready_steps_title".localized()
34+
35+
/// en = "Make sure your face is not covered with sunglasses or a mask."
36+
static let get_ready_face_not_covered = "amplify_ui_liveness_get_ready_face_not_covered".localized()
37+
38+
/// en = "Move to a well-lit place that is not in direct sunlight."
39+
static let get_ready_lighting = "amplify_ui_liveness_get_ready_lighting".localized()
40+
41+
/// en = "When an oval appears, fill the oval with your face in it."
42+
static let get_ready_fit_face = "amplify_ui_liveness_get_ready_fit_face".localized()
43+
44+
/// en = "Begin Check"
45+
static let get_ready_begin_check = "amplify_ui_liveness_get_ready_begin_check".localized()
46+
47+
/// en = "Illustration demonstrating good fit of face in oval."
48+
static let get_ready_illustration_good_fit_a11y = "amplify_ui_liveness_get_ready_illustration_good_fit_a11y".localized()
49+
50+
/// en = "Illustration demonstrating face too far from screen."
51+
static let get_ready_illustration_too_far_a11y = "amplify_ui_liveness_get_ready_illustration_too_far_a11y".localized()
52+
53+
/// en = "REC"
54+
static let challenge_recording_indicator_label = "amplify_ui_liveness_challenge_recording_indicator_label".localized()
55+
56+
/// en = "Hold face in oval for colored lights."
57+
static let challenge_instruction_hold_face_during_freshness = "amplify_ui_liveness_challenge_instruction_hold_face_during_freshness".localized()
58+
59+
/// en = "Move back"
60+
static let challenge_instruction_move_face_back = "amplify_ui_liveness_challenge_instruction_move_face_back".localized()
61+
62+
/// en = "Move closer"
63+
static let challenge_instruction_move_face_closer = "amplify_ui_liveness_challenge_instruction_move_face_closer".localized()
64+
65+
/// en = "Move closer"
66+
static let challenge_instruction_move_face = "amplify_ui_liveness_challenge_instruction_move_face".localized()
67+
68+
/// en = "Hold still"
69+
static let challenge_instruction_hold_still = "amplify_ui_liveness_challenge_instruction_hold_still".localized()
70+
71+
/// en = "Ensure only one face is in front of camera"
72+
static let challenge_instruction_multiple_faces_detected = "amplify_ui_liveness_challenge_instruction_multiple_faces_detected".localized()
73+
74+
/// en = "Connecting..."
75+
static let challenge_connecting = "amplify_ui_liveness_challenge_connecting".localized()
76+
77+
/// en = "Verifying"
78+
static let challenge_verifying = "amplify_ui_liveness_challenge_verifying".localized()
79+
80+
/// en = "Cancel Challenge"
81+
static let challenge_cancel_a11y = "amplify_ui_liveness_challenge_cancel_a11y".localized()
82+
83+
/// en = "Change Your Camera Settings"
84+
static let camera_setting_alert_title = "amplify_ui_liveness_camera_setting_alert_title".localized()
85+
86+
/// en = "Allow camera permission in settings."
87+
static let camera_setting_alert_message = "amplify_ui_liveness_camera_setting_alert_message".localized()
88+
89+
/// en = "Update Setting"
90+
static let camera_setting_alert_update_setting_button_text = "amplify_ui_liveness_camera_setting_alert_update_setting_button_text".localized()
91+
92+
/// en = "Not Now"
93+
static let camera_setting_alert_not_now_button_text = "amplify_ui_liveness_camera_setting_alert_not_now_button_text".localized()
94+
95+
/// en = "Close"
96+
static let close_button_a11y = "amplify_ui_liveness_close_button_a11y".localized()
97+
98+
/// en = "Good fit"
99+
static let get_ready_good_fit_example = "amplify_ui_liveness_get_ready_good_fit_example".localized()
100+
101+
/// en = "Too far"
102+
static let get_ready_too_far_example = "amplify_ui_liveness_get_ready_too_far_example".localized()
103+
104+
}

Sources/FaceLiveness/Utilities/LocalizedStringKey+Liveness.swift

Lines changed: 0 additions & 166 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
10+
extension String {
11+
/// Looks for a localized value using this value as the key.
12+
/// If no localization is found in the current app's bundle,
13+
/// it defaults to the one provided by Liveness
14+
func localized(comment: String = "") -> String {
15+
let defaultValue = NSLocalizedString(self, bundle: .module, comment: "")
16+
return NSLocalizedString(
17+
self,
18+
bundle: .main,
19+
value: defaultValue,
20+
comment: ""
21+
)
22+
}
23+
24+
func localized(using arguments: CVarArg...) -> String {
25+
return String(format: localized(), arguments)
26+
}
27+
}

Sources/FaceLiveness/Views/CloseButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct CloseButton: View {
2020
.frame(width: 44, height: 44)
2121
.background(Color.livenessBackground)
2222
.clipShape(Circle())
23-
.accessibilityLabel(Text(.close_button_a11y, bundle: .module))
23+
.accessibilityLabel(Text(LocalizedStrings.close_button_a11y))
2424
}
2525
)
2626
}

0 commit comments

Comments
 (0)