Skip to content

Commit

Permalink
localizable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed Nov 9, 2018
1 parent ef72f03 commit fd0f92f
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 80 deletions.
20 changes: 16 additions & 4 deletions ProfilesManager.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
B804236A2192BD9100AD899F /* GitHubInstallWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B80423542192BD9000AD899F /* GitHubInstallWindowController.m */; };
B804236B2192BD9100AD899F /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B80423592192BD9000AD899F /* Info.plist */; };
B80FCFC31E4AAE480044098D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = B80FCFC51E4AAE480044098D /* Localizable.strings */; };
B81B6A782195470500A8580F /* ProfilesManagerWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B81B6A7A2195470500A8580F /* ProfilesManagerWindowController.xib */; };
B843F36E20897BAD00C1679C /* ProfilesManagerWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B843F36C20897BAD00C1679C /* ProfilesManagerWindowController.m */; };
B843F36F20897BAD00C1679C /* ProfilesManagerWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B843F36D20897BAD00C1679C /* ProfilesManagerWindowController.xib */; };
B8BCD2401E6CEFCB00ABD2A6 /* iAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BCD23F1E6CEFCB00ABD2A6 /* iAlert.m */; };
B8C823BE1E0288D9004BEAEF /* NSData+JKBase64.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C823BD1E0288D8004BEAEF /* NSData+JKBase64.m */; };
B8F694BB204D3ADF0048F3E6 /* PreviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F694B9204D3ADF0048F3E6 /* PreviewViewController.m */; };
Expand Down Expand Up @@ -99,12 +99,14 @@
B804235A2192BD9000AD899F /* GitHubRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitHubRelease.h; sourceTree = "<group>"; };
B80FCFC41E4AAE480044098D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
B80FCFC71E4AAE560044098D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
B81B6A7B2195470A00A8580F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ProfilesManagerWindowController.xib; sourceTree = "<group>"; };
B81B6A7D2195471400A8580F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ProfilesManagerWindowController.strings; sourceTree = "<group>"; };
B81B6A7E2195472500A8580F /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/ProfilesManagerWindowController.strings"; sourceTree = "<group>"; };
B8329CA91E4B1F7900D589F6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
B833BA561E4B1C36003FF745 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/MainMenu.strings; sourceTree = "<group>"; };
B833BA571E4B1C5C003FF745 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/MainMenu.strings"; sourceTree = "<group>"; };
B843F36B20897BAD00C1679C /* ProfilesManagerWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProfilesManagerWindowController.h; sourceTree = "<group>"; };
B843F36C20897BAD00C1679C /* ProfilesManagerWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProfilesManagerWindowController.m; sourceTree = "<group>"; };
B843F36D20897BAD00C1679C /* ProfilesManagerWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProfilesManagerWindowController.xib; sourceTree = "<group>"; };
B856B7801E25EDC800060107 /* ProfilesManager.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProfilesManager.entitlements; sourceTree = "<group>"; };
B8BCD23E1E6CEFCB00ABD2A6 /* iAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iAlert.h; sourceTree = "<group>"; };
B8BCD23F1E6CEFCB00ABD2A6 /* iAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iAlert.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -209,7 +211,7 @@
B8F694BA204D3ADF0048F3E6 /* PreviewViewController.xib */,
B843F36B20897BAD00C1679C /* ProfilesManagerWindowController.h */,
B843F36C20897BAD00C1679C /* ProfilesManagerWindowController.m */,
B843F36D20897BAD00C1679C /* ProfilesManagerWindowController.xib */,
B81B6A7A2195470500A8580F /* ProfilesManagerWindowController.xib */,
);
path = Controller;
sourceTree = "<group>";
Expand Down Expand Up @@ -396,7 +398,7 @@
B804235C2192BD9100AD899F /* Install.pdf in Resources */,
B804236B2192BD9100AD899F /* Info.plist in Resources */,
A21193271AF1CA5B0064CA7D /* MainMenu.xib in Resources */,
B843F36F20897BAD00C1679C /* ProfilesManagerWindowController.xib in Resources */,
B81B6A782195470500A8580F /* ProfilesManagerWindowController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -474,6 +476,16 @@
name = Localizable.strings;
sourceTree = "<group>";
};
B81B6A7A2195470500A8580F /* ProfilesManagerWindowController.xib */ = {
isa = PBXVariantGroup;
children = (
B81B6A7B2195470A00A8580F /* Base */,
B81B6A7D2195471400A8580F /* en */,
B81B6A7E2195472500A8580F /* zh-Hans */,
);
name = ProfilesManagerWindowController.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
1 change: 1 addition & 0 deletions ProfilesManager/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ @implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

_window = [[ProfilesManagerWindowController alloc] initWithWindowNibName:@"ProfilesManagerWindowController"];
_window.contentViewController = [[ProfilesManagerViewController alloc] initWithNibName:@"ProfilesManagerViewController" bundle:[NSBundle bundleForClass:[self class]]];
[_window.window orderFront:nil];
Expand Down
21 changes: 11 additions & 10 deletions ProfilesManager/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
Copyright © 2017年 Jakey. All rights reserved.
*/

"move to trash" = "move to trash";
"delete" = "delete";
"show in finder" = "show in finder";
"refresh table" = "refresh";
"import profile" = "import profile";
"export certificate file" = "export certificate file";
"expired" = "expired";
"valid" = "valid";
"Move to trash" = "Move to trash";
"Delete" = "Delete";
"Show in finder" = "Show in finder";
"Refresh table" = "Refresh";
"Import profile" = "Import Profile";
"Export Certificate File" = "Export Certificate File";
"Expired" = "Expired";
"Valid" = "Valid";
"Ok" = "Ok";
"Cancel" = "Cancel";
"Cancle" = "Cancle";
"Confirm Delete Opration" = "Confirm Delete Opration";
"Delete this profie item permanently,can't rollback!" = "Delete this profie item permanently,can't rollback!";
"Warning" = "Warning";
"are you sure move item to trash?" = "are you sure move item to trash?";
"export" = "export";
"Export" = "Export";
"Beautify Filename" = "Beautify Filename";
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@
</textFieldCell>
</textField>
</toolbarItem>
<toolbarItem implicitItemIdentifier="70E91DEC-358C-4E92-B3C3-750F0C3199B0" label="" paletteLabel="" id="7K3-qP-Fsk">
<nil key="toolTip"/>
<size key="minSize" width="38" height="17"/>
<size key="maxSize" width="100" height="17"/>
<textField key="view" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="0Ux-9r-7iC">
<rect key="frame" x="0.0" y="14" width="100" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Order By:" id="aPR-eb-uj1">
<font key="font" size="13" name=".PingFangSC-Regular"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</toolbarItem>
<toolbarItem implicitItemIdentifier="063C2AD9-E683-468A-8D1F-055105A2C4C4" label="" paletteLabel="" id="TqD-HL-i0O">
<nil key="toolTip"/>
<size key="minSize" width="96" height="22"/>
Expand Down
107 changes: 78 additions & 29 deletions ProfilesManager/Controller/ProfilesManagerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(NSTextFieldCel
}else{
cell.textColor = [NSColor darkGrayColor];
if ([[tableColumn identifier] isEqualToString:kColumnIdentifierDetal]) {
if ([realItem.detail isEqualToString:@"expired"]) {
if ([realItem.detail isEqualToString:@"Expired"] ||[realItem.detail isEqualToString:@"过期"] ) {
cell.textColor = [NSColor redColor];
}
}
Expand Down Expand Up @@ -250,49 +250,57 @@ - (void)menuWillOpen:(NSMenu *)menu
NSMenuItem *gotoItemName = [menu itemWithTag:1002];
if (!gotoItemName)
{
gotoItemName = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"show in finder",nil) action:@selector(gotoClick:) keyEquivalent:@""];
gotoItemName = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Show in Finder",nil) action:@selector(gotoClick:) keyEquivalent:@""];
[gotoItemName setTarget:self];
[gotoItemName setTag:1002];
[menu addItem:gotoItemName];
}
NSMenuItem *moveTrashItem = [menu itemWithTag:1000];
if (!moveTrashItem)
{
moveTrashItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"move to trash",nil) action:@selector(moveTrashItemClick:) keyEquivalent:@""];
moveTrashItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Move to Trash",nil) action:@selector(moveTrashItemClick:) keyEquivalent:@""];
[moveTrashItem setTarget:self];
[moveTrashItem setTag:1000];
[menu addItem:moveTrashItem];
}
NSMenuItem *deleteItem = [menu itemWithTag:1001];
if (!deleteItem)
{
deleteItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"delete",nil) action:@selector(deleteItemClick:) keyEquivalent:@""];
deleteItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Delete",nil) action:@selector(deleteItemClick:) keyEquivalent:@""];
[deleteItem setTarget:self];
[deleteItem setTag:1001];
[menu addItem:deleteItem];
}
NSMenuItem *exportItem = [menu itemWithTag:1003];
if (!exportItem)
{
exportItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"export",nil) action:@selector(exportItemClick:) keyEquivalent:@""];
exportItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Export",nil) action:@selector(exportItemClick:) keyEquivalent:@""];
[exportItem setTarget:self];
[exportItem setTag:1003];
[menu addItem:exportItem];
}
// NSMenuItem *renameItem = [menu itemWithTag:1004];
// if (!renameItem)
// {
// renameItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Beautify Filename",nil) action:@selector(renameItemClick:) keyEquivalent:@""];
// [renameItem setTarget:self];
// [renameItem setTag:1004];
// [menu addItem:renameItem];
// }
}
if(menu == _mainMenu){
NSMenuItem *refreshItem = [menu itemWithTag:2000];
if (!refreshItem)
{
refreshItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"refresh table",nil) action:@selector(refreshItemClick:) keyEquivalent:@""];
refreshItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Refresh Table",nil) action:@selector(refreshItemClick:) keyEquivalent:@""];
[refreshItem setTarget:self];
[refreshItem setTag:2000];
[menu addItem:refreshItem];
}
NSMenuItem *importItem = [menu itemWithTag:2001];
if (!importItem)
{
importItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"import profile",nil) action:@selector(importItemClick:) keyEquivalent:@""];
importItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Import Profile",nil) action:@selector(importItemClick:) keyEquivalent:@""];
[importItem setTarget:self];
[importItem setTag:2001];
[menu addItem:importItem];
Expand All @@ -302,7 +310,7 @@ - (void)menuWillOpen:(NSMenu *)menu
NSMenuItem *exportItem = [menu itemWithTag:3001];
if (!exportItem)
{
exportItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"export certificate file",nil) action:@selector(exportCerItemClick:) keyEquivalent:@""];
exportItem = [[NSMenuItem alloc] initWithTitle:JKLocalizedString(@"Export Certificate File",nil) action:@selector(exportCerItemClick:) keyEquivalent:@""];
[exportItem setTarget:self];
[exportItem setTag:3001];
[menu addItem:exportItem];
Expand All @@ -317,7 +325,7 @@ - (void)deleteItemClick:(id)sender
NSInteger index = [self.treeView clickedRow];
ProfilesNode *node = [self.treeView itemAtRow:index];

