Makes it able to reload user phrases.

This commit is contained in:
zonble 2022-01-09 21:53:45 +08:00 committed by Lukhnos Liu
parent e909dc20b5
commit a5247d958c
3 changed files with 23 additions and 7 deletions

View File

@ -233,9 +233,14 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
chineseConversionMenuItem.state = _chineseConversionEnabled ? NSControlStateValueOn : NSControlStateValueOff;
[menu addItem:chineseConversionMenuItem];
if (_inputMode != kPlainBopomofoModeIdentifier) {
NSMenuItem *editUserPhraseItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Edit User Phrases", @"") action:@selector(openUserPhrases:) keyEquivalent:@""];
[menu addItem:editUserPhraseItem];
NSMenuItem *reloadUserPhraseItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Reload User Phrases", @"") action:@selector(reloadUserPhrases:) keyEquivalent:@""];
[menu addItem:reloadUserPhraseItem];
}
NSMenuItem *updateCheckItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Check for Updates…", @"") action:@selector(checkForUpdate:) keyEquivalent:@""];
[menu addItem:updateCheckItem];
@ -666,6 +671,8 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
NSData *data = [currentMarkedPhrase dataUsingEncoding:NSUTF8StringEncoding];
[file writeData:data];
[file closeFile];
LTLoadUserLanguageModelFile();
return YES;
}
@ -1550,11 +1557,11 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
}
NSURL *url = [NSURL fileURLWithPath:path];
[[NSWorkspace sharedWorkspace] openURL:url];
// NSWorkspaceOpenConfiguration *config = [NSWorkspaceOpenConfiguration configuration];
// [[NSWorkspace sharedWorkspace] openURL:url configuration:config completionHandler:^(NSRunningApplication * app, NSError * error) {
// NSLog(@"app %@", app);
// NSLog(@"error %@", error);
// }];
}
- (void)reloadUserPhrases:(id)sender
{
LTLoadUserLanguageModelFile();
}
- (void)showAbout:(id)sender

View File

@ -50,3 +50,7 @@
"You're currently using McBopomofo %@ (%@), a new version %@ (%@) is now available. Do you want to visit McBopomofo's website to download the version?%@" = "You're currently using McBopomofo %@ (%@), a new version %@ (%@) is now available. Do you want to visit McBopomofo's website to download the version?%@";
"Chinese Conversion" = "Convert to Simplified Chinese";
"Edit User Phrases" = "Edit User Phrases";
"Reload User Phrases" = "Reload User Phrases";

View File

@ -50,3 +50,8 @@
"You're currently using McBopomofo %@ (%@), a new version %@ (%@) is now available. Do you want to visit McBopomofo's website to download the version?%@" = "目前使用的小麥注音版本是 %1$@ (%2$@),網路上有更新版本 %3$@ (%4$@) 可供下載。是否要前往小麥注音網站下載新版來安裝?%5$@";
"Chinese Conversion" = "輸出簡體中文";
"Edit User Phrases" = "編輯使用者詞彙";
"Reload User Phrases" = "重新載入使用者詞彙";