Skip to content

Commit d46842b

Browse files
committed
Version 1.1: i18n, better icon, reload item
Signed-off-by: Chris Warrick <[email protected]>
1 parent b926c6a commit d46842b

29 files changed

+1083
-12
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Changelog
33

44
More information, including binaries, can be found on GitHub in the [releases section](https://github.com/Kwpolska/DisplayMenu/releases).
55

6+
v1.1 (build 2)
7+
--------------
8+
9+
* Better app icon
10+
* Add *Refresh* menu item (^R)
11+
* Localization support (Polish translation)
12+
613
v1.0 (build 1)
714
--------------
815

Display Menu.xcodeproj/project.pbxproj

+49-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
E53D1BBA1EFE5ABF00C6F0A1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E53D1BB81EFE5ABF00C6F0A1 /* InfoPlist.strings */; };
11+
E53D1BC41EFE5E9A00C6F0A1 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = E53D1BC21EFE5E9A00C6F0A1 /* Localizable.strings */; };
12+
E53D1BC81EFE608B00C6F0A1 /* AccessibilityImageDescriptions.strings in Resources */ = {isa = PBXBuildFile; fileRef = E53D1BC61EFE608B00C6F0A1 /* AccessibilityImageDescriptions.strings */; };
1013
E5E515491EF943CD00D8CF93 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5E515481EF943CD00D8CF93 /* AppDelegate.swift */; };
1114
E5E5154B1EF943CD00D8CF93 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5E5154A1EF943CD00D8CF93 /* ViewController.swift */; };
1215
E5E5154D1EF943CD00D8CF93 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E5E5154C1EF943CD00D8CF93 /* Assets.xcassets */; };
@@ -15,8 +18,15 @@
1518
/* End PBXBuildFile section */
1619

1720
/* Begin PBXFileReference section */
21+
E53D1BB01EFE548400C6F0A1 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Main.strings; sourceTree = "<group>"; };
22+
E53D1BB91EFE5ABF00C6F0A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = "Display Menu/Base.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
23+
E53D1BBB1EFE5B5600C6F0A1 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = "Display Menu/pl.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
24+
E53D1BC31EFE5E9A00C6F0A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
25+
E53D1BC51EFE5EA100C6F0A1 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
26+
E53D1BC71EFE608B00C6F0A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/AccessibilityImageDescriptions.strings; sourceTree = "<group>"; };
27+
E53D1BC91EFE609300C6F0A1 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/AccessibilityImageDescriptions.strings; sourceTree = "<group>"; };
1828
E5E515451EF943CD00D8CF93 /* Display Menu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Display Menu.app"; sourceTree = BUILT_PRODUCTS_DIR; };
19-
E5E515481EF943CD00D8CF93 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
29+
E5E515481EF943CD00D8CF93 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2030
E5E5154A1EF943CD00D8CF93 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
2131
E5E5154C1EF943CD00D8CF93 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2232
E5E5154F1EF943CD00D8CF93 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -57,8 +67,11 @@
5767
E5E515481EF943CD00D8CF93 /* AppDelegate.swift */,
5868
E5E5154A1EF943CD00D8CF93 /* ViewController.swift */,
5969
E5E5154C1EF943CD00D8CF93 /* Assets.xcassets */,
70+
E53D1BC61EFE608B00C6F0A1 /* AccessibilityImageDescriptions.strings */,
71+
E53D1BC21EFE5E9A00C6F0A1 /* Localizable.strings */,
6072
E5E5154E1EF943CD00D8CF93 /* Main.storyboard */,
6173
E5E515511EF943CD00D8CF93 /* Info.plist */,
74+
E53D1BB81EFE5ABF00C6F0A1 /* InfoPlist.strings */,
6275
E5E515571EF96ACC00D8CF93 /* DisplayManager.swift */,
6376
);
6477
path = "Display Menu";
@@ -107,6 +120,7 @@
107120
knownRegions = (
108121
en,
109122
Base,
123+
pl,
110124
);
111125
mainGroup = E5E5153C1EF943CD00D8CF93;
112126
productRefGroup = E5E515461EF943CD00D8CF93 /* Products */;
@@ -124,6 +138,9 @@
124138
buildActionMask = 2147483647;
125139
files = (
126140
E5E5154D1EF943CD00D8CF93 /* Assets.xcassets in Resources */,
141+
E53D1BC41EFE5E9A00C6F0A1 /* Localizable.strings in Resources */,
142+
E53D1BC81EFE608B00C6F0A1 /* AccessibilityImageDescriptions.strings in Resources */,
143+
E53D1BBA1EFE5ABF00C6F0A1 /* InfoPlist.strings in Resources */,
127144
E5E515501EF943CD00D8CF93 /* Main.storyboard in Resources */,
128145
);
129146
runOnlyForDeploymentPostprocessing = 0;
@@ -144,10 +161,39 @@
144161
/* End PBXSourcesBuildPhase section */
145162

