Skip to content

Commit b5e992e

Browse files
authored
Use appName instead of hard-coded Loop in strings (#26)
* enable use of environment appName * restore comment to original * modify text with appName so translation string remains constant * update Xcode placement of Bundle.swift, fix typo in header
1 parent eba7d98 commit b5e992e

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

G7SensorKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
B60BB2E42BC649DA00D2BB39 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B60BB2E32BC649DA00D2BB39 /* Bundle.swift */; };
1011
C109F14A291ECCE2008EA5B6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C109F149291ECCE2008EA5B6 /* Assets.xcassets */; };
1112
C109F14C291ED66F008EA5B6 /* G7GlucoseMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C109F14B291ED66F008EA5B6 /* G7GlucoseMessageTests.swift */; };
1213
C139829829295D7D0047DB5F /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17F514A291EB6F000555EB5 /* HKUnit.swift */; };
@@ -106,6 +107,7 @@
106107
/* End PBXCopyFilesBuildPhase section */
107108

108109
/* Begin PBXFileReference section */
110+
B60BB2E32BC649DA00D2BB39 /* Bundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bundle.swift; path = G7SensorKitUI/Extensions/Bundle.swift; sourceTree = SOURCE_ROOT; };
109111
C1086B0E29C9169100D46E65 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
110112
C1086B0F29C9169100D46E65 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
111113
C109F149291ECCE2008EA5B6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -366,6 +368,7 @@
366368
C17F5154291EBD7100555EB5 /* Extensions */ = {
367369
isa = PBXGroup;
368370
children = (
371+
B60BB2E32BC649DA00D2BB39 /* Bundle.swift */,
369372
C17F5155291EBD8600555EB5 /* Image.swift */,
370373
);
371374
path = Extensions;
@@ -636,6 +639,7 @@
636639
buildActionMask = 2147483647;
637640
files = (
638641
C17F5108291EAC9D00555EB5 /* G7SettingsView.swift in Sources */,
642+
B60BB2E42BC649DA00D2BB39 /* Bundle.swift in Sources */,
639643
C17F5157291EBD9900555EB5 /* TimeInterval.swift in Sources */,
640644
C19C9F4E29C91C4C00A6D3D0 /* LocalizedString.swift in Sources */,
641645
C17F5156291EBD8600555EB5 /* Image.swift in Sources */,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Bundle.swift
3+
// G7SensorKit
4+
//
5+
// Created by Darin Krauss on 1/23/21.
6+
// Copyright © 2021 LoopKit Authors. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
extension Bundle {
12+
var bundleDisplayName: String {
13+
return object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
14+
}
15+
}

G7SensorKitUI/G7CGMManager/G7UICoordinator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class G7UICoordinator: UINavigationController, CGMManagerOnboarding, CompletionN
5454
}
5555
}
5656
)
57+
.environment(\.appName, Bundle.main.bundleDisplayName)
5758
let hostingController = DismissibleHostingController(content: rootView, colorPalette: colorPalette)
5859
hostingController.navigationItem.largeTitleDisplayMode = .never
5960
hostingController.title = nil

G7SensorKitUI/Views/G7StartupView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ struct G7StartupView: View {
1313
var didContinue: (() -> Void)?
1414
var didCancel: (() -> Void)?
1515

16+
@Environment(\.appName) private var appName
17+
1618
var body: some View {
1719
VStack(alignment: .center, spacing: 20) {
1820
Spacer()
@@ -26,7 +28,7 @@ struct G7StartupView: View {
2628
.frame(height: 120)
2729
.padding(.horizontal)
2830
}.frame(maxWidth: .infinity)
29-
Text(LocalizedString("Loop can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Descriptive text on G7StartupView"))
31+
Text(String(format: LocalizedString("%1$@ can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Descriptive text on G7StartupView (1: appName)"), self.appName))
3032
.fixedSize(horizontal: false, vertical: true)
3133
.foregroundColor(.secondary)
3234
Spacer()

0 commit comments

Comments
 (0)