@@ -4,32 +4,28 @@ import AVFoundation
44// MARK: - Configurations
55
66public struct Title {
7- public static var text = NSLocalizedString ( " Scan barcode " , comment : " " )
7+ public static var text = localizedString ( " SCAN_BARCODE_TITLE " )
88 public static var font = UIFont . boldSystemFont ( ofSize: 17 )
99 public static var color = UIColor . black
1010}
1111
1212public struct CloseButton {
13- public static var text = NSLocalizedString ( " Close " , comment : " " )
13+ public static var text = localizedString ( " BUTTON_CLOSE " )
1414 public static var font = UIFont . boldSystemFont ( ofSize: 17 )
1515 public static var color = UIColor . black
1616}
1717
1818public struct SettingsButton {
19- public static var text = NSLocalizedString ( " Settings " , comment : " " )
19+ public static var text = localizedString ( " BUTTON_SETTINGS " )
2020 public static var font = UIFont . boldSystemFont ( ofSize: 17 )
2121 public static var color = UIColor . white
2222}
2323
2424public struct Info {
25- public static var text = NSLocalizedString (
26- " Place the barcode within the window to scan. The search will start automatically. " , comment: " " )
27- public static var loadingText = NSLocalizedString (
28- " Looking for your product... " , comment: " " )
29- public static var notFoundText = NSLocalizedString (
30- " No product found. " , comment: " " )
31- public static var settingsText = NSLocalizedString (
32- " In order to scan barcodes you have to allow camera under your settings. " , comment: " " )
25+ public static var text = localizedString ( " INFO_DESCRIPTION_TEXT " )
26+ public static var loadingText = localizedString ( " INFO_LOADING_TITLE " )
27+ public static var notFoundText = localizedString ( " NO_PRODUCT_ERROR_TITLE " )
28+ public static var settingsText = localizedString ( " ASK_FOR_PERMISSION_TEXT " )
3329
3430 public static var font = UIFont . boldSystemFont ( ofSize: 14 )
3531 public static var textColor = UIColor . black
@@ -64,6 +60,15 @@ func imageNamed(_ name: String) -> UIImage {
6460 return image
6561}
6662
63+ func localizedString( _ key: String ) -> String {
64+ if let path = Bundle ( for: BarcodeScannerController . self) . resourcePath,
65+ let resourceBundle = Bundle ( path: path + " /Localization.bundle " ) {
66+ return resourceBundle. localizedString ( forKey: key, value: nil , table: " Localizable " )
67+ }
68+ return key
69+ }
70+
71+
6772/**
6873 `AVCaptureMetadataOutput` metadata object types.
6974 */
0 commit comments