diff options
| author | Tomáš Znamenáček | 2015-08-18 14:00:09 +0200 |
|---|---|---|
| committer | Tomáš Znamenáček | 2015-08-18 14:00:09 +0200 |
| commit | 814934072aef7050f0efc880a6496c97aa288d3a (patch) | |
| tree | 3fc5abc1718183af62873272fd562f9520864b46 /Framework | |
| parent | 74e3f32438ec052828fe53a48dc04afaf66e7fd3 (diff) | |
| download | MASShortcut-814934072aef7050f0efc880a6496c97aa288d3a.tar.bz2 | |
Added Czech localization.
Diffstat (limited to 'Framework')
| -rw-r--r-- | Framework/MASLocalization.h | 13 | ||||
| -rw-r--r-- | Framework/MASLocalization.m | 7 | ||||
| -rw-r--r-- | Framework/MASShortcut.m | 2 | ||||
| -rw-r--r-- | Framework/MASShortcutValidator.m | 4 | ||||
| -rw-r--r-- | Framework/MASShortcutView.m | 26 | ||||
| -rw-r--r-- | Framework/Prefix.pch | 3 |
6 files changed, 38 insertions, 17 deletions
diff --git a/Framework/MASLocalization.h b/Framework/MASLocalization.h new file mode 100644 index 0000000..466a969 --- /dev/null +++ b/Framework/MASLocalization.h @@ -0,0 +1,13 @@ +/** + Reads a localized string from the framework’s bundle. + + Normally you would use NSLocalizedString to read the localized + strings, but that’s just a shortcut for loading the strings from + the main bundle. And once the framework ends up in an app, the + main bundle will be the app’s bundle and won’t contain our strings. + So we introduced this helper function that makes sure to load the + strings from the framework’s bundle. Please avoid using + NSLocalizedString throughout the framework, it wouldn’t work + properly. +*/ +NSString *MASLocalizedString(NSString *key, NSString *comment);
\ No newline at end of file diff --git a/Framework/MASLocalization.m b/Framework/MASLocalization.m new file mode 100644 index 0000000..7f395a9 --- /dev/null +++ b/Framework/MASLocalization.m @@ -0,0 +1,7 @@ +#import "MASLocalization.h" +#import "MASShortcut.h" + +NSString *MASLocalizedString(NSString *key, NSString *comment) { + NSBundle *frameworkBundle = [NSBundle bundleForClass:[MASShortcut class]]; + return [frameworkBundle localizedStringForKey:key value:@"XXX" table:@"Localizable"]; +} diff --git a/Framework/MASShortcut.m b/Framework/MASShortcut.m index ef3385d..0170c01 100644 --- a/Framework/MASShortcut.m +++ b/Framework/MASShortcut.m @@ -100,7 +100,7 @@ static NSString *const MASShortcutModifierFlags = @"ModifierFlags"; case kVK_F17: return @"F17"; case kVK_F18: return @"F18"; case kVK_F19: return @"F19"; - case kVK_Space: return NSLocalizedString(@"Space", @"Shortcut glyph name for SPACE key"); + case kVK_Space: return MASLocalizedString(@"Space", @"Shortcut glyph name for SPACE key"); case kVK_Escape: return NSStringFromMASKeyCode(kMASShortcutGlyphEscape); case kVK_Delete: return NSStringFromMASKeyCode(kMASShortcutGlyphDeleteLeft); case kVK_ForwardDelete: return NSStringFromMASKeyCode(kMASShortcutGlyphDeleteRight); diff --git a/Framework/MASShortcutValidator.m b/Framework/MASShortcutValidator.m index 47dd700..6b192bf 100644 --- a/Framework/MASShortcutValidator.m +++ b/Framework/MASShortcutValidator.m @@ -68,7 +68,7 @@ if (equalFlags && equalHotkeyLowercase) { if (explanation) { - *explanation = NSLocalizedString(@"This shortcut cannot be used because it is already used by the menu item ‘%@’.", + *explanation = MASLocalizedString(@"This shortcut cannot be used because it is already used by the menu item ‘%@’.", @"Message for alert when shortcut is already used"); *explanation = [NSString stringWithFormat:*explanation, menuItem.title]; } @@ -95,7 +95,7 @@ ([(__bridge NSNumber *)enabled boolValue])) { if (explanation) { - *explanation = NSLocalizedString(@"This combination cannot be used because it is already used by a system-wide " + *explanation = MASLocalizedString(@"This combination cannot be used because it is already used by a system-wide " @"keyboard shortcut.\nIf you really want to use this key combination, most shortcuts " @"can be changed in the Keyboard & Mouse panel in System Preferences.", @"Message for alert when shortcut is already used by the system"); diff --git a/Framework/MASShortcutView.m b/Framework/MASShortcutView.m index 7b67411..21b8f38 100644 --- a/Framework/MASShortcutView.m +++ b/Framework/MASShortcutView.m @@ -139,8 +139,8 @@ static const CGFloat MASButtonFontSize = 11; // Give VoiceOver users feedback on the result. Requires at least 10.9 to run. if (_recording == NO && (&NSAccessibilityPriorityKey != NULL)) { NSString* msg = _shortcutValue ? - NSLocalizedString(@"Shortcut set", @"VoiceOver: Shortcut set") : - NSLocalizedString(@"Shortcut cleared", @"VoiceOver: Shortcut cleared"); + MASLocalizedString(@"Shortcut set", @"VoiceOver: Shortcut set") : + MASLocalizedString(@"Shortcut cleared", @"VoiceOver: Shortcut cleared"); NSDictionary *announcementInfo = @{ NSAccessibilityAnnouncementKey : msg, NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh), @@ -217,10 +217,10 @@ static const CGFloat MASButtonFontSize = 11; [self getShortcutRect:&shortcutRect hintRect:NULL]; NSString *title = (self.recording ? (_hinting - ? NSLocalizedString(@"Use Old Shortcut", @"Cancel action button for non-empty shortcut in recording state") + ? MASLocalizedString(@"Use Old Shortcut", @"Cancel action button for non-empty shortcut in recording state") : (self.shortcutPlaceholder.length > 0 ? self.shortcutPlaceholder - : NSLocalizedString(@"Type New Shortcut", @"Non-empty shortcut button in recording state"))) + : MASLocalizedString(@"Type New Shortcut", @"Non-empty shortcut button in recording state"))) : _shortcutValue ? _shortcutValue.description : @""); [self drawInRect:shortcutRect withTitle:title alignment:NSCenterTextAlignment state:self.isRecording ? NSOnState : NSOffState]; } @@ -232,15 +232,15 @@ static const CGFloat MASButtonFontSize = 11; CGRect shortcutRect; [self getShortcutRect:&shortcutRect hintRect:NULL]; NSString *title = (_hinting - ? NSLocalizedString(@"Cancel", @"Cancel action button in recording state") + ? MASLocalizedString(@"Cancel", @"Cancel action button in recording state") : (self.shortcutPlaceholder.length > 0 ? self.shortcutPlaceholder - : NSLocalizedString(@"Type Shortcut", @"Empty shortcut button in recording state"))); + : MASLocalizedString(@"Type Shortcut", @"Empty shortcut button in recording state"))); [self drawInRect:shortcutRect withTitle:title alignment:NSCenterTextAlignment state:NSOnState]; } else { - [self drawInRect:self.bounds withTitle:NSLocalizedString(@"Record Shortcut", @"Empty shortcut button in normal state") + [self drawInRect:self.bounds withTitle:MASLocalizedString(@"Record Shortcut", @"Empty shortcut button in normal state") alignment:NSCenterTextAlignment state:NSOffState]; } } @@ -373,10 +373,10 @@ void *kUserDataHint = &kUserDataHint; - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(CGPoint)point userData:(void *)data { if (data == kUserDataShortcut) { - return NSLocalizedString(@"Click to record new shortcut", @"Tooltip for non-empty shortcut button"); + return MASLocalizedString(@"Click to record new shortcut", @"Tooltip for non-empty shortcut button"); } else if (data == kUserDataHint) { - return NSLocalizedString(@"Delete shortcut", @"Tooltip for hint button near the non-empty shortcut"); + return MASLocalizedString(@"Delete shortcut", @"Tooltip for hint button near the non-empty shortcut"); } return nil; } @@ -431,13 +431,13 @@ void *kUserDataHint = &kUserDataHint; // Prevent cancel of recording when Alert window is key [weakSelf activateResignObserver:NO]; [weakSelf activateEventMonitoring:NO]; - NSString *format = NSLocalizedString(@"The key combination %@ cannot be used", + NSString *format = MASLocalizedString(@"The key combination %@ cannot be used", @"Title for alert when shortcut is already used"); NSAlert* alert = [[NSAlert alloc]init]; alert.alertStyle = NSCriticalAlertStyle; alert.informativeText = explanation; alert.messageText = [NSString stringWithFormat:format, shortcut]; - [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Alert button when shortcut is already used")]; + [alert addButtonWithTitle:MASLocalizedString(@"OK", @"Alert button when shortcut is already used")]; [alert runModal]; weakSelf.shortcutPlaceholder = nil; @@ -544,7 +544,7 @@ void *kUserDataHint = &kUserDataHint; - (NSString *)accessibilityHelp { - return NSLocalizedString(@"To record a new shortcut, click this button, and then type the" + return MASLocalizedString(@"To record a new shortcut, click this button, and then type the" @" new shortcut, or press delete to clear an existing shortcut.", @"VoiceOver shortcut help"); } @@ -552,7 +552,7 @@ void *kUserDataHint = &kUserDataHint; - (NSString *)accessibilityLabel { NSString* title = _shortcutValue.description ?: @"Empty"; - title = [title stringByAppendingFormat:@" %@", NSLocalizedString(@"keyboard shortcut", @"VoiceOver title")]; + title = [title stringByAppendingFormat:@" %@", MASLocalizedString(@"keyboard shortcut", @"VoiceOver title")]; return title; } diff --git a/Framework/Prefix.pch b/Framework/Prefix.pch index 3e71c31..ad417e0 100644 --- a/Framework/Prefix.pch +++ b/Framework/Prefix.pch @@ -1,2 +1,3 @@ #import <AppKit/AppKit.h> -#import <Carbon/Carbon.h>
\ No newline at end of file +#import <Carbon/Carbon.h> +#import "MASLocalization.h"
\ No newline at end of file |
