return self.localizedName;
else if (self.bundleIdentifier)
return self.bundleIdentifier;
- else
- return @"@Application";
+ else {
+ return NSLocalizedString(@"@Application",
+ @"Magic string to trigger automatic "
+ @"mapping renames. It should look like "
+ @"an identifier rather than normal "
+ @"word, with the @ on the front.");
+ }
}
@end
IOHIDManagerSetDeviceMatchingMultiple(_hidManager, (__bridge CFArrayRef)criteria);
IOReturn ret = IOHIDManagerOpen(_hidManager, kIOHIDOptionsTypeNone);
if (ret != kIOReturnSuccess) {
- [[NSAlert alertWithMessageText:@"Input devices are unavailable"
+ [[NSAlert alertWithMessageText:NSLocalizedString(@"input devices unavailable",
+ @"error title when devices can't be read")
defaultButton:nil
alternateButton:nil
otherButton:nil
- informativeTextWithFormat:@"Error 0x%08x occured trying to access your devices. "
- @"Input may not be correctly detected or mapped.",
- ret]
+ informativeTextWithFormat:NSLocalizedString(@"input error 0x%08x occurred",
+ @"message containing IOReturn failure code when devices can't be read"), ret]
beginSheetModalForWindow:outlineView.window
modalDelegate:nil
didEndSelector:nil
- (id)initWithIndex:(int)index rawMin:(long)rawMin_ rawMax:(long)rawMax_ {
if ((self = [super init])) {
- self.name = [[NSString alloc] initWithFormat: @"Axis %d", index];
- self.children = @[[[NJInput alloc] initWithName:@"Low" base:self],
- [[NJInput alloc] initWithName:@"High" base:self]];
+ self.name = [[NSString alloc] initWithFormat:NSLocalizedString(@"axis %d", @"axis name"), index];
+ self.children = @[[[NJInput alloc] initWithName:NSLocalizedString(@"axis low", @"axis low trigger") base:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"axis high", @"axis high trigger") base:self]];
rawMax = rawMax_;
rawMin = rawMin_;
}
- (id)initWithName:(NSString *)name idx:(int)idx max:(long)max {
if ((self = [super init])) {
_max = max;
+ self.name = [NSString stringWithFormat:NSLocalizedString(@"button %d", @"button name"), idx];
+
if (name.length)
- self.name = [NSString stringWithFormat:@"Button %d - %@", idx, name];
- else
- self.name = [NSString stringWithFormat:@"Button %d", idx];
+ self.name = [self.name stringByAppendingFormat:@"- %@", name];
}
return self;
}
- (id)initWithIndex:(int)index {
if ((self = [super init])) {
- self.children = @[[[NJInput alloc] initWithName:@"Up" base:self],
- [[NJInput alloc] initWithName:@"Down" base:self],
- [[NJInput alloc] initWithName:@"Left" base:self],
- [[NJInput alloc] initWithName:@"Right" base:self]];
- self.name = [NSString stringWithFormat:@"Hat Switch %d", index];
+ self.children = @[[[NJInput alloc] initWithName:NSLocalizedString(@"hat up", @"hat switch up state") base:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"hat down", @"hat switch down state") base:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"hat left", @"hat switch left state") base:self],
+ [[NJInput alloc] initWithName:NSLocalizedString(@"hat right", @"hat switch right state") base:self]];
+ self.name = [NSString stringWithFormat:NSLocalizedString(@"hat switch %d", @"hat switch name"), index];
}
return self;
}
#import <Cocoa/Cocoa.h>
-extern CGKeyCode NJKeyInputFieldEmpty;
+extern const CGKeyCode NJKeyInputFieldEmpty;
@protocol NJKeyInputFieldDelegate;
#import "NJKeyInputField.h"
-CGKeyCode NJKeyInputFieldEmpty = 0xFFFF;
+const CGKeyCode NJKeyInputFieldEmpty = 0xFFFF;
@implementation NJKeyInputField
+ (NSString *)stringForKeyCode:(CGKeyCode)keyCode {
switch (keyCode) {
- case 0xffff: return @"";
case 0x7a: return @"F1";
case 0x78: return @"F2";
case 0x63: return @"F3";
case 0x4f: return @"F18";
case 0x50: return @"F19";
- case 0x35: return @"Esc";
+ case 0x35: return @"⎋";
case 0x32: return @"`";
case 0x12: return @"1";
case 0x18: return @"=";
case 0x3f: return @"Fn";
- case 0x36: return @"Right Command";
- case 0x37: return @"Left Command";
- case 0x38: return @"Left Shift";
- case 0x39: return @"Caps Lock";
- case 0x3a: return @"Left Option";
- case 0x3b: return @"Left Control";
- case 0x3c: return @"Right Shift";
- case 0x3d: return @"Right Option";
- case 0x3e: return @"Right Control";
+ case 0x36: return NSLocalizedString(@"Right ⌘", @"keyboard key");
+ case 0x37: return NSLocalizedString(@"Left ⌘", @"keyboard key");
+ case 0x38: return NSLocalizedString(@"Left ⇧", @"keyboard key");
+ case 0x39: return @"⇪";
+ case 0x3a: return NSLocalizedString(@"Left ⌥", @"keyboard key");
+ case 0x3b: return NSLocalizedString(@"Left ⌃", @"keyboard key");
+ case 0x3c: return NSLocalizedString(@"Right ⇧", @"keyboard key");
+ case 0x3d: return NSLocalizedString(@"Right ⌃", @"keyboard key");
+ case 0x3e: return NSLocalizedString(@"Right ⌥", @"keyboard key");
- case 0x73: return @"Home";
- case 0x74: return @"Page Up";
- case 0x75: return @"Delete";
- case 0x77: return @"End";
- case 0x79: return @"Page Down";
+ case 0x73: return @"↖";
+ case 0x74: return @"⇞";
+ case 0x77: return @"↘";
+ case 0x79: return @"⇟";
+
+ case 0x75: return @"⌦";
+ case 0x33: return @"⌫";
- case 0x30: return @"Tab";
- case 0x33: return @"Backspace";
- case 0x24: return @"Return";
- case 0x31: return @"Space";
+ case 0x30: return @"⇥";
+ case 0x24: return @"↩";
+ case 0x31: return @"␣";
case 0x0c: return @"Q";
case 0x0d: return @"W";
case 0x2f: return @".";
case 0x2c: return @"/";
- case 0x47: return @"Clear";
- case 0x51: return @"Keypad =";
- case 0x4b: return @"Keypad /";
- case 0x43: return @"Keypad *";
- case 0x59: return @"Keypad 7";
- case 0x5b: return @"Keypad 8";
- case 0x5c: return @"Keypad 9";
- case 0x4e: return @"Keypad -";
- case 0x56: return @"Keypad 4";
- case 0x57: return @"Keypad 5";
- case 0x58: return @"Keypad 6";
- case 0x45: return @"Keypad +";
- case 0x53: return @"Keypad 1";
- case 0x54: return @"Keypad 2";
- case 0x55: return @"Keypad 3";
- case 0x52: return @"Keypad 0";
- case 0x41: return @"Keypad .";
- case 0x4c: return @"Enter";
+ case 0x47: return @"⌧";
+ case 0x51: return NSLocalizedString(@"Key Pad =", @"numeric pad key");
+ case 0x4b: return NSLocalizedString(@"Key Pad /", @"numeric pad key");
+ case 0x43: return NSLocalizedString(@"Key Pad *", @"numeric pad key");
+ case 0x59: return NSLocalizedString(@"Key Pad 7", @"numeric pad key");
+ case 0x5b: return NSLocalizedString(@"Key Pad 8", @"numeric pad key");
+ case 0x5c: return NSLocalizedString(@"Key Pad 9", @"numeric pad key");
+ case 0x4e: return NSLocalizedString(@"Key Pad -", @"numeric pad key");
+ case 0x56: return NSLocalizedString(@"Key Pad 4", @"numeric pad key");
+ case 0x57: return NSLocalizedString(@"Key Pad 5", @"numeric pad key");
+ case 0x58: return NSLocalizedString(@"Key Pad 6", @"numeric pad key");
+ case 0x45: return NSLocalizedString(@"Key Pad +", @"numeric pad key");
+ case 0x53: return NSLocalizedString(@"Key Pad 1", @"numeric pad key");
+ case 0x54: return NSLocalizedString(@"Key Pad 2", @"numeric pad key");
+ case 0x55: return NSLocalizedString(@"Key Pad 3", @"numeric pad key");
+ case 0x52: return NSLocalizedString(@"Key Pad 0", @"numeric pad key");
+ case 0x41: return NSLocalizedString(@"Key Pad .", @"numeric pad key");
+ case 0x4c: return @"⌤";
- case 0x7e: return @"Up";
- case 0x7d: return @"Down";
- case 0x7b: return @"Left";
- case 0x7c: return @"Right";
+ case 0x7e: return @"↑";
+ case 0x7d: return @"↓";
+ case 0x7b: return @"←";
+ case 0x7c: return @"→";
+ case 0xffff: // NJKeyInputFieldEmpty
+ return @"";
default:
- return [[NSString alloc] initWithFormat:@"Key 0x%x", keyCode];
+ return [[NSString alloc] initWithFormat:
+ NSLocalizedString(@"key 0x%x", @"unknown key code"),
+ keyCode];
}
}
// Extra checks during initialization because the data is often loaded
// from untrusted serializations.
-- (id)initWithName:(NSString *)name {
+- (id)init {
if ((self = [super init])) {
- self.name = [name isKindOfClass:NSString.class] ? name : @"Untitled";
+ self.name = NSLocalizedString(@"Untitled", @"name for new mappings");
_entries = [[NSMutableDictionary alloc] init];
}
return self;
}
+- (id)initWithName:(NSString *)name {
+ if ((self = [self init])) {
+ if ([name isKindOfClass:NSString.class])
+ self.name = name;
+ }
+ return self;
+}
+
- (id)initWithSerialization:(NSDictionary *)serialization
mappings:(NSArray *)mappings {
if ((self = [self initWithName:serialization[@"name"]])) {
&& [serialization[@"entries"] isKindOfClass:NSDictionary.class])) {
*error = [NSError errorWithDomain:@"Enjoyable"
code:0
- description:@"This isn't a valid mapping file."];
+ description:NSLocalizedString(@"invalid mapping file",
+ @"error when imported file was JSON but not a mapping")];
return nil;
}
[self.menu insertItem:item atIndex:index++];
if (added == MAXIMUM_MAPPINGS_IN_MENU
&& mappings.count > MAXIMUM_MAPPINGS_IN_MENU + 1) {
- NSString *msg = [NSString stringWithFormat:@"(and %lu more…)",
+ NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"mapping overflow %lu",
+ @"menu item when mappings list overflows"),
mappings.count - MAXIMUM_MAPPINGS_IN_MENU];
NSMenuItem *end = [[NSMenuItem alloc] initWithTitle:msg
action:@selector(_mappingListWasChosen:)
}
- (void)eventTranslationActivated:(NSNotification *)note {
- self.eventTranslationToggle.title = @"Disable";
+ self.eventTranslationToggle.title = NSLocalizedString(@"Disable",
+ @"menu item text to disable event translation");
}
- (void)eventTranslationDeactivated:(NSNotification *)note {
- self.eventTranslationToggle.title = @"Enable";
+ self.eventTranslationToggle.title = NSLocalizedString(@"Enable",
+ @"menu item text to enable event translation");
}
-
-
@end
- (id)init {
if ((self = [super init])) {
_mappings = [[NSMutableArray alloc] init];
- _currentMapping = [[NJMapping alloc] initWithName:@"(default)"];
+ _currentMapping = [[NJMapping alloc] initWithName:
+ NSLocalizedString(@"(default)", @"default name for first the mapping")];
_manualMapping = _currentMapping;
[_mappings addObject:_currentMapping];
}
if (!found) {
[self activateMapping:oldMapping];
- if ([oldMapping.name.lowercaseString isEqualToString:@"@application"]) {
+ if ([oldMapping.name.lowercaseString isEqualToString:@"@application"]
+ || [oldMapping.name.lowercaseString isEqualToString:
+ NSLocalizedString(@"@Application", nil).lowercaseString]) {
oldMapping.name = app.bestMappingName;
[self mappingsChanged];
}
}
- (IBAction)addPressed:(id)sender {
- NJMapping *newMapping = [[NJMapping alloc] initWithName:@"Untitled"];
+ NJMapping *newMapping = [[NJMapping alloc] init];
[_mappings addObject:newMapping];
[self activateMapping:newMapping];
[self mappingsChanged];
NJMapping *mergeInto = self[mapping.name];
if ([mergeInto hasConflictWith:mapping]) {
NSAlert *conflictAlert = [[NSAlert alloc] init];
- conflictAlert.messageText = @"Replace existing mappings?";
+ conflictAlert.messageText = NSLocalizedString(@"import conflict prompt", @"Title of import conflict alert");
conflictAlert.informativeText =
- [NSString stringWithFormat:
- @"This file contains inputs you've already mapped in \"%@\". Do you "
- @"want to merge them and replace your existing mappings, or import this "
- @"as a separate mapping?", mapping.name];
- [conflictAlert addButtonWithTitle:@"Merge"];
- [conflictAlert addButtonWithTitle:@"Cancel"];
- [conflictAlert addButtonWithTitle:@"New Mapping"];
+ [NSString stringWithFormat:NSLocalizedString(@"import conflict in %@", @"Explanation of import conflict"),
+ mapping.name];
+ [conflictAlert addButtonWithTitle:NSLocalizedString(@"import and merge", @"button to merge imported mappings")];
+ [conflictAlert addButtonWithTitle:NSLocalizedString(@"cancel import", @"button to cancel import")];
+ [conflictAlert addButtonWithTitle:NSLocalizedString(@"import new mapping", @"button to import as new mapping")];
[conflictAlert beginSheetModalForWindow:popoverActivate.window
modalDelegate:self
didEndSelector:@selector(mappingConflictDidResolve:returnCode:contextInfo:)
/* Begin PBXBuildFile section */
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
D594BF000FAE7397007A85F2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D594BEFF0FAE7397007A85F2 /* IOKit.framework */; };
+ EE1F3CEA16EF4182008C6426 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = EE1F3CE816EF4182008C6426 /* Localizable.strings */; };
EE3D897A16EA7EFC00596D1F /* Status Menu Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE3D897916EA7EFC00596D1F /* Status Menu Icon@2x.png */; };
EE3D897C16EA806E00596D1F /* Status Menu Icon Disabled@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE3D897B16EA806E00596D1F /* Status Menu Icon Disabled@2x.png */; };
EE3D897F16EA817E00596D1F /* Status Menu Icon Disabled.png in Resources */ = {isa = PBXBuildFile; fileRef = EE3D897D16EA817E00596D1F /* Status Menu Icon Disabled.png */; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Enjoyable.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Enjoyable.app; sourceTree = BUILT_PRODUCTS_DIR; };
D594BEFF0FAE7397007A85F2 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
+ EE1F3CE916EF4182008C6426 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Resources/English.lproj/Localizable.strings; sourceTree = "<group>"; };
EE3D897916EA7EFC00596D1F /* Status Menu Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Status Menu Icon@2x.png"; path = "Resources/Status Menu Icon@2x.png"; sourceTree = "<group>"; };
EE3D897B16EA806E00596D1F /* Status Menu Icon Disabled@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Status Menu Icon Disabled@2x.png"; path = "Resources/Status Menu Icon Disabled@2x.png"; sourceTree = "<group>"; };
EE3D897D16EA817E00596D1F /* Status Menu Icon Disabled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Status Menu Icon Disabled.png"; path = "Resources/Status Menu Icon Disabled.png"; sourceTree = "<group>"; };
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ EE1F3CE816EF4182008C6426 /* Localizable.strings */,
EE3D897D16EA817E00596D1F /* Status Menu Icon Disabled.png */,
EE3D897E16EA817E00596D1F /* Status Menu Icon.png */,
EE3D897B16EA806E00596D1F /* Status Menu Icon Disabled@2x.png */,
EE3D897C16EA806E00596D1F /* Status Menu Icon Disabled@2x.png in Resources */,
EE3D897F16EA817E00596D1F /* Status Menu Icon Disabled.png in Resources */,
EE3D898016EA817E00596D1F /* Status Menu Icon.png in Resources */,
+ EE1F3CEA16EF4182008C6426 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
+ EE1F3CE816EF4182008C6426 /* Localizable.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ EE1F3CE916EF4182008C6426 /* English */,
+ );
+ name = Localizable.strings;
+ sourceTree = "<group>";
+ };
EEF17D1B16E8E23A00D7DC4D /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>175</string>
+ <string>182</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>NSHumanReadableCopyright</key>