Skip to content

Commit ba29a0f

Browse files
authored
Merge pull request #30 from tapwork/localized_strings
Adds localized strings (en & de)
2 parents 8634613 + 7ddf16f commit ba29a0f

5 files changed

Lines changed: 34 additions & 15 deletions

File tree

BarcodeScanner.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
1515
s.requires_arc = true
1616

1717
s.source_files = 'Sources/**/*'
18-
s.resource_bundles = { 'BarcodeScanner' => ['Images/*.{png}'] }
18+
s.resource_bundles = { 'BarcodeScanner' => ['Images/*.{png}'] , 'Localization' => ['Localization/*.lproj/Localizable.strings']}
1919

2020
s.frameworks = 'UIKit', 'AVFoundation'
2121

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- BarcodeScanner (1.0.0)
2+
- BarcodeScanner (2.0.0)
33

44
DEPENDENCIES:
55
- BarcodeScanner (from `../../`)
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
99
:path: "../../"
1010

1111
SPEC CHECKSUMS:
12-
BarcodeScanner: b78575fbe0d0f6d2ce9217d798cfb22ce9ba1225
12+
BarcodeScanner: 225e96dfa2cee966771b345e4bf72b1babfa0c40
1313

1414
PODFILE CHECKSUM: 5ef23317899e015b0a239f469648c11cbee75aaa
1515

16-
COCOAPODS: 1.1.0.rc.2
16+
COCOAPODS: 1.2.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"SCAN_BARCODE_TITLE" = "Scan Barcode";
2+
"BUTTON_CLOSE" = "Schließen";
3+
"BUTTON_SETTINGS" = "Einstellungen";
4+
"INFO_DESCRIPTION_TEXT" = "Den Barcode innerhalb des Fensters platzieren. Die Suche beginnt automatisch.";
5+
"INFO_LOADING_TITLE" = "Suche...";
6+
"NO_PRODUCT_ERROR_TITLE" = "Es wurde kein Barcode erkannt.";
7+
"ASK_FOR_PERMISSION_TEXT" = "Für die Erkennung der Barcodes, müssen Sie der Nutzung für die Kamera zustimmen.";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"SCAN_BARCODE_TITLE" = "Scan barcode";
2+
"BUTTON_CLOSE" = "Close";
3+
"BUTTON_SETTINGS" = "Settings";
4+
"INFO_DESCRIPTION_TEXT" = "Place the barcode within the window to scan. The search will start automatically.";
5+
"INFO_LOADING_TITLE" = "Looking for your product...";
6+
"NO_PRODUCT_ERROR_TITLE" = "No product found.";
7+
"ASK_FOR_PERMISSION_TEXT" = "In order to scan barcodes you have to allow camera under your settings.";

Sources/Config.swift

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,28 @@ import AVFoundation
44
// MARK: - Configurations
55

66
public 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

1212
public 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

1818
public 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

2424
public 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

Comments
 (0)