iAlert *alert = [iAlert alertWithTitle:JKLocalizedString(@"Confirm Delete Opration",nil) message:JKLocalizedString(@"Delete this profie item permanently,can't rollback!",nil) style:NSAlertStyleWarning];
iAlert *alert = [iAlert alertWithTitle:[NSString stringWithFormat:@"%@,%@",JKLocalizedString(@"Confirm Delete Opration",nil),node.type] message:JKLocalizedString(@"Delete this profie item permanently,can't rollback!",nil) style:NSAlertStyleWarning];
[alert addCommonButtonWithTitle:JKLocalizedString(@"Ok", nil) handler:^(iAlertItem *item) {
NSLog(@"deleteItem inde%zd",index);
if (index == -1) return;
Expand All @@ -327,7 +335,7 @@ - (void)deleteItemClick:(id)sender
[self.treeView endUpdates];

[self deleteProfile:node.filePath option:YES];
[self loadProfileFilesWithSearchWord:_searchWord];
// [self loadProfileFilesWithSearchWord:_searchWord];
}];
[alert addButtonWithTitle:JKLocalizedString(@"Cancle", nil)];
[alert show:self.view.window];
Expand All @@ -350,28 +358,11 @@ - (void)moveTrashItemClick:(id)sender{
[self deleteProfile:node.filePath option:NO];
[self loadProfileFilesWithSearchWord:_searchWord];
}];

