Skip to content

Commit

Permalink
Merge pull request #9 from mac-cain13/master
Browse files Browse the repository at this point in the history
Localized the App to Dutch (and some other small tweaks)
  • Loading branch information
codler committed Aug 16, 2012
2 parents 6746f4a + 9be6fee commit 355011f
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 220 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.xcworkspace
!default.xcworkspace
xcuserdata

.DS_Store
23 changes: 17 additions & 6 deletions Battery Time Remaining.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
28FEDA5E15DA5C9D00320B72 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28FEDA5D15DA5C9D00320B72 /* ServiceManagement.framework */; };
28FEDA6E15DA5ECA00320B72 /* LaunchAtLoginHelper.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 28FEDA6B15DA5EB200320B72 /* LaunchAtLoginHelper.app */; };
28FEDA6F15DA5F8C00320B72 /* LLManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 28FEDA6315DA5EB200320B72 /* LLManager.m */; };
D58C7EF815CD7C6100C07E0C /* StartAtLoginHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */; };
D53375E515DC43380077CEF6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D53375E315DC43380077CEF6 /* Localizable.strings */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -78,8 +78,9 @@
28FEDA6215DA5EB200320B72 /* LLManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLManager.h; path = ../LaunchAtLoginHelper/LLManager.h; sourceTree = "<group>"; };
28FEDA6315DA5EB200320B72 /* LLManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = LLManager.m; path = ../LaunchAtLoginHelper/LLManager.m; sourceTree = "<group>"; };
28FEDA6415DA5EB200320B72 /* LLStrings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LLStrings.h; path = ../LaunchAtLoginHelper/LLStrings.h; sourceTree = "<group>"; };
D58C7EF615CD7C6100C07E0C /* StartAtLoginHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StartAtLoginHelper.h; sourceTree = "<group>"; };
D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StartAtLoginHelper.m; sourceTree = "<group>"; };
D53375E415DC43380077CEF6 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
D53375FC15DC44620077CEF6 /* nl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
D53375FD15DC47700077CEF6 /* nl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -145,8 +146,6 @@
2841C7F315C91CC100F4F15F /* AppDelegate.m */,
28833BAC15D7B90B00741727 /* HttpGet.h */,
28833BAD15D7B90B00741727 /* HttpGet.m */,
D58C7EF615CD7C6100C07E0C /* StartAtLoginHelper.h */,
D58C7EF715CD7C6100C07E0C /* StartAtLoginHelper.m */,
2841C7E715C91CC100F4F15F /* Supporting Files */,
);
path = "Battery Time Remaining";
Expand All @@ -155,6 +154,7 @@
2841C7E715C91CC100F4F15F /* Supporting Files */ = {
isa = PBXGroup;
children = (
D53375E315DC43380077CEF6 /* Localizable.strings */,
28833BB315D7D61100741727 /* build_version */,
28833BB115D7D4FF00741727 /* Readme.md */,
28BA61A715D1B12500EDB674 /* icon.icns */,
Expand Down Expand Up @@ -213,6 +213,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
nl,
);
mainGroup = 2841C7D115C91CC100F4F15F;
productRefGroup = 2841C7DD15C91CC100F4F15F /* Products */;
Expand Down Expand Up @@ -250,6 +251,7 @@
28BA61A815D1B12500EDB674 /* icon.icns in Resources */,
28833BB215D7D4FF00741727 /* Readme.md in Resources */,
28833BB415D7D61100741727 /* build_version in Resources */,
D53375E515DC43380077CEF6 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -263,7 +265,6 @@
28FEDA6F15DA5F8C00320B72 /* LLManager.m in Sources */,
2841C7ED15C91CC100F4F15F /* main.m in Sources */,
2841C7F415C91CC100F4F15F /* AppDelegate.m in Sources */,
D58C7EF815CD7C6100C07E0C /* StartAtLoginHelper.m in Sources */,
28833BAE15D7B90B00741727 /* HttpGet.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -283,6 +284,7 @@
isa = PBXVariantGroup;
children = (
2841C7EA15C91CC100F4F15F /* en */,
D53375FD15DC47700077CEF6 /* nl */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
Expand All @@ -295,6 +297,15 @@
name = Credits.rtf;
sourceTree = "<group>";
};
D53375E315DC43380077CEF6 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
D53375E415DC43380077CEF6 /* en */,
D53375FC15DC44620077CEF6 /* nl */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
52 changes: 19 additions & 33 deletions Battery Time Remaining/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "AppDelegate.h"
#import "HttpGet.h"
#import "LLManager.h"
#import "StartAtLoginHelper.h"
#import <IOKit/ps/IOPowerSources.h>
#import <IOKit/ps/IOPSKeys.h>