146163
/* Begin PBXVariantGroup section */
164+
E53D1BB81EFE5ABF00C6F0A1 /* InfoPlist.strings */ = {
165+
isa = PBXVariantGroup;
166+
children = (
167+
E53D1BB91EFE5ABF00C6F0A1 /* Base */,
168+
E53D1BBB1EFE5B5600C6F0A1 /* pl */,
169+
);
170+
name = InfoPlist.strings;
171+
path = ..;
172+
sourceTree = "<group>";
173+
};
174+
E53D1BC21EFE5E9A00C6F0A1 /* Localizable.strings */ = {
175+
isa = PBXVariantGroup;
176+
children = (
177+
E53D1BC31EFE5E9A00C6F0A1 /* Base */,
178+
E53D1BC51EFE5EA100C6F0A1 /* pl */,
179+
);
180+
name = Localizable.strings;
181+
sourceTree = "<group>";
182+
};
183+
E53D1BC61EFE608B00C6F0A1 /* AccessibilityImageDescriptions.strings */ = {
184+
isa = PBXVariantGroup;
185+
children = (
186+
E53D1BC71EFE608B00C6F0A1 /* Base */,
187+
E53D1BC91EFE609300C6F0A1 /* pl */,
188+
);
189+
name = AccessibilityImageDescriptions.strings;
190+
sourceTree = "<group>";
191+
};
147192
E5E5154E1EF943CD00D8CF93 /* Main.storyboard */ = {
148193
isa = PBXVariantGroup;
149194
children = (
150195
E5E5154F1EF943CD00D8CF93 /* Base */,
196+
E53D1BB01EFE548400C6F0A1 /* pl */,
151197
);
152198
name = Main.storyboard;
153199
sourceTree = "<group>";
@@ -159,6 +205,7 @@
159205
isa = XCBuildConfiguration;
160206
buildSettings = {
161207
ALWAYS_SEARCH_USER_PATHS = NO;
208+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
162209
CLANG_ANALYZER_NONNULL = YES;
163210
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
164211
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
@@ -209,6 +256,7 @@
209256
isa = XCBuildConfiguration;
210257
buildSettings = {
211258
ALWAYS_SEARCH_USER_PATHS = NO;
259+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
212260
CLANG_ANALYZER_NONNULL = YES;
213261
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
214262
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";

Display Menu/AppDelegate.swift

+13-6
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
3939
var displayManager: DisplayManager? = nil
4040
let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
4141
let statusMenu = NSMenu()
42+
let refreshItem = NSMenuItem(title: NSLocalizedString("Reload", comment: "Reload menu item"), action: #selector(acquireDisplayManager), keyEquivalent: "r")
43+
let quitItem = NSMenuItem(title: NSLocalizedString("Quit", comment: "Quit menu item"), action: #selector(NSApp.terminate), keyEquivalent: "q")
4244

4345
func applicationDidFinishLaunching(_ aNotification: Notification) {
4446
do {
4547
try acquireDisplayManager()
4648
} catch let error {
47-
alertAndQuit("Failed to initialize display manager.", String(reflecting: error))
49+
alertAndQuit(NSLocalizedString("Failed to initialize display manager.", comment: "Alert title (display manager/config error)"), String(reflecting: error))
4850
}
4951

52+
refreshItem.keyEquivalentModifierMask = .control
5053
statusMenu.delegate = self
5154

5255
statusItem.image = #imageLiteral(resourceName: "DMStatusReady")
@@ -61,7 +64,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6164
if FileManager.default.fileExists(atPath: url.path) {
6265
displayManager = try DisplayManager(jsonPath: url)
6366
} else {
64-
alertAndQuit("Settings file not found", "Place a settings file at \(url.path) and try again.")
67+
alertAndQuit(
68+
NSLocalizedString("Settings file not found", comment: "no settings alert title"),
69+
String.localizedStringWithFormat(NSLocalizedString("Place a settings file at %@ and try again.", comment: "no settings alert description"), url.path)
70+
)
6571
}
6672
}
6773

@@ -80,7 +86,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
8086
self.statusItem.image = #imageLiteral(resourceName: "DMStatusSuccess")
8187
} catch let error {
8288
self.statusItem.image = #imageLiteral(resourceName: "DMStatusError")
83-
alert("Failed to apply preset", String(reflecting: error), alertStyle: .critical)
89+
alert(NSLocalizedString("Failed to apply preset", comment: "alert when applyPreset fails"), String(reflecting: error), alertStyle: .critical)
8490
}
8591
Timer.scheduledTimer(timeInterval: TimeInterval(1.5), target: self, selector: #selector(_resetDMIcon), userInfo: nil, repeats: false)
8692
}
@@ -96,7 +102,8 @@ extension AppDelegate: NSMenuDelegate {
96102
}
97103

98104
menu.addItem(NSMenuItem.separator())
99-
menu.addItem(withTitle: "Quit", action: #selector(NSApp.terminate), keyEquivalent: "q")
105+
menu.addItem(refreshItem)
106+
menu.addItem(quitItem)
100107
}
101108
}
102109

@@ -111,9 +118,9 @@ public func alert(_ messageText: String, _ informativeText: String? = nil, alert
111118
}
112119

113120
public func alertAndQuit(_ messageText: String, _ informativeText: String? = nil) {
114-
var informative = "The application will now quit."
121+
var informative = NSLocalizedString("The application will now quit.", comment: "fatal error alert (without informative text)")
115122
if informativeText != nil {
116-
informative = informativeText! + " The application will now quit."
123+
informative = String.localizedStringWithFormat(NSLocalizedString("%@ The application will now quit.", comment: "fatal error alert (argument is informative text)"), informativeText!)
117124
}
118125
alert(messageText, informative, alertStyle: NSAlertStyle.critical)
119126
NSApp.terminate(nil)
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"DMStatusReady" = "Display Menu";
2+
"DMStatusWorking" = "Display Menu (working)";
3+
"DMStatusSuccess" = "Display Menu (success)";
4+
"DMStatusError" = "Display Menu (error)";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CFBundleDisplayName = "Display Menu";
2+
NSHumanReadableCopyright = "Copyright © 2017 Chris Warrick. All rights reserved. Licensed under the 3-clause BSD license.";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* fatal error alert (argument is informative text) */
2+
"%@ The application will now quit." = "%@ The application will now quit.";
3+
4+
/* alert when applyPreset fails */
5+
"Failed to apply preset" = "Failed to apply preset";
6+
7+
/* no settings alert description */
8+
"Place a settings file at %@ and try again." = "Place a settings file at %@ and try again.";
9+
10+
/* Quit menu item */
11+
"Quit" = "Quit";
12+
13+
/* Reload menu item */
14+
"Reload" = "Reload";
15+
16+
/* no settings alert title */
17+
"Settings file not found" = "Settings file not found";
18+
19+
/* fatal error alert (no other info) */
20+
"The application will now quit." = "The application will now quit.";
21+
22+
/* Alert title (display manager/config error) */
23+
"Failed to initialize display manager." = "Nie udało się zainicjalizować menadżera ekranów.";

Display Menu/Info.plist

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
66
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>Display Menu</string>
79
<key>CFBundleExecutable</key>
810
<string>$(EXECUTABLE_NAME)</string>
911
<key>CFBundleIconFile</key>
10-
<string></string>
12+
<string>AppIcon</string>
1113
<key>CFBundleIdentifier</key>
1214
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1315
<key>CFBundleInfoDictionaryVersion</key>
@@ -17,18 +19,18 @@
1719
<key>CFBundlePackageType</key>
1820
<string>APPL</string>
1921
<key>CFBundleShortVersionString</key>
20-
<string>1.0</string>
22+
<string>1.1</string>
2123
<key>CFBundleVersion</key>
22-
<string>1</string>
24+
<string>2</string>
2325
<key>LSMinimumSystemVersion</key>
2426
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
27+
<key>LSUIElement</key>
28+
<true/>
2529
<key>NSHumanReadableCopyright</key>
2630
<string>Copyright © 2017 Chris Warrick. All rights reserved. Licensed under the 3-clause BSD license.</string>
2731
<key>NSMainStoryboardFile</key>
2832
<string>Main</string>
2933
<key>NSPrincipalClass</key>
3034
<string>NSApplication</string>
31-
<key>LSUIElement</key>
32-
<true/>
3335
</dict>
3436
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"DMStatusReady" = "Menu Ekranów";
2+
"DMStatusWorking" = "Menu Ekranów (praca w toku)";
3+
"DMStatusSuccess" = "Menu Ekranów (OK)";
4+
"DMStatusError" = "Menu Ekranów (błąd)";
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CFBundleDisplayName = "Menu Ekranów";
2+
NSHumanReadableCopyright = "Copyright © 2017 Chris Warrick. Wszelkie prawa zastrzeżone. Na licencji BSD (3-klauzulowej).";
3+
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* fatal error alert (argument is informative text) */
2+
"%@ The application will now quit." = "%@ Program zostanie teraz zamknięty.";
3+
4+
/* alert when applyPreset fails */
5+
"Failed to apply preset" = "Nie udało się ustawić układu";
6+
7+
/* no settings alert description */
8+
"Place a settings file at %@ and try again." = "Utwórz plik z ustawieniami %@ i spróbuj ponownie.";
9+
10+
/* Quit menu item */
11+
"Quit" = "Zakończ";
12+
13+
/* Reload menu item */
14+
"Reload" = "Odśwież";
15+
16+
/* no settings alert title */
17+
"Settings file not found" = "Nie znaleziono pliku z ustawieniami";
18+
19+
/* fatal error alert (no other info) */
20+
"The application will now quit." = "Program zostanie teraz zamknięty.";
21+
22+
/* Alert title (display manager/config error) */
23+
"Failed to initialize display manager." = "Failed to initialize display manager.";

0 commit comments

Comments
 (0)