[alert addButtonWithTitle:JKLocalizedString(@"Cancle", nil)];
[alert show:self.view.window];
}

//delete and move
- (BOOL)deleteProfile:(NSString*)filePath option:(BOOL)totle{
NSError *error;
BOOL result = NO;
if (totle) {
result = [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error];

}else{
result = [[NSFileManager defaultManager] mr_moveFileAtPathToTrash:filePath error:&error];
}
if(error)
{
[self showMessage:[error localizedDescription] completionHandler:^(NSModalResponse returnCode) {

}];
}
return result;
}

//goto
- (void)gotoClick:(id)sender
Expand All @@ -387,7 +378,25 @@ - (void)gotoClick:(id)sender
[[NSWorkspace sharedWorkspace] selectFile:node.filePath inFileViewerRootedAtPath:@""];
}
}

////beautify filename
//- (void)renameItemClick:(id)sender{
// NSInteger index = [self.treeView clickedRow];
// ProfilesNode *node = [self.treeView itemAtRow:index];
//
// iAlert *alert = [iAlert alertWithTitle:JKLocalizedString(@"Warning",nil) message:JKLocalizedString(@"are you sure rename profile filename ?",nil) style:NSAlertStyleWarning];
// [alert addCommonButtonWithTitle:JKLocalizedString(@"Ok", nil) handler:^(iAlertItem *item) {
//
// if (index == -1) return;
// if ([self renameFileAtPath:node.filePath toName:node.type]) {
// [self.treeView beginUpdates];
// [self.treeView reloadItem:node];
// [self.treeView endUpdates];
// }
// }];
//
// [alert addButtonWithTitle:JKLocalizedString(@"Cancle", nil)];
// [alert show:self.view.window];
//}
//export Item to file
- (void)exportItemClick:(id)sender {
NSInteger index = [self.treeView clickedRow];
Expand Down Expand Up @@ -461,7 +470,47 @@ - (void)exportCerItemClick:(id)sender

}
}
#pragma mark --filemanager