Expand Down Expand Up @@ -44,18 +43,17 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[self saveNotificationSettings];

// Power source menu
self.psTimeMenu = [[NSMenuItem alloc] initWithTitle:@"Loading…" action:nil keyEquivalent:@""];
self.psTimeMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Loading…", @"Remaining menuitem") action:nil keyEquivalent:@""];
[self.psTimeMenu setEnabled:NO];

self.psStateMenu = [[NSMenuItem alloc] initWithTitle:@"Power source: Unknown" action:nil keyEquivalent:@""];
self.psStateMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Power source: Unknown", @"Powersource menuitem") action:nil keyEquivalent:@""];
[self.psStateMenu setEnabled:NO];

#ifndef SANDBOX
// Create the startup at login toggle
self.startupToggle = [[NSMenuItem alloc] initWithTitle:@"Start at login" action:@selector(toggleStartAtLogin:) keyEquivalent:@""];
self.startupToggle = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Start at login", @"Start at login setting") action:@selector(toggleStartAtLogin:) keyEquivalent:@""];
self.startupToggle.target = self;
self.startupToggle.state = ([LLManager launchAtLogin]) ? NSOnState : NSOffState;
//self.startupToggle.state = ([StartAtLoginHelper isInLoginItems]) ? NSOnState : NSOffState;
#endif

// Build the notification submenu
Expand All @@ -69,11 +67,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[notificationSubmenu addItem:notificationSubmenuItem];
}

NSMenuItem *notificationMenu = [[NSMenuItem alloc] initWithTitle:@"Notifications" action:nil keyEquivalent:@""];
NSMenuItem *notificationMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Notifications", @"Notification menuitem") action:nil keyEquivalent:@""];
[notificationMenu setSubmenu:notificationSubmenu];

// Updater menu
self.updaterMenu = [[NSMenuItem alloc] initWithTitle:@"Checking for updates…" action:nil keyEquivalent:@""];
self.updaterMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Checking for updates…", @"Update menuitem") action:nil keyEquivalent:@""];
[self.updaterMenu setEnabled:NO];

// Build the status menu
Expand All @@ -88,11 +86,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[statusMenu addItem:notificationMenu];
[statusMenu addItem:[NSMenuItem separatorItem]];

[statusMenu addItemWithTitle:@"Energy Saver Preferences…" action:@selector(openEnergySaverPreference:) keyEquivalent:@""];
[statusMenu addItemWithTitle:NSLocalizedString(@"Energy Saver Preferences…", @"Open Energy Saver Preferences menuitem") action:@selector(openEnergySaverPreference:) keyEquivalent:@""];
[statusMenu addItem:[NSMenuItem separatorItem]];
[statusMenu addItem:self.updaterMenu];
[statusMenu addItem:[NSMenuItem separatorItem]];
[statusMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@""];
[statusMenu addItemWithTitle:NSLocalizedString(@"Quit", @"Quit menuitem") action:@selector(terminate:) keyEquivalent:@""];

// Create the status item and set initial text
statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
Expand Down Expand Up @@ -135,8 +133,8 @@ - (void)updateStatusItem
NSInteger percent = (int)[currentBatteryCapacity doubleValue] / [maxBatteryCapacity doubleValue] * 100;

// Update menu title
self.psTimeMenu.title = [NSString stringWithFormat:@"%ld %% left", percent];
self.psStateMenu.title = [NSString stringWithFormat:@"Power source: %@", CFDictionaryGetValue(description, CFSTR(kIOPSPowerSourceStateKey))];
self.psTimeMenu.title = [NSString stringWithFormat:NSLocalizedString(@"%ld %% left", @"Percentage left menuitem"), percent];
self.psStateMenu.title = [NSString stringWithFormat:NSLocalizedString(@"Power source: %@", @"Powersource menuitem"), CFDictionaryGetValue(description, CFSTR(kIOPSPowerSourceStateKey))];

