Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve localization support #54

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions Sources/FaceLiveness/Utilities/LivenessLocalizedStrings.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import SwiftUI

enum LocalizedStrings {
/// en = "Liveness Check"
static let get_ready_page_title = "amplify_ui_liveness_get_ready_page_title".localized()

/// 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."
static let get_ready_page_description = "amplify_ui_liveness_get_ready_page_description".localized()

/// en = "Photosensitivity Warning"
static let get_ready_photosensitivity_title = "amplify_ui_liveness_get_ready_photosensitivity_title".localized()

/// en = "This check displays colored lights. Use caution if you are photosensitive."
static let get_ready_photosensitivity_description = "amplify_ui_liveness_get_ready_photosensitivity_description".localized()

/// en = "Photosensitivity Information"
static let get_ready_photosensitivity_icon_a11y = "amplify_ui_liveness_get_ready_photosensitivity_icon_a11y".localized()

/// en = "Photosensitivity warning"
static let get_ready_photosensitivity_dialog_title = "amplify_ui_liveness_get_ready_photosensitivity_dialog_title".localized()

/// 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."
static let get_ready_photosensitivity_dialog_description = "amplify_ui_liveness_get_ready_photosensitivity_dialog_description".localized()

/// en = "Follow the instructions to complete the check:"
static let get_ready_steps_title = "amplify_ui_liveness_get_ready_steps_title".localized()

/// en = "Make sure your face is not covered with sunglasses or a mask."
static let get_ready_face_not_covered = "amplify_ui_liveness_get_ready_face_not_covered".localized()

/// en = "Move to a well-lit place that is not in direct sunlight."
static let get_ready_lighting = "amplify_ui_liveness_get_ready_lighting".localized()

/// en = "When an oval appears, fill the oval with your face in it."
static let get_ready_fit_face = "amplify_ui_liveness_get_ready_fit_face".localized()

/// en = "Begin Check"
static let get_ready_begin_check = "amplify_ui_liveness_get_ready_begin_check".localized()

/// en = "Illustration demonstrating good fit of face in oval."
static let get_ready_illustration_good_fit_a11y = "amplify_ui_liveness_get_ready_illustration_good_fit_a11y".localized()

/// en = "Illustration demonstrating face too far from screen."
static let get_ready_illustration_too_far_a11y = "amplify_ui_liveness_get_ready_illustration_too_far_a11y".localized()

/// en = "REC"
static let challenge_recording_indicator_label = "amplify_ui_liveness_challenge_recording_indicator_label".localized()

/// en = "Hold face in oval for colored lights."
static let challenge_instruction_hold_face_during_freshness = "amplify_ui_liveness_challenge_instruction_hold_face_during_freshness".localized()

/// en = "Move back"
static let challenge_instruction_move_face_back = "amplify_ui_liveness_challenge_instruction_move_face_back".localized()

/// en = "Move closer"
static let challenge_instruction_move_face_closer = "amplify_ui_liveness_challenge_instruction_move_face_closer".localized()

/// en = "Move closer"
static let challenge_instruction_move_face = "amplify_ui_liveness_challenge_instruction_move_face".localized()

/// en = "Hold still"
static let challenge_instruction_hold_still = "amplify_ui_liveness_challenge_instruction_hold_still".localized()

/// en = "Ensure only one face is in front of camera"
static let challenge_instruction_multiple_faces_detected = "amplify_ui_liveness_challenge_instruction_multiple_faces_detected".localized()

/// en = "Connecting..."
static let challenge_connecting = "amplify_ui_liveness_challenge_connecting".localized()

/// en = "Verifying"
static let challenge_verifying = "amplify_ui_liveness_challenge_verifying".localized()

/// en = "Cancel Challenge"
static let challenge_cancel_a11y = "amplify_ui_liveness_challenge_cancel_a11y".localized()

/// en = "Change Your Camera Settings"
static let camera_setting_alert_title = "amplify_ui_liveness_camera_setting_alert_title".localized()

/// en = "Allow camera permission in settings."
static let camera_setting_alert_message = "amplify_ui_liveness_camera_setting_alert_message".localized()

/// en = "Update Setting"
static let camera_setting_alert_update_setting_button_text = "amplify_ui_liveness_camera_setting_alert_update_setting_button_text".localized()

/// en = "Not Now"
static let camera_setting_alert_not_now_button_text = "amplify_ui_liveness_camera_setting_alert_not_now_button_text".localized()

/// en = "Close"
static let close_button_a11y = "amplify_ui_liveness_close_button_a11y".localized()

/// en = "Good fit"
static let get_ready_good_fit_example = "amplify_ui_liveness_get_ready_good_fit_example".localized()

/// en = "Too far"
static let get_ready_too_far_example = "amplify_ui_liveness_get_ready_too_far_example".localized()

}
166 changes: 0 additions & 166 deletions Sources/FaceLiveness/Utilities/LocalizedStringKey+Liveness.swift

This file was deleted.

27 changes: 27 additions & 0 deletions Sources/FaceLiveness/Utilities/String+Localizable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import Foundation

extension String {
/// Looks for a localized value using this value as the key.
/// If no localization is found in the current app's bundle,
/// it defaults to the one provided by Liveness
func localized(comment: String = "") -> String {
let defaultValue = NSLocalizedString(self, bundle: .module, comment: "")
return NSLocalizedString(
self,
bundle: .main,
value: defaultValue,
comment: ""
)
}

func localized(using arguments: CVarArg...) -> String {
return String(format: localized(), arguments)
}
}
2 changes: 1 addition & 1 deletion Sources/FaceLiveness/Views/CloseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct CloseButton: View {
.frame(width: 44, height: 44)
.background(Color.livenessBackground)
.clipShape(Circle())
.accessibilityLabel(Text(.close_button_a11y, bundle: .module))
.accessibilityLabel(Text(LocalizedStrings.close_button_a11y))
}
)
}
Expand Down
Loading