mirror of
https://github.com/tappollo/Xcode-Quick-Localization.git
synced 2026-04-28 18:45:32 +08:00
support for Xcode 5 GM
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
09A343C6174068E600A713EE /* RCXcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A343C5174068E200A713EE /* RCXcode.m */; };
|
09A343C6174068E600A713EE /* RCXcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 09A343C5174068E200A713EE /* RCXcode.m */; };
|
||||||
|
09EC581817E3B6E1002261C4 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 09EC581717E3B6E1002261C4 /* icon.icns */; };
|
||||||
09F65636174041010000486B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09F65635174041010000486B /* AppKit.framework */; };
|
09F65636174041010000486B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09F65635174041010000486B /* AppKit.framework */; };
|
||||||
09F65638174041010000486B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09F65637174041010000486B /* Foundation.framework */; };
|
09F65638174041010000486B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09F65637174041010000486B /* Foundation.framework */; };
|
||||||
09F6563E174041010000486B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 09F6563C174041010000486B /* InfoPlist.strings */; };
|
09F6563E174041010000486B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 09F6563C174041010000486B /* InfoPlist.strings */; };
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
09A343C4174068E200A713EE /* RCXcode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCXcode.h; sourceTree = "<group>"; };
|
09A343C4174068E200A713EE /* RCXcode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCXcode.h; sourceTree = "<group>"; };
|
||||||
09A343C5174068E200A713EE /* RCXcode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCXcode.m; sourceTree = "<group>"; };
|
09A343C5174068E200A713EE /* RCXcode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCXcode.m; sourceTree = "<group>"; };
|
||||||
|
09EC581717E3B6E1002261C4 /* icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = icon.icns; sourceTree = "<group>"; };
|
||||||
09F65632174041010000486B /* QuickLocalization.xcplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QuickLocalization.xcplugin; sourceTree = BUILT_PRODUCTS_DIR; };
|
09F65632174041010000486B /* QuickLocalization.xcplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QuickLocalization.xcplugin; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
09F65635174041010000486B /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
09F65635174041010000486B /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||||
09F65637174041010000486B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
09F65637174041010000486B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
@@ -82,6 +84,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
09F6563B174041010000486B /* QuickLocalization-Info.plist */,
|
09F6563B174041010000486B /* QuickLocalization-Info.plist */,
|
||||||
|
09EC581717E3B6E1002261C4 /* icon.icns */,
|
||||||
09F6563C174041010000486B /* InfoPlist.strings */,
|
09F6563C174041010000486B /* InfoPlist.strings */,
|
||||||
09F65642174041010000486B /* QuickLocalization-Prefix.pch */,
|
09F65642174041010000486B /* QuickLocalization-Prefix.pch */,
|
||||||
);
|
);
|
||||||
@@ -140,6 +143,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
09F6563E174041010000486B /* InfoPlist.strings in Resources */,
|
09F6563E174041010000486B /* InfoPlist.strings in Resources */,
|
||||||
|
09EC581817E3B6E1002261C4 /* icon.icns in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -229,10 +233,11 @@
|
|||||||
09F65646174041010000486B /* Debug */ = {
|
09F65646174041010000486B /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEPLOYMENT_LOCATION = YES;
|
DEPLOYMENT_LOCATION = YES;
|
||||||
DSTROOT = "$(HOME)";
|
DSTROOT = "$(HOME)";
|
||||||
GCC_ENABLE_OBJC_GC = required;
|
GCC_ENABLE_OBJC_GC = unsupported;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "QuickLocalization/QuickLocalization-Prefix.pch";
|
GCC_PREFIX_HEADER = "QuickLocalization/QuickLocalization-Prefix.pch";
|
||||||
INFOPLIST_FILE = "QuickLocalization/QuickLocalization-Info.plist";
|
INFOPLIST_FILE = "QuickLocalization/QuickLocalization-Info.plist";
|
||||||
@@ -246,10 +251,11 @@
|
|||||||
09F65647174041010000486B /* Release */ = {
|
09F65647174041010000486B /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
DEPLOYMENT_LOCATION = YES;
|
DEPLOYMENT_LOCATION = YES;
|
||||||
DSTROOT = "$(HOME)";
|
DSTROOT = "$(HOME)";
|
||||||
GCC_ENABLE_OBJC_GC = required;
|
GCC_ENABLE_OBJC_GC = unsupported;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "QuickLocalization/QuickLocalization-Prefix.pch";
|
GCC_PREFIX_HEADER = "QuickLocalization/QuickLocalization-Prefix.pch";
|
||||||
INFOPLIST_FILE = "QuickLocalization/QuickLocalization-Info.plist";
|
INFOPLIST_FILE = "QuickLocalization/QuickLocalization-Info.plist";
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
|
||||||
|
<false/>
|
||||||
|
<key>IDESourceControlProjectIdentifier</key>
|
||||||
|
<string>1EE47844-8854-4E87-9C9D-9981C6C7EB5C</string>
|
||||||
|
<key>IDESourceControlProjectName</key>
|
||||||
|
<string>QuickLocalization</string>
|
||||||
|
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||||
|
<dict>
|
||||||
|
<key>B1384B3C-CDED-4974-B523-BFBC8D94735C</key>
|
||||||
|
<string>ssh://github.com/nanaimostudio/Xcode-Quick-Localization.git</string>
|
||||||
|
</dict>
|
||||||
|
<key>IDESourceControlProjectPath</key>
|
||||||
|
<string>QuickLocalization.xcodeproj/project.xcworkspace</string>
|
||||||
|
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||||
|
<dict>
|
||||||
|
<key>B1384B3C-CDED-4974-B523-BFBC8D94735C</key>
|
||||||
|
<string>../..</string>
|
||||||
|
</dict>
|
||||||
|
<key>IDESourceControlProjectURL</key>
|
||||||
|
<string>ssh://github.com/nanaimostudio/Xcode-Quick-Localization.git</string>
|
||||||
|
<key>IDESourceControlProjectVersion</key>
|
||||||
|
<integer>110</integer>
|
||||||
|
<key>IDESourceControlProjectWCCIdentifier</key>
|
||||||
|
<string>B1384B3C-CDED-4974-B523-BFBC8D94735C</string>
|
||||||
|
<key>IDESourceControlProjectWCConfigurations</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||||
|
<string>public.vcs.git</string>
|
||||||
|
<key>IDESourceControlWCCIdentifierKey</key>
|
||||||
|
<string>B1384B3C-CDED-4974-B523-BFBC8D94735C</string>
|
||||||
|
<key>IDESourceControlWCCName</key>
|
||||||
|
<string>Xcode-Quick-Localization</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>${EXECUTABLE_NAME}</string>
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string></string>
|
<string>icon.icns</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>com.nanaimostudio.${PRODUCT_NAME:rfc1034identifier}</string>
|
<string>com.nanaimostudio.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
@@ -22,11 +22,34 @@
|
|||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1</string>
|
<string>1</string>
|
||||||
|
<key>CFPlugInDynamicRegisterFunction</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFPlugInDynamicRegistration</key>
|
||||||
|
<string>NO</string>
|
||||||
|
<key>CFPlugInFactories</key>
|
||||||
|
<dict>
|
||||||
|
<key>00000000-0000-0000-0000-000000000000</key>
|
||||||
|
<string>MyFactoryFunction</string>
|
||||||
|
</dict>
|
||||||
|
<key>CFPlugInTypes</key>
|
||||||
|
<dict>
|
||||||
|
<key>00000000-0000-0000-0000-000000000000</key>
|
||||||
|
<array>
|
||||||
|
<string>00000000-0000-0000-0000-000000000000</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>CFPlugInUnloadFunction</key>
|
||||||
|
<string></string>
|
||||||
<key>XC4Compatible</key>
|
<key>XC4Compatible</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>XCGCReady</key>
|
<key>XCGCReady</key>
|
||||||
<true/>
|
<false/>
|
||||||
<key>XCPluginHasUI</key>
|
<key>XCPluginHasUI</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>DVTPlugInCompatibilityUUIDs</key>
|
||||||
|
<array>
|
||||||
|
<string>63FC1C47-140D-42B0-BB4D-A10B2D225574</string>
|
||||||
|
<string>37B30044-3B14-46BA-ABAA-F01000C27B63</string>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ static NSString *localizeRegexs[] = {
|
|||||||
};
|
};
|
||||||
static NSString *stringRegexs = @"@\"[^\"]*\"";
|
static NSString *stringRegexs = @"@\"[^\"]*\"";
|
||||||
@implementation QuickLocalization
|
@implementation QuickLocalization
|
||||||
|
static id sharedPlugin = nil;
|
||||||
|
|
||||||
|
|
||||||
+ (void)pluginDidLoad:(NSBundle *)plugin {
|
+ (void)pluginDidLoad:(NSBundle *)plugin {
|
||||||
static id sharedPlugin = nil;
|
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
sharedPlugin = [[self alloc] init];
|
sharedPlugin = [[self alloc] init];
|
||||||
@@ -29,26 +29,18 @@ static NSString *stringRegexs = @"@\"[^\"]*\"";
|
|||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
NSMenuItem *viewMenuItem = [[NSApp mainMenu] itemWithTitle:@"Edit"];
|
||||||
selector:@selector(applicationDidFinishLaunching:)
|
if (viewMenuItem) {
|
||||||
name:NSApplicationDidFinishLaunchingNotification
|
[[viewMenuItem submenu] addItem:[NSMenuItem separatorItem]];
|
||||||
object:nil];
|
NSMenuItem *sample = [[NSMenuItem alloc] initWithTitle:@"Quick Localization" action:@selector(quickLocalization) keyEquivalent:@"d"];
|
||||||
|
[sample setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
|
||||||
|
[sample setTarget:self];
|
||||||
|
[[viewMenuItem submenu] addItem:sample];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
|
|
||||||
NSMenuItem *viewMenuItem = [[NSApp mainMenu] itemWithTitle:@"Edit"];
|
|
||||||
if (viewMenuItem) {
|
|
||||||
[[viewMenuItem submenu] addItem:[NSMenuItem separatorItem]];
|
|
||||||
NSMenuItem *sample = [[NSMenuItem alloc] initWithTitle:@"Quick Localization" action:@selector(quickLocalization) keyEquivalent:@"c"];
|
|
||||||
[sample setKeyEquivalentModifierMask:NSCommandKeyMask | NSShiftKeyMask];
|
|
||||||
[sample setTarget:self];
|
|
||||||
[[viewMenuItem submenu] addItem:sample];
|
|
||||||
[sample release];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sample Action, for menu item:
|
// Sample Action, for menu item:
|
||||||
- (void)quickLocalization {
|
- (void)quickLocalization {
|
||||||
IDESourceCodeDocument *document = [RCXcode currentSourceCodeDocument];
|
IDESourceCodeDocument *document = [RCXcode currentSourceCodeDocument];
|
||||||
@@ -64,10 +56,10 @@ static NSString *stringRegexs = @"@\"[^\"]*\"";
|
|||||||
NSRange lineRange = [textView.textStorage.string lineRangeForRange:range];
|
NSRange lineRange = [textView.textStorage.string lineRangeForRange:range];
|
||||||
NSString *line = [textView.textStorage.string substringWithRange:lineRange];
|
NSString *line = [textView.textStorage.string substringWithRange:lineRange];
|
||||||
|
|
||||||
NSRegularExpression *localizedRex = [[[NSRegularExpression alloc] initWithPattern:localizeRegexs[0] options:NSRegularExpressionCaseInsensitive error:nil] autorelease];
|
NSRegularExpression *localizedRex = [[NSRegularExpression alloc] initWithPattern:localizeRegexs[0] options:NSRegularExpressionCaseInsensitive error:nil];
|
||||||
NSArray *localizedMatches = [localizedRex matchesInString:line options:0 range:NSMakeRange(0, [line length])];
|
NSArray *localizedMatches = [localizedRex matchesInString:line options:0 range:NSMakeRange(0, [line length])];
|
||||||
|
|
||||||
NSRegularExpression *regex = [[[NSRegularExpression alloc] initWithPattern:stringRegexs options:NSRegularExpressionCaseInsensitive error:nil] autorelease];
|
NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:stringRegexs options:NSRegularExpressionCaseInsensitive error:nil];
|
||||||
NSArray *matches = [regex matchesInString:line options:0 range:NSMakeRange(0, [line length])];
|
NSArray *matches = [regex matchesInString:line options:0 range:NSMakeRange(0, [line length])];
|
||||||
NSUInteger addedLength = 0;
|
NSUInteger addedLength = 0;
|
||||||
for (int i = 0; i < [matches count]; i++) {
|
for (int i = 0; i < [matches count]; i++) {
|
||||||
@@ -83,7 +75,7 @@ static NSString *stringRegexs = @"@\"[^\"]*\"";
|
|||||||
addedLength = addedLength + outputString.length - string.length;
|
addedLength = addedLength + outputString.length - string.length;
|
||||||
if ([textView shouldChangeTextInRange:matchedRangeInDocument replacementString:outputString]) {
|
if ([textView shouldChangeTextInRange:matchedRangeInDocument replacementString:outputString]) {
|
||||||
[textView.textStorage replaceCharactersInRange:matchedRangeInDocument
|
[textView.textStorage replaceCharactersInRange:matchedRangeInDocument
|
||||||
withAttributedString:[[[NSAttributedString alloc] initWithString:outputString] autorelease]];
|
withAttributedString:[[NSAttributedString alloc] initWithString:outputString]];
|
||||||
[textView didChangeText];
|
[textView didChangeText];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,9 +97,4 @@ static NSString *stringRegexs = @"@\"[^\"]*\"";
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
BIN
QuickLocalization/icon.icns
Normal file
BIN
QuickLocalization/icon.icns
Normal file
Binary file not shown.
@@ -7,7 +7,7 @@ Xcode Plugin to Convert @"content" to NSLocalizedString(@"content", @"content")
|
|||||||
How To Use
|
How To Use
|
||||||
==========
|
==========
|
||||||
|
|
||||||
Select any line in xcode, press command + shift + c. String will be converted to localized string.
|
Select any line in xcode, press option + shift + d. String will be converted to localized string.
|
||||||
|
|
||||||
You can also access it under Edit -> Quick Localization
|
You can also access it under Edit -> Quick Localization
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user