// We're connected to an unlimited power source (AC adapter probably)
if (kIOPSTimeRemainingUnlimited == timeRemaining)
Expand All @@ -160,7 +158,7 @@ - (void)updateStatusItem
else
{
self.statusItem.image = [self getBatteryIconNamed:@"BatteryCharging"];
self.statusItem.title = @" Calculating…";
self.statusItem.title = NSLocalizedString(@" Calculating…", @"Calculating sidetext");
}
}
else
Expand All @@ -186,7 +184,7 @@ - (void)updateStatusItem
else if (kIOPSTimeRemainingUnknown == timeRemaining)
{
self.statusItem.image = [self getBatteryIconPercent:percent];
self.statusItem.title = @" Calculating…";
self.statusItem.title = NSLocalizedString(@" Calculating…", @"Calculating sidetext");
}
// Time is known!
else
Expand All @@ -203,7 +201,7 @@ - (void)updateStatusItem
if ([[self.notifications valueForKey:key] boolValue] && [key intValue] == percent) {
// Send notification once
if (self.previousPercent != percent) {
[self notify:[NSString stringWithFormat:@"%ld:%02ld left (%ld%%)", hour, minute, percent]];
[self notify:[NSString stringWithFormat:NSLocalizedString(@"%ld:%02ld left (%ld%%)", @"Percentage left menuitem"), hour, minute, percent]];
}
break;
}
Expand Down Expand Up @@ -273,25 +271,13 @@ - (void)toggleStartAtLogin:(id)sender
[LLManager setLaunchAtLogin:YES];
self.startupToggle.state = NSOnState;
}
/*
// Check the state of start at login
if ([StartAtLoginHelper isInLoginItems])
{
[StartAtLoginHelper removeFromLoginItems];
self.startupToggle.state = NSOffState;
}
else
{
[StartAtLoginHelper addToLoginItems];
self.startupToggle.state = NSOnState;
}*/
}
#endif

- (void)notify:(NSString *)message
{
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Battery Time Remaining"];
[notification setTitle:NSLocalizedString(@"Battery Time Remaining", @"Notification title")];
[notification setInformativeText:message];
[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
Expand Down Expand Up @@ -341,7 +327,7 @@ - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentN

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
if ([[notification informativeText] isEqualToString:@"A newer version is available"]) {
if ([[notification informativeText] isEqualToString:NSLocalizedString(@"A newer version is available", @"Update menuitem")]) {
[self openHomeUrl:nil];
}
}
Expand All @@ -361,21 +347,21 @@ - (void)menuWillOpen:(NSMenu *)menu
NSInteger currentBuildVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] integerValue];

if (!latestBuildVersion) {
self.updaterMenu.title = @"Could not check for updates";
self.updaterMenu.title = NSLocalizedString(@"Could not check for updates", @"Update menuitem");
return;
}

// Newer version available
if (latestBuildVersion > currentBuildVersion) {
self.updaterMenu.title = @"A newer version is available";
self.updaterMenu.title = NSLocalizedString(@"A newer version is available", @"Update menuitem");
[self.updaterMenu setAction:@selector(openHomeUrl:)];
[self.updaterMenu setEnabled:YES];
[self notify:@"A newer version is available"];
[self notify:NSLocalizedString(@"A newer version is available", @"Update notification")];
} else {
self.updaterMenu.title = @"Up to date";
self.updaterMenu.title = NSLocalizedString(@"Up to date", @"Update menuitem");
}
} error:^(NSError *error) {
self.updaterMenu.title = @"Could not check for updates";
self.updaterMenu.title = NSLocalizedString(@"Could not check for updates", @"Update menuitem");
}];
}

Expand Down
2 changes: 2 additions & 0 deletions Battery Time Remaining/Battery Time Remaining-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>LSHasLocalizedDisplayName</key>
<true/>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
17 changes: 0 additions & 17 deletions Battery Time Remaining/StartAtLoginHelper.h

This file was deleted.

Loading

0 comments on commit 355011f

Please sign in to comment.