Skip to content

Commit cefc6f0

Browse files
committed
Mainly localizations
1 parent b2866b4 commit cefc6f0

File tree

9 files changed

+176
-82
lines changed

9 files changed

+176
-82
lines changed

GeofenceTester.xcodeproj/project.pbxproj

+35
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
CB655F6F28534E2700EBCABA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CB655F6E28534E2700EBCABA /* Assets.xcassets */; };
1515
CB655F7228534E2700EBCABA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CB655F7028534E2700EBCABA /* LaunchScreen.storyboard */; };
1616
CB655F7E2856A43B00EBCABA /* RegionsListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB655F7D2856A43B00EBCABA /* RegionsListViewController.swift */; };
17+
CB97AE3F286DC6410067B1BF /* RegionsListVC+CoreLocationsDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB97AE3E286DC6410067B1BF /* RegionsListVC+CoreLocationsDelegate.swift */; };
18+
CBBF88CF286F269B00E4E1F0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = CBBF88CD286F269B00E4E1F0 /* InfoPlist.strings */; };
19+
CBBF88D2286F269B00E4E1F0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = CBBF88D0286F269B00E4E1F0 /* Localizable.strings */; };
1720
CBE711EF2868EE36008F51C4 /* RegionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBE711EE2868EE36008F51C4 /* RegionViewController.swift */; };
1821
CBE711F1286915A8008F51C4 /* EventRecord.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBE711F0286915A8008F51C4 /* EventRecord.swift */; };
1922
CBE711F3286920FD008F51C4 /* EventsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBE711F2286920FD008F51C4 /* EventsTableViewController.swift */; };
@@ -33,6 +36,11 @@
3336
CB655F7128534E2700EBCABA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
3437
CB655F7328534E2700EBCABA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3538
CB655F7D2856A43B00EBCABA /* RegionsListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionsListViewController.swift; sourceTree = "<group>"; };
39+
CB97AE3D286DB2840067B1BF /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = "<group>"; };
40+
CB97AE3E286DC6410067B1BF /* RegionsListVC+CoreLocationsDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RegionsListVC+CoreLocationsDelegate.swift"; sourceTree = "<group>"; };
41+
CBBF88CE286F269B00E4E1F0 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
42+
CBBF88D1286F269B00E4E1F0 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
43+
CBBF88D3286F29ED00E4E1F0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3644
CBE711EE2868EE36008F51C4 /* RegionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionViewController.swift; sourceTree = "<group>"; };
3745
CBE711F0286915A8008F51C4 /* EventRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventRecord.swift; sourceTree = "<group>"; };
3846
CBE711F2286920FD008F51C4 /* EventsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsTableViewController.swift; sourceTree = "<group>"; };
@@ -76,6 +84,7 @@
7684
CBE71236286C7E7A008F51C4 /* Keys.swift */,
7785
CB655F6728534E2600EBCABA /* SceneDelegate.swift */,
7886
CB655F7D2856A43B00EBCABA /* RegionsListViewController.swift */,
87+
CB97AE3E286DC6410067B1BF /* RegionsListVC+CoreLocationsDelegate.swift */,
7988
CBE711EE2868EE36008F51C4 /* RegionViewController.swift */,
8089
CBE711F2286920FD008F51C4 /* EventsTableViewController.swift */,
8190
CBE711F0286915A8008F51C4 /* EventRecord.swift */,
@@ -84,6 +93,8 @@
8493
CB655F6E28534E2700EBCABA /* Assets.xcassets */,
8594
CB655F7028534E2700EBCABA /* LaunchScreen.storyboard */,
8695
CB655F7328534E2700EBCABA /* Info.plist */,
96+
CBBF88D0286F269B00E4E1F0 /* Localizable.strings */,
97+
CBBF88CD286F269B00E4E1F0 /* InfoPlist.strings */,
8798
);
8899
path = GeofenceTester;
89100
sourceTree = "<group>";
@@ -135,6 +146,7 @@
135146
knownRegions = (
136147
en,
137148
Base,
149+
de,
138150
);
139151
mainGroup = CB655F5928534E2600EBCABA;
140152
packageReferences = (
@@ -154,7 +166,9 @@
154166
isa = PBXResourcesBuildPhase;
155167
buildActionMask = 2147483647;
156168
files = (
169+
CBBF88D2286F269B00E4E1F0 /* Localizable.strings in Resources */,
157170
CB655F7228534E2700EBCABA /* LaunchScreen.storyboard in Resources */,
171+
CBBF88CF286F269B00E4E1F0 /* InfoPlist.strings in Resources */,
158172
CB655F6F28534E2700EBCABA /* Assets.xcassets in Resources */,
159173
CB655F6D28534E2600EBCABA /* Main.storyboard in Resources */,
160174
);
@@ -167,6 +181,7 @@
167181
isa = PBXSourcesBuildPhase;
168182
buildActionMask = 2147483647;
169183
files = (
184+
CB97AE3F286DC6410067B1BF /* RegionsListVC+CoreLocationsDelegate.swift in Sources */,
170185
CBE711F1286915A8008F51C4 /* EventRecord.swift in Sources */,
171186
CBE71237286C7E7A008F51C4 /* Keys.swift in Sources */,
172187
CB655F6628534E2600EBCABA /* AppDelegate.swift in Sources */,
@@ -185,6 +200,7 @@
185200
isa = PBXVariantGroup;
186201
children = (
187202
CB655F6C28534E2600EBCABA /* Base */,
203+
CB97AE3D286DB2840067B1BF /* de */,
188204
);
189205
name = Main.storyboard;
190206
sourceTree = "<group>";
@@ -197,13 +213,31 @@
197213
name = LaunchScreen.storyboard;
198214
sourceTree = "<group>";
199215
};
216+
CBBF88CD286F269B00E4E1F0 /* InfoPlist.strings */ = {
217+
isa = PBXVariantGroup;
218+
children = (
219+
CBBF88CE286F269B00E4E1F0 /* de */,
220+
CBBF88D3286F29ED00E4E1F0 /* en */,
221+
);
222+
name = InfoPlist.strings;
223+
sourceTree = "<group>";
224+
};
225+
CBBF88D0286F269B00E4E1F0 /* Localizable.strings */ = {
226+
isa = PBXVariantGroup;
227+
children = (
228+
CBBF88D1286F269B00E4E1F0 /* de */,
229+
);
230+
name = Localizable.strings;
231+
sourceTree = "<group>";
232+
};
200233
/* End PBXVariantGroup section */
201234

202235
/* Begin XCBuildConfiguration section */
203236
CB655F7428534E2700EBCABA /* Debug */ = {
204237
isa = XCBuildConfiguration;
205238
buildSettings = {
206239
ALWAYS_SEARCH_USER_PATHS = NO;
240+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
207241
CLANG_ANALYZER_NONNULL = YES;
208242
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
209243
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
@@ -264,6 +298,7 @@
264298
isa = XCBuildConfiguration;
265299
buildSettings = {
266300
ALWAYS_SEARCH_USER_PATHS = NO;
301+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
267302
CLANG_ANALYZER_NONNULL = YES;
268303
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
269304
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";

GeofenceTester/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Keys.swift

GeofenceTester/Base.lproj/Main.storyboard

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
</barButtonItem>
9191
</navigationItem>
9292
<connections>
93+
<outlet property="addButton" destination="BJ6-F4-XfY" id="UTb-4K-1NO"/>
9394
<outlet property="mapView" destination="PTq-kR-Xju" id="Xpb-Pa-2kJ"/>
9495
<segue destination="abz-U4-dF9" kind="showDetail" identifier="RegionDetail" id="r59-b2-f5b"/>
9596
</connections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//
2+
// RegionsListVC+CoreLocationsDelegate.swift
3+
// GeofenceTester
4+
//
5+
// Created by Alexander von Below on 30.06.22.
6+
//
7+
8+
import UIKit
9+
import CoreLocation
10+
11+
extension RegionsListViewController: CLLocationManagerDelegate {
12+
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
13+
process(event: .ENTER, region: region)
14+
}
15+
16+
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
17+
process(event: .EXIT, region: region)
18+
}
19+
20+
private func process (event: EventRecord.EventType, region: CLRegion) {
21+
let content = UNMutableNotificationContent()
22+
let title: String
23+
switch event {
24+
case .ENTER:
25+
title = NSLocalizedString("Region Entered",
26+
comment: "Push Notificaton Title")
27+
case .EXIT:
28+
title = NSLocalizedString("Region Exited",
29+
comment: "Push Notificaton Title")
30+
}
31+
content.title = title
32+
content.body = "\(region.identifier) \(Date())"
33+
34+
let eventRecord = EventRecord(event: event,
35+
identifier: region.identifier,
36+
date: Date())
37+
do {
38+
try storage.store(eventRecord)
39+
}
40+
catch let error {
41+
self.handleError(error)
42+
}
43+
let request = UNNotificationRequest(identifier: region.identifier,
44+
content: content,
45+
trigger: nil)
46+
UNUserNotificationCenter.current().add(request)
47+
}
48+
49+
func locationManager( _ manager: CLLocationManager,
50+
monitoringDidFailFor region: CLRegion?,
51+
withError error: Error
52+
) {
53+
self.handleError(error)
54+
}
55+
56+
func locationManager(_ manager: CLLocationManager,
57+
didChangeAuthorization status: CLAuthorizationStatus) {
58+
switch status {
59+
case .restricted, .denied:
60+
// Disable your app's location features
61+
self.handleError("Warning: Location restricted or denied")
62+
63+
case .authorizedWhenInUse:
64+
// Enable your app's location features.
65+
self.handleError("Warning: Location InUse Only")
66+
67+
case .authorizedAlways:
68+
self.mapView.showsUserLocation = true
69+
// Enable or prepare your app's location features that can run any time.
70+
71+
case .notDetermined:
72+
self.handleError("Warning: Location Not Determined")
73+
default:
74+
self.handleError("Warning: Switch fell through")
75+
}
76+
}
77+
}

GeofenceTester/RegionsListViewController.swift

+19-82
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ class RegionsListViewController: UIViewController {
1616
private var logger = Logger()
1717

1818
@IBOutlet var mapView: MKMapView!
19+
@IBOutlet var addButton: UIBarButtonItem!
1920

2021
override func viewDidLoad() {
2122
super.viewDidLoad()
2223

24+
addButton.accessibilityLabel = NSLocalizedString("Add Monitored Region at current location", comment: "Accessibilty label for add button")
2325
locationManager.delegate = self
2426

2527
registerMapAnnotationViews()
@@ -31,7 +33,11 @@ class RegionsListViewController: UIViewController {
3133
self.mapView.showsUserLocation = true
3234
mapView.setCenter(mapView.userLocation.coordinate, animated: true)
3335
default:
34-
let alert = UIAlertController(title: "No authorization", message: "This app requires the location services to be authorised", preferredStyle: .alert)
36+
let alert = UIAlertController(title: NSLocalizedString("No authorization",
37+
comment: "Alert: Authorization to Localization denied"),
38+
message: NSLocalizedString("This app requires the location services to be authorised",
39+
comment: "Alert: Authorization to Localization denied"),
40+
preferredStyle: .alert)
3541
self.present(alert, animated: true)
3642
}
3743
}
@@ -47,14 +53,20 @@ class RegionsListViewController: UIViewController {
4753
}
4854

4955
@IBAction func addRegionAction() {
50-
let alertController = UIAlertController(title: "New Region", message: "Please enter a name", preferredStyle: .alert)
56+
let alertController = UIAlertController(title: NSLocalizedString("New Region",
57+
comment: "New Region Alert"),
58+
message: NSLocalizedString("Please enter a name",
59+
comment: "New Region Alert"),
60+
preferredStyle: .alert)
5161
alertController.addTextField()
52-
alertController.addAction(UIAlertAction(title: "Cancel",
62+
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel",
63+
comment: "New Region Alert"),
5364
style: .cancel,
5465
handler: { _ in
5566
return
5667
}))
57-
alertController.addAction(UIAlertAction(title: "OK",
68+
alertController.addAction(UIAlertAction(title: NSLocalizedString("OK",
69+
comment: "New Region Alert"),
5870
style: .default,
5971
handler: { _ in
6072
guard let identifier = alertController.textFields?.first?.text else {
@@ -121,11 +133,11 @@ class RegionsListViewController: UIViewController {
121133
mapView.showAnnotations(mapAnnotations, animated: true)
122134
}
123135

124-
private func handleError (_ error: Error) {
136+
internal func handleError (_ error: Error) {
125137
handleError(error.localizedDescription)
126138
}
127139

128-
private func handleError (_ error: String) {
140+
internal func handleError (_ error: String) {
129141
logger.error("\(error)")
130142
}
131143

@@ -136,8 +148,7 @@ class RegionsListViewController: UIViewController {
136148

137149
if let destination = segue.destination as? RegionViewController {
138150
guard let annotation = sender as? MKAnnotation else {
139-
let logger = Logger()
140-
logger.log(level: .error, "Sender was not MKAnnotation")
151+
self.handleError("Sender was not MKAnnotation")
141152
return
142153
}
143154
guard let identifier = annotation.title else {
@@ -186,77 +197,3 @@ extension RegionsListViewController: MKMapViewDelegate {
186197
self.performSegue(withIdentifier: "RegionDetail", sender: view.annotation)
187198
}
188199
}
189-
190-
// MARK: - CLLocationManagerDelegate
191-
192-
extension RegionsListViewController: CLLocationManagerDelegate {
193-
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
194-
let date = Date()
195-
let content = UNMutableNotificationContent()
196-
content.title = "Region Entered"
197-
content.body = "\(region.identifier) \(date)"
198-
199-
let eventRecord = EventRecord(event: .ENTER,
200-
identifier: region.identifier,
201-
date: date)
202-
do {
203-
try storage.store(eventRecord)
204-
}
205-
catch let error {
206-
self.handleError(error)
207-
}
208-
let request = UNNotificationRequest(identifier: region.identifier,
209-
content: content,
210-
trigger: nil)
211-
UNUserNotificationCenter.current().add(request)
212-
}
213-
214-
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) {
215-
let content = UNMutableNotificationContent()
216-
content.title = "Region Exited"
217-
content.body = "\(region.identifier) \(Date())"
218-
219-
let eventRecord = EventRecord(event: .EXIT,
220-
identifier: region.identifier,
221-
date: Date())
222-
do {
223-
try storage.store(eventRecord)
224-
}
225-
catch let error {
226-
self.handleError(error)
227-
}
228-
let request = UNNotificationRequest(identifier: region.identifier,
229-
content: content,
230-
trigger: nil)
231-
UNUserNotificationCenter.current().add(request)
232-
}
233-
234-
func locationManager( _ manager: CLLocationManager,
235-
monitoringDidFailFor region: CLRegion?,
236-
withError error: Error
237-
) {
238-
self.handleError(error)
239-
}
240-
241-
func locationManager(_ manager: CLLocationManager,
242-
didChangeAuthorization status: CLAuthorizationStatus) {
243-
switch status {
244-
case .restricted, .denied:
245-
// Disable your app's location features
246-
self.handleError("Warning: Location restricted or denied")
247-
248-
case .authorizedWhenInUse:
249-
// Enable your app's location features.
250-
self.handleError("Warning: Location InUse Only")
251-
252-
case .authorizedAlways:
253-
self.mapView.showsUserLocation = true
254-
// Enable or prepare your app's location features that can run any time.
255-
256-
case .notDetermined:
257-
self.handleError("Warning: Location Not Determined")
258-
default:
259-
self.handleError("Warning: Switch fell through")
260-
}
261-
}
262-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Privacy - Location Always and When In Use Usage Description */
2+
"NSLocationWhenInUseUsageDescription" = "Der Zweck dieser App ist Region Monitoring. Dazu benötigt sie Ortungsdienste im Hintergrund";
3+
"NSLocationAlwaysAndWhenInUseUsageDescription" = "Der Zweck dieser App ist Region Monitoring. Dazu benötigt sie Ortungsdienste im Hintergrund";
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Accessibilty label for add button */
2+
"Add Monitored Region at current location" = "Füge eine überwachte Region am aktuellen Ort hinzu";
3+
4+
/* New Region Alert */
5+
"Cancel" = "Abbrechen";
6+
7+
/* New Region Alert */
8+
"New Region" = "Neue Region";
9+
10+
/* Alert: Authorization to Localization denied */
11+
"No authorization" = "Keine Authorization";
12+
13+
/* New Region Alert */
14+
"OK" = "OK";
15+
16+
/* New Region Alert */
17+
"Please enter a name" = "Name für die Region";
18+
19+
/* Push Notificaton Title */
20+
"Region Entered" = "Region betreten";
21+
22+
/* Push Notificaton Title */
23+
"Region Exited" = "Region verlassen";
24+
25+
/* Alert: Authorization to Localization denied */
26+
"This app requires the location services to be authorised" = "Die Ortungsdienste müssen für diese App zugelassen sein";
27+

GeofenceTester/de.lproj/Main.strings

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* Class = "UIButton"; configuration.title = "Delete"; ObjectID = "pRa-cH-jsG"; */
2+
"pRa-cH-jsG.configuration.title" = "Löschen";
3+
4+
/* Class = "UIButton"; normalTitle = "Button"; ObjectID = "pRa-cH-jsG"; */
5+
"pRa-cH-jsG.normalTitle" = "Button";
6+
7+
/* Class = "UILabel"; text = "Label"; ObjectID = "YxR-jO-lcY"; */
8+
"YxR-jO-lcY.text" = "Label";
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* Privacy - Location When In Use Usage Description */
2+
"NSLocationWhenInUseUsageDescription" = "This is a region monitoring testing app. It needs background location updates";
3+
"NSLocationAlwaysAndWhenInUseUsageDescription" = "This is a region monitoring testing app. It needs background location updates";

0 commit comments

Comments
 (0)