//delete and move
- (BOOL)deleteProfile:(NSString*)filePath option:(BOOL)totle{
NSError *error;
BOOL result = NO;
if (totle) {
result = [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error];

}else{
result = [[NSFileManager defaultManager] mr_moveFileAtPathToTrash:filePath error:&error];
}
if(error)
{
[self showMessage:[error localizedDescription] completionHandler:^(NSModalResponse returnCode) {

}];
}
return result;
}

//-(BOOL)renameFileAtPath:(NSString *)oldPath toName:(NSString *)toName {
// BOOL result = NO;
// NSError * error = nil;
// NSString *toPath = [[[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:toName] stringByAppendingPathExtension:@"mobileprovision"];
//
// NSString *tempFolder = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"temp"];
// if (![[NSFileManager defaultManager] fileExistsAtPath:tempFolder]) {
// [[NSFileManager defaultManager] createDirectoryAtPath:tempFolder withIntermediateDirectories:YES attributes:nil error:nil];
// }
// NSString *tempPath = [tempFolder stringByAppendingPathComponent:oldPath.lastPathComponent];
//
// result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:oldPath] toURL:[NSURL fileURLWithPath:tempPath] error:&error];
//
// result = [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:tempPath] toURL:[NSURL fileURLWithPath:toPath] error:&error];
//
// if (error){ NSLog(@"重命名失败:%@",[error localizedDescription]);
//
// }
// return result;
//}
#pragma mark --alert
- (void)showMessage:(NSString*)message completionHandler:(void (^)(NSModalResponse returnCode))handler{
NSAlert *alert = [[NSAlert alloc] init];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/* Class = "NSTextFieldCell"; placeholderString = "input search keyword"; ObjectID = "Dgc-Gr-MVo"; */
"Dgc-Gr-MVo.placeholderString" = "input search keyword";

/* Class = "NSWindow"; title = "ProfileManager"; ObjectID = "F0z-JX-Cv5"; */
"F0z-JX-Cv5.title" = "ProfileManager";

/* Class = "NSToolbarItem"; label = "Refresh"; ObjectID = "RbJ-X4-SVv"; */
"RbJ-X4-SVv.label" = "Refresh";

/* Class = "NSToolbarItem"; paletteLabel = "Refresh"; ObjectID = "RbJ-X4-SVv"; */
"RbJ-X4-SVv.paletteLabel" = "Refresh";

/* Class = "NSTextField"; ibShadowedToolTip = "search keyword"; ObjectID = "t6d-rt-sJV"; */
"t6d-rt-sJV.ibShadowedToolTip" = "search keyword";

/* Class = "NSTextFieldCell"; title = "Search & Filter:"; ObjectID = "xoe-JW-DJi"; */
"xoe-JW-DJi.title" = "Search & Filter:";
Loading

0 comments on commit fd0f92f

Please sign in to comment.