cc-pets 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/CHANGELOG.zh-CN.md +42 -0
- package/CONTRIBUTING.md +68 -0
- package/CONTRIBUTING.zh-CN.md +56 -0
- package/README.md +47 -31
- package/README.zh-CN.md +39 -20
- package/Resources/Info.plist +3 -1
- package/Resources/en.lproj/InfoPlist.strings +1 -0
- package/Resources/phrases.default.en.txt +182 -0
- package/Resources/zh-Hans.lproj/InfoPlist.strings +1 -0
- package/Resources/zh-Hans.lproj/Localizable.strings +337 -0
- package/Sources/CCPets/CCPetsAppDelegate+AgentStatus.m +35 -36
- package/Sources/CCPets/CCPetsAppDelegate+Bridge.m +16 -14
- package/Sources/CCPets/CCPetsAppDelegate+Pets.m +8 -10
- package/Sources/CCPets/CCPetsAppDelegate+Private.h +33 -9
- package/Sources/CCPets/CCPetsAppDelegate+Settings.m +84 -8
- package/Sources/CCPets/CCPetsAppDelegate+Speech.m +7 -5
- package/Sources/CCPets/CCPetsAppDelegate+Update.m +104 -79
- package/Sources/CCPets/CCPetsAppDelegate.h +1 -2
- package/Sources/CCPets/CCPetsAppDelegate.m +23 -15
- package/Sources/CCPets/CCPetsCleanup.m +9 -6
- package/Sources/CCPets/CCPetsEvents.m +4 -3
- package/Sources/CCPets/CCPetsImageLoader.h +2 -1
- package/Sources/CCPets/CCPetsImageLoader.m +10 -2
- package/Sources/CCPets/CCPetsL10n.h +55 -0
- package/Sources/CCPets/CCPetsL10n.m +219 -0
- package/Sources/CCPets/CCPetsPetSize.h +10 -0
- package/Sources/CCPets/CCPetsPetSize.m +21 -0
- package/Sources/CCPets/CCPetsPhrases.h +14 -1
- package/Sources/CCPets/CCPetsPhrases.m +107 -38
- package/Sources/CCPets/CCPetsPhrasesEditor.m +100 -65
- package/Sources/CCPets/CCPetsPreviews.m +7 -6
- package/Sources/CCPets/CCPetsVersion.h +7 -4
- package/Sources/CCPets/CCPetsVersion.m +14 -6
- package/Sources/CCPets/MenuChoiceRow.m +3 -0
- package/Sources/CCPets/MenuPetSizeView.h +5 -0
- package/Sources/CCPets/MenuPetSizeView.m +73 -0
- package/Sources/CCPets/MenuToggleSwitch.m +3 -2
- package/Sources/CCPets/PetView.m +156 -94
- package/Sources/CCPets/QuotaDashboardView.m +122 -85
- package/Sources/CCPets/main.m +3 -1
- package/bin/cc-pets +21 -22
- package/bin/claude-with-pet +2 -1
- package/bin/codex-with-pet +2 -1
- package/package.json +3 -2
- package/scripts/bridge/cli.mjs +39 -38
- package/scripts/bridge/core.mjs +27 -26
- package/scripts/bridge/hook.mjs +7 -6
- package/scripts/bridge/install.mjs +24 -23
- package/scripts/bridge/mcp-server.mjs +79 -71
- package/scripts/bridge/options.mjs +7 -6
- package/scripts/bridge/reservations.mjs +6 -5
- package/scripts/bridge/store.mjs +10 -9
- package/scripts/build.sh +24 -5
- package/scripts/check-l10n.mjs +168 -0
- package/scripts/configure-updater.mjs +4 -3
- package/scripts/doctor.mjs +93 -79
- package/scripts/i18n.mjs +122 -0
- package/scripts/i18n.zsh +66 -0
- package/scripts/install-app.sh +3 -2
- package/scripts/install-claude-hooks.mjs +10 -9
- package/scripts/install-codex-hooks.mjs +7 -6
- package/scripts/install-shell-integration.sh +6 -5
- package/scripts/locales/zh-Hans.json +366 -0
- package/scripts/pet-store.mjs +45 -44
- package/scripts/uninstall-app.sh +4 -3
- package/scripts/uninstall-integrations.mjs +8 -7
- package/scripts/uninstall-shell-integration.sh +8 -7
- /package/Resources/{phrases.default.txt → phrases.default.zh-Hans.txt} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "CCPetsPhrasesEditor.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
#import "CCPetsPhrases.h"
|
|
3
4
|
|
|
4
5
|
static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
@@ -7,6 +8,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
7
8
|
@property NSTextView *textView;
|
|
8
9
|
@property NSPopUpButton *tagPicker;
|
|
9
10
|
@property NSTextField *statusLabel;
|
|
11
|
+
@property NSButton *speakButton;
|
|
10
12
|
@property NSButton *saveButton;
|
|
11
13
|
@property NSButton *saveAndCloseButton;
|
|
12
14
|
@property NSButton *revertButton;
|
|
@@ -41,6 +43,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
41
43
|
PetPhrasesEditorController *controller = [self shared];
|
|
42
44
|
[controller buildWindowIfNeeded];
|
|
43
45
|
[controller syncScopeToCurrentPet];
|
|
46
|
+
[controller refreshLocalizedUI];
|
|
44
47
|
[controller reloadFromDisk];
|
|
45
48
|
[NSApp activateIgnoringOtherApps:YES];
|
|
46
49
|
[controller.window makeKeyAndOrderFront:nil];
|
|
@@ -56,7 +59,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
56
59
|
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
|
57
60
|
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
|
|
58
61
|
backing:NSBackingStoreBuffered defer:NO];
|
|
59
|
-
window.title = @"
|
|
62
|
+
window.title = L(@"Pet Lines");
|
|
60
63
|
window.releasedWhenClosed = NO;
|
|
61
64
|
window.minSize = NSMakeSize(460, 400);
|
|
62
65
|
[window center];
|
|
@@ -101,37 +104,38 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
101
104
|
NSPopUpButton *picker = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO];
|
|
102
105
|
picker.translatesAutoresizingMaskIntoConstraints = NO;
|
|
103
106
|
for (NSString *tag in PetPhraseAllTags()) {
|
|
104
|
-
[picker addItemWithTitle:[NSString stringWithFormat
|
|
107
|
+
[picker addItemWithTitle:[NSString stringWithFormat:L(@"%1$@ (%2$@)"),
|
|
105
108
|
PetPhraseTagDescription(tag), tag]];
|
|
106
109
|
picker.lastItem.representedObject = tag;
|
|
107
110
|
}
|
|
108
111
|
self.tagPicker = picker;
|
|
109
112
|
|
|
110
|
-
NSButton *speak = [NSButton buttonWithTitle
|
|
113
|
+
NSButton *speak = [NSButton buttonWithTitle:L(@"Try a Line") target:self
|
|
111
114
|
action:@selector(speakSample:)];
|
|
112
115
|
speak.translatesAutoresizingMaskIntoConstraints = NO;
|
|
116
|
+
self.speakButton = speak;
|
|
113
117
|
|
|
114
|
-
NSButton *save = [NSButton buttonWithTitle
|
|
118
|
+
NSButton *save = [NSButton buttonWithTitle:L(@"Save") target:self action:@selector(save:)];
|
|
115
119
|
// ⌘S 而不是回车:这是个多行文本编辑器,回车要用来换行。
|
|
116
120
|
save.keyEquivalent = @"s";
|
|
117
121
|
save.keyEquivalentModifierMask = NSEventModifierFlagCommand;
|
|
118
122
|
save.translatesAutoresizingMaskIntoConstraints = NO;
|
|
119
123
|
self.saveButton = save;
|
|
120
124
|
|
|
121
|
-
NSButton *saveAndClose = [NSButton buttonWithTitle
|
|
125
|
+
NSButton *saveAndClose = [NSButton buttonWithTitle:L(@"Save & Close") target:self
|
|
122
126
|
action:@selector(saveAndClose:)];
|
|
123
127
|
saveAndClose.keyEquivalent = @"\r";
|
|
124
128
|
saveAndClose.translatesAutoresizingMaskIntoConstraints = NO;
|
|
125
129
|
self.saveAndCloseButton = saveAndClose;
|
|
126
130
|
|
|
127
|
-
NSButton *revert = [NSButton buttonWithTitle
|
|
131
|
+
NSButton *revert = [NSButton buttonWithTitle:L(@"Restore Defaults…") target:self
|
|
128
132
|
action:@selector(revertToDefault:)];
|
|
129
133
|
revert.translatesAutoresizingMaskIntoConstraints = NO;
|
|
130
134
|
self.revertButton = revert;
|
|
131
135
|
|
|
132
136
|
// 两段式而不是下拉菜单:一共就两个去处,而且"我现在改的是哪一份"必须一眼可见——
|
|
133
137
|
// 藏进下拉里的话,用户很容易把只想给一只宠物写的台词存进通用词库。
|
|
134
|
-
NSSegmentedControl *scope = [NSSegmentedControl segmentedControlWithLabels:@[@"
|
|
138
|
+
NSSegmentedControl *scope = [NSSegmentedControl segmentedControlWithLabels:@[L(@"Shared"), L(@"This Pet")]
|
|
135
139
|
trackingMode:NSSegmentSwitchTrackingSelectOne target:self action:@selector(scopeChanged:)];
|
|
136
140
|
scope.translatesAutoresizingMaskIntoConstraints = NO;
|
|
137
141
|
scope.selectedSegment = 0;
|
|
@@ -140,7 +144,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
140
144
|
// 专属页初次打开是空白的——空白在语义上是对的(全部回落到通用),但一个空白文本框
|
|
141
145
|
// 不告诉任何人该往里写什么。这个按钮就是那个起点:把默认台词整份填进来,
|
|
142
146
|
// 用户在上面改字、删掉不想接管的小节即可。
|
|
143
|
-
NSButton *fill = [NSButton buttonWithTitle
|
|
147
|
+
NSButton *fill = [NSButton buttonWithTitle:L(@"Insert Template") target:self
|
|
144
148
|
action:@selector(fillFromDefault:)];
|
|
145
149
|
fill.translatesAutoresizingMaskIntoConstraints = NO;
|
|
146
150
|
fill.hidden = YES;
|
|
@@ -181,6 +185,35 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
181
185
|
]];
|
|
182
186
|
|
|
183
187
|
self.window = window;
|
|
188
|
+
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(languageDidChange:)
|
|
189
|
+
name:CCPetsLanguageDidChangeNotification object:nil];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 只更新界面文案,保留编辑内容、撤销记录和当前编辑的宠物。
|
|
193
|
+
- (void)refreshLocalizedUI {
|
|
194
|
+
self.window.title = L(@"Pet Lines");
|
|
195
|
+
self.speakButton.title = L(@"Try a Line");
|
|
196
|
+
self.saveButton.title = L(@"Save");
|
|
197
|
+
self.saveAndCloseButton.title = L(@"Save & Close");
|
|
198
|
+
self.fillButton.title = L(@"Insert Template");
|
|
199
|
+
[self.scopeControl setLabel:L(@"Shared") forSegment:0];
|
|
200
|
+
[self.scopeControl setLabel:self.scopePetID.length > 0 ?
|
|
201
|
+
[NSString stringWithFormat:L(@"This Pet · %@"),
|
|
202
|
+
[self displayNameForPetID:self.scopePetID]] : L(@"This Pet") forSegment:1];
|
|
203
|
+
[self syncRevertButtonTitle];
|
|
204
|
+
// 更新原有菜单项,不改变用户选中的情境。
|
|
205
|
+
for (NSMenuItem *item in self.tagPicker.itemArray) {
|
|
206
|
+
NSString *tag = item.representedObject;
|
|
207
|
+
item.title = [NSString stringWithFormat:L(@"%1$@ (%2$@)"),
|
|
208
|
+
PetPhraseTagDescription(tag), tag];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
- (void)languageDidChange:(NSNotification *)notification {
|
|
213
|
+
[self refreshLocalizedUI];
|
|
214
|
+
// 通用词库可能已随语言切换换成新默认内容;有草稿时只刷新界面,不能重载覆盖它。
|
|
215
|
+
if (![self isDirty]) [self reloadFromDisk];
|
|
216
|
+
else [self showCurrentFileStatus];
|
|
184
217
|
}
|
|
185
218
|
|
|
186
219
|
#pragma mark - 编辑范围
|
|
@@ -206,8 +239,8 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
206
239
|
NSString *petID = PetPhrasesCurrentPetID();
|
|
207
240
|
BOOL hasPet = petID.length > 0;
|
|
208
241
|
[self.scopeControl setLabel:hasPet ?
|
|
209
|
-
[NSString stringWithFormat
|
|
210
|
-
@"
|
|
242
|
+
[NSString stringWithFormat:L(@"This Pet · %@"), [self displayNameForPetID:petID]] :
|
|
243
|
+
L(@"This Pet") forSegment:1];
|
|
211
244
|
[self.scopeControl setEnabled:hasPet forSegment:1];
|
|
212
245
|
|
|
213
246
|
// 宠物变了(或没了)而这一页正停在专属范围上:跟着走,但别把用户没存的东西冲掉。
|
|
@@ -226,7 +259,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
226
259
|
|
|
227
260
|
- (void)syncRevertButtonTitle {
|
|
228
261
|
// 专属词库没有"默认"这一说,它的默认状态就是空文件(全部回落到通用)。
|
|
229
|
-
self.revertButton.title = self.petScope ? @"
|
|
262
|
+
self.revertButton.title = self.petScope ? L(@"Clear Page…") : L(@"Restore Defaults…");
|
|
230
263
|
// 通用页不需要这个按钮:它本来就是从默认台词拷出来的,不存在空白无从下手的问题,
|
|
231
264
|
// 想拿回默认内容有"恢复默认台词…"。
|
|
232
265
|
self.fillButton.hidden = !self.petScope;
|
|
@@ -256,10 +289,10 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
256
289
|
|
|
257
290
|
- (BOOL)confirmDiscardChanges {
|
|
258
291
|
NSAlert *alert = [NSAlert new];
|
|
259
|
-
alert.messageText = @"
|
|
260
|
-
alert.informativeText = @"
|
|
261
|
-
[alert addButtonWithTitle
|
|
262
|
-
[alert addButtonWithTitle
|
|
292
|
+
alert.messageText = L(@"This Page Isn't Saved");
|
|
293
|
+
alert.informativeText = L(@"Unsaved changes will be lost if you switch.");
|
|
294
|
+
[alert addButtonWithTitle:L(@"Discard Changes")];
|
|
295
|
+
[alert addButtonWithTitle:L(@"Stay")];
|
|
263
296
|
return [alert runModal] == NSAlertFirstButtonReturn;
|
|
264
297
|
}
|
|
265
298
|
|
|
@@ -276,10 +309,14 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
276
309
|
self.loadedText = text;
|
|
277
310
|
self.loadedStamp = [NSFileManager.defaultManager attributesOfItemAtPath:path
|
|
278
311
|
error:nil][NSFileModificationDate];
|
|
279
|
-
|
|
312
|
+
[self showCurrentFileStatus];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
- (void)showCurrentFileStatus {
|
|
316
|
+
NSString *path = [self currentFilePath];
|
|
317
|
+
if (self.petScope && self.textView.string.length == 0) {
|
|
280
318
|
[self showStatus:[NSString stringWithFormat:
|
|
281
|
-
@"%@ ·
|
|
282
|
-
"只写想改的小节即可,或点右上角「填入默认模板」看看能写些什么。", path]
|
|
319
|
+
L(@"%@ · Still empty, so this pet uses the shared lines. Only write the sections you want to change, or click “Insert Template” at the top right to see what's possible."), path]
|
|
283
320
|
warning:NO];
|
|
284
321
|
return;
|
|
285
322
|
}
|
|
@@ -337,7 +374,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
337
374
|
|
|
338
375
|
NSString *path = [self currentFilePath];
|
|
339
376
|
if (path.length == 0) {
|
|
340
|
-
[self showStatus
|
|
377
|
+
[self showStatus:L(@"No pet is selected, so pet-specific lines can't be saved.") warning:YES];
|
|
341
378
|
return NO;
|
|
342
379
|
}
|
|
343
380
|
NSError *error = nil;
|
|
@@ -347,8 +384,8 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
347
384
|
[NSFileManager.defaultManager createDirectoryAtPath:path.stringByDeletingLastPathComponent
|
|
348
385
|
withIntermediateDirectories:YES attributes:nil error:nil];
|
|
349
386
|
if (![normalized writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
|
|
350
|
-
[self showStatus:[NSString stringWithFormat
|
|
351
|
-
error.localizedDescription ?: @"
|
|
387
|
+
[self showStatus:[NSString stringWithFormat:L(@"Save failed: %@"),
|
|
388
|
+
error.localizedDescription ?: L(@"unknown error")] warning:YES];
|
|
352
389
|
return NO;
|
|
353
390
|
}
|
|
354
391
|
self.loadedStamp = [NSFileManager.defaultManager attributesOfItemAtPath:path
|
|
@@ -357,11 +394,12 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
357
394
|
|
|
358
395
|
if (issues.count > 0) {
|
|
359
396
|
[self presentIssues:issues blocking:NO restored:nil];
|
|
360
|
-
[self showStatus:[NSString stringWithFormat
|
|
397
|
+
[self showStatus:[NSString stringWithFormat:issues.count != 1
|
|
398
|
+
? L(@"Saved, with %lu notices") : L(@"Saved, with %lu notice"),
|
|
361
399
|
(unsigned long)issues.count] warning:YES];
|
|
362
400
|
return YES;
|
|
363
401
|
}
|
|
364
|
-
[self showStatus
|
|
402
|
+
[self showStatus:L(@"Saved. Takes effect now.") warning:NO];
|
|
365
403
|
return YES;
|
|
366
404
|
}
|
|
367
405
|
|
|
@@ -372,12 +410,11 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
372
410
|
if (!current || !self.loadedStamp || [current isEqualToDate:self.loadedStamp]) return YES;
|
|
373
411
|
|
|
374
412
|
NSAlert *alert = [NSAlert new];
|
|
375
|
-
alert.messageText = @"
|
|
376
|
-
alert.informativeText = @"
|
|
377
|
-
|
|
378
|
-
[alert addButtonWithTitle
|
|
379
|
-
[alert addButtonWithTitle
|
|
380
|
-
[alert addButtonWithTitle:@"重新载入"];
|
|
413
|
+
alert.messageText = L(@"File Changed on Disk");
|
|
414
|
+
alert.informativeText = L(@"Another app changed the lines file after the editor opened it. Saving will overwrite those changes.");
|
|
415
|
+
[alert addButtonWithTitle:L(@"Overwrite")];
|
|
416
|
+
[alert addButtonWithTitle:L(@"Cancel")];
|
|
417
|
+
[alert addButtonWithTitle:L(@"Reload")];
|
|
381
418
|
NSModalResponse response = [alert runModal];
|
|
382
419
|
if (response == NSAlertSecondButtonReturn) return NO;
|
|
383
420
|
if (response == NSAlertThirdButtonReturn) {
|
|
@@ -394,41 +431,41 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
394
431
|
if (restored.count > 0) {
|
|
395
432
|
NSMutableArray<NSString *> *names = [NSMutableArray array];
|
|
396
433
|
for (NSString *tag in restored) {
|
|
397
|
-
[names addObject:[NSString stringWithFormat
|
|
434
|
+
[names addObject:[NSString stringWithFormat:L(@"[%1$@] (%2$@)"), tag,
|
|
398
435
|
PetPhraseTagDescription(tag)]];
|
|
399
436
|
}
|
|
400
437
|
[lines addObject:[NSString stringWithFormat:
|
|
401
|
-
@"
|
|
438
|
+
L(@"Tags can't be deleted, so %@ was put back in place (⌘Z to undo)."),
|
|
402
439
|
[names componentsJoinedByString:@"、"]]];
|
|
403
|
-
if (blocking) [lines addObject
|
|
440
|
+
if (blocking) [lines addObject:L(@"Nothing was saved. Check the restored tags, then save again.")];
|
|
404
441
|
[lines addObject:@""];
|
|
405
442
|
}
|
|
406
443
|
for (PetPhraseIssue *issue in issues) {
|
|
407
|
-
NSString *prefix = issue.level == PetPhraseIssueLevelError ? @"
|
|
444
|
+
NSString *prefix = issue.level == PetPhraseIssueLevelError ? L(@"Must fix: ") : L(@"Note: ");
|
|
408
445
|
NSString *where = issue.line > 0 ?
|
|
409
|
-
[NSString stringWithFormat
|
|
446
|
+
[NSString stringWithFormat:L(@"Line %ld "), (long)issue.line] : @"";
|
|
410
447
|
[lines addObject:[NSString stringWithFormat:@"%@%@%@", prefix, where, issue.message]];
|
|
411
448
|
// 一屏放不下就没人看了,剩下的等改完这批再报。
|
|
412
449
|
if (lines.count >= 12) {
|
|
413
|
-
[lines addObject:[NSString stringWithFormat
|
|
450
|
+
[lines addObject:[NSString stringWithFormat:L(@"…and %lu more"),
|
|
414
451
|
(unsigned long)(issues.count - lines.count + 1)]];
|
|
415
452
|
break;
|
|
416
453
|
}
|
|
417
454
|
}
|
|
418
455
|
NSAlert *alert = [NSAlert new];
|
|
419
456
|
if (blocking) {
|
|
420
|
-
alert.messageText = @"
|
|
457
|
+
alert.messageText = L(@"Can't Save Yet");
|
|
421
458
|
} else {
|
|
422
|
-
alert.messageText = issues.count > 0 ? @"
|
|
459
|
+
alert.messageText = issues.count > 0 ? L(@"Saved, but Some Lines Won't Be Used") : L(@"Saved");
|
|
423
460
|
}
|
|
424
461
|
alert.informativeText = [lines componentsJoinedByString:@"\n"];
|
|
425
462
|
alert.alertStyle = blocking ? NSAlertStyleWarning : NSAlertStyleInformational;
|
|
426
|
-
[alert addButtonWithTitle
|
|
463
|
+
[alert addButtonWithTitle:L(@"OK")];
|
|
427
464
|
[alert runModal];
|
|
428
465
|
if (blocking) {
|
|
429
466
|
[self showStatus:restored.count > 0 ?
|
|
430
|
-
@"
|
|
431
|
-
@"
|
|
467
|
+
L(@"Tags restored, nothing saved yet. Check and save again.") :
|
|
468
|
+
L(@"Some problems must be fixed before saving.") warning:YES];
|
|
432
469
|
}
|
|
433
470
|
}
|
|
434
471
|
|
|
@@ -448,12 +485,12 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
448
485
|
}
|
|
449
486
|
NSString *text = PetPhraseForTagInText(tag, draft, [self sampleSlots]);
|
|
450
487
|
if (text.length == 0) {
|
|
451
|
-
[self showStatus:[NSString stringWithFormat
|
|
488
|
+
[self showStatus:[NSString stringWithFormat:L(@"[%@] has no usable lines."), tag] warning:YES];
|
|
452
489
|
return;
|
|
453
490
|
}
|
|
454
491
|
if (PetPhrasesSpeakHandler) PetPhrasesSpeakHandler(text);
|
|
455
|
-
[self showStatus:[NSString stringWithFormat
|
|
456
|
-
fellBack ? @"
|
|
492
|
+
[self showStatus:[NSString stringWithFormat:L(@"Trying: %1$@%2$@"), text,
|
|
493
|
+
fellBack ? L(@" (from the shared lines)") : @""] warning:NO];
|
|
457
494
|
}
|
|
458
495
|
|
|
459
496
|
// 预览用的假数据。用真实数据的话,没在跑 agent 时 {toolName} 之类全是空的,
|
|
@@ -484,14 +521,14 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
484
521
|
if (defaults.length == 0) return nil;
|
|
485
522
|
|
|
486
523
|
NSString *petName = self.scopePetID.length > 0 ?
|
|
487
|
-
[self displayNameForPetID:self.scopePetID] : @"
|
|
524
|
+
[self displayNameForPetID:self.scopePetID] : L(@"this pet");
|
|
488
525
|
NSMutableString *text = [NSMutableString stringWithFormat:
|
|
489
|
-
@"# ↓↓↓
|
|
526
|
+
L(@"# ↓↓↓ Lines just for %1$@. Everything below is commented out and inactive ↓↓↓\n"
|
|
490
527
|
"#\n"
|
|
491
|
-
"#
|
|
492
|
-
"#
|
|
493
|
-
"#
|
|
494
|
-
"\n", petName
|
|
528
|
+
"# To give %1$@ its own lines for a situation, uncomment that tag and write lines under it\n"
|
|
529
|
+
"# An uncommented tag with no lines keeps the pet quiet in that situation\n"
|
|
530
|
+
"# Tags left commented out fall back to the shared lines\n"
|
|
531
|
+
"\n"), petName];
|
|
495
532
|
|
|
496
533
|
for (NSString *line in [defaults componentsSeparatedByString:@"\n"]) {
|
|
497
534
|
// 已经是注释的行不再叠一层 #,双井号只是噪音。空行保持空行,
|
|
@@ -505,17 +542,16 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
505
542
|
- (void)fillFromDefault:(id)sender {
|
|
506
543
|
NSString *text = [self commentedDefaultText];
|
|
507
544
|
if (text.length == 0) {
|
|
508
|
-
[self showStatus
|
|
545
|
+
[self showStatus:L(@"Default lines file not found.") warning:YES];
|
|
509
546
|
return;
|
|
510
547
|
}
|
|
511
548
|
// 空白页直接填,不打断——那正是这个按钮存在的理由。已经写了东西才问一句。
|
|
512
549
|
if ((self.textView.string ?: @"").length > 0) {
|
|
513
550
|
NSAlert *alert = [NSAlert new];
|
|
514
|
-
alert.messageText = @"
|
|
515
|
-
alert.informativeText = @"
|
|
516
|
-
|
|
517
|
-
[alert addButtonWithTitle
|
|
518
|
-
[alert addButtonWithTitle:@"取消"];
|
|
551
|
+
alert.messageText = L(@"Overwrite This Page?");
|
|
552
|
+
alert.informativeText = L(@"This page will be replaced with the full default lines (all commented out). Nothing is saved yet; ⌘Z undoes it.");
|
|
553
|
+
[alert addButtonWithTitle:L(@"Overwrite")];
|
|
554
|
+
[alert addButtonWithTitle:L(@"Cancel")];
|
|
519
555
|
if ([alert runModal] != NSAlertFirstButtonReturn) return;
|
|
520
556
|
}
|
|
521
557
|
// 走 shouldChangeTextInRange: 而不是直接设 string,这样这一步能被 ⌘Z 撤销。
|
|
@@ -523,8 +559,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
523
559
|
if (![self.textView shouldChangeTextInRange:all replacementString:text]) return;
|
|
524
560
|
[self.textView.textStorage replaceCharactersInRange:all withString:text];
|
|
525
561
|
[self.textView didChangeText];
|
|
526
|
-
[self showStatus
|
|
527
|
-
"把想改的那一节行首的 # 去掉,它才归这只宠物管。" warning:NO];
|
|
562
|
+
[self showStatus:L(@"Default lines inserted, all commented out and inactive. Remove the # in front of a section to make it this pet's own.") warning:NO];
|
|
528
563
|
}
|
|
529
564
|
|
|
530
565
|
#pragma mark - 恢复默认 / 清空
|
|
@@ -533,12 +568,12 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
533
568
|
NSAlert *alert = [NSAlert new];
|
|
534
569
|
// 专属词库的"默认状态"就是空白:清空 = 这只宠物全部回落到通用台词。
|
|
535
570
|
// 拿默认词库去填它是错的——那等于把 22 个小节全部标成"专属接管",再也不会回落。
|
|
536
|
-
alert.messageText = self.petScope ? @"
|
|
571
|
+
alert.messageText = self.petScope ? L(@"Clear This Pet's Lines?") : L(@"Restore Default Lines?");
|
|
537
572
|
alert.informativeText = self.petScope ?
|
|
538
|
-
@"
|
|
539
|
-
@"
|
|
540
|
-
[alert addButtonWithTitle:self.petScope ? @"
|
|
541
|
-
[alert addButtonWithTitle
|
|
573
|
+
L(@"After clearing, this pet goes back to the shared lines. Nothing is saved yet; ⌘Z undoes it.") :
|
|
574
|
+
L(@"The editor content will be replaced with the default lines. Nothing is saved yet; ⌘Z undoes it.");
|
|
575
|
+
[alert addButtonWithTitle:self.petScope ? L(@"Clear") : L(@"Restore")];
|
|
576
|
+
[alert addButtonWithTitle:L(@"Cancel")];
|
|
542
577
|
if ([alert runModal] != NSAlertFirstButtonReturn) return;
|
|
543
578
|
|
|
544
579
|
NSString *text = @"";
|
|
@@ -546,7 +581,7 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
546
581
|
text = [NSString stringWithContentsOfFile:PetPhrasesDefaultFilePath()
|
|
547
582
|
encoding:NSUTF8StringEncoding error:nil];
|
|
548
583
|
if (text.length == 0) {
|
|
549
|
-
[self showStatus
|
|
584
|
+
[self showStatus:L(@"Default lines file not found.") warning:YES];
|
|
550
585
|
return;
|
|
551
586
|
}
|
|
552
587
|
}
|
|
@@ -555,8 +590,8 @@ static void (^PetPhrasesSpeakHandler)(NSString *);
|
|
|
555
590
|
if (![self.textView shouldChangeTextInRange:all replacementString:text]) return;
|
|
556
591
|
[self.textView.textStorage replaceCharactersInRange:all withString:text];
|
|
557
592
|
[self.textView didChangeText];
|
|
558
|
-
[self showStatus:self.petScope ? @"
|
|
559
|
-
@"
|
|
593
|
+
[self showStatus:self.petScope ? L(@"Cleared. Click Save to write it to the file.") :
|
|
594
|
+
L(@"Default lines inserted. Click Save to write them to the file.") warning:NO];
|
|
560
595
|
}
|
|
561
596
|
|
|
562
597
|
@end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "CCPetsPreviews.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
#import "QuotaDashboardView.h"
|
|
3
4
|
#import "MenuToggleSwitch.h"
|
|
4
5
|
#import "CCPetsUsage.h"
|
|
@@ -123,12 +124,12 @@ int RenderAgentStatusCard(NSString *path) {
|
|
|
123
124
|
glass.layer.borderColor = [NSColor colorWithWhite:1 alpha:0.48].CGColor;
|
|
124
125
|
[root addSubview:glass];
|
|
125
126
|
|
|
126
|
-
NSTextField *title = [NSTextField labelWithString
|
|
127
|
+
NSTextField *title = [NSTextField labelWithString:L(@"Codex · Task completed")];
|
|
127
128
|
title.frame = NSMakeRect(20, 30, glassSize.width - 80, 18);
|
|
128
129
|
title.font = [NSFont systemFontOfSize:13 weight:NSFontWeightSemibold];
|
|
129
130
|
title.textColor = [NSColor colorWithWhite:0.10 alpha:0.96];
|
|
130
131
|
[glass addSubview:title];
|
|
131
|
-
NSTextField *detail = [NSTextField labelWithString
|
|
132
|
+
NSTextField *detail = [NSTextField labelWithString:L(@"The current task is done.")];
|
|
132
133
|
detail.frame = NSMakeRect(20, 12, glassSize.width - 80, 17);
|
|
133
134
|
detail.font = [NSFont systemFontOfSize:12 weight:NSFontWeightRegular];
|
|
134
135
|
detail.textColor = [NSColor colorWithWhite:0.34 alpha:0.88];
|
|
@@ -143,7 +144,7 @@ int RenderAgentStatusCard(NSString *path) {
|
|
|
143
144
|
NSColor *green = [NSColor colorWithRed:0.18 green:0.68 blue:0.35 alpha:1];
|
|
144
145
|
icon.layer.backgroundColor = [green colorWithAlphaComponent:0.28].CGColor;
|
|
145
146
|
NSImage *image = [NSImage imageWithSystemSymbolName:@"checkmark"
|
|
146
|
-
accessibilityDescription
|
|
147
|
+
accessibilityDescription:L(@"Task completed")];
|
|
147
148
|
icon.image = [image imageWithSymbolConfiguration:
|
|
148
149
|
[NSImageSymbolConfiguration configurationWithPointSize:15 weight:NSFontWeightBold]];
|
|
149
150
|
icon.contentTintColor = [green blendedColorWithFraction:0.18
|
|
@@ -173,8 +174,8 @@ int RenderMenuSwitches(NSString *path) {
|
|
|
173
174
|
view.wantsLayer = YES;
|
|
174
175
|
view.layer.backgroundColor = [NSColor colorWithWhite:0.86 alpha:1].CGColor;
|
|
175
176
|
NSArray<NSDictionary *> *rows = @[
|
|
176
|
-
@{@"title": @"
|
|
177
|
-
@{@"title": @"
|
|
177
|
+
@{@"title": L(@"Task done"), @"state": @YES, @"y": @40},
|
|
178
|
+
@{@"title": L(@"Task failed"), @"state": @NO, @"y": @10}
|
|
178
179
|
];
|
|
179
180
|
for (NSDictionary *row in rows) {
|
|
180
181
|
CGFloat y = [row[@"y"] doubleValue];
|
|
@@ -213,7 +214,7 @@ int RenderPetSheet(NSString *path, NSString *sheetPath, NSInteger rowCount) {
|
|
|
213
214
|
if (rowCount <= 0) rowCount = 9;
|
|
214
215
|
NSImage *sheet = LoadPetSpriteImage(sheetPath, NSMakeSize(140, 150), rowCount);
|
|
215
216
|
if (!sheet) {
|
|
216
|
-
fprintf(stderr, "
|
|
217
|
+
fprintf(stderr, "%s\n", [NSString stringWithFormat:L(@"Can't load the sprite: %@"), sheetPath].UTF8String);
|
|
217
218
|
return EXIT_FAILURE;
|
|
218
219
|
}
|
|
219
220
|
|
|
@@ -12,9 +12,12 @@ int RestartAfterPID(pid_t pid, NSString *appPath, BOOL managed);
|
|
|
12
12
|
// npm 安装日志里是否只是暂时性故障(值得自动重试一次),而不是真的装不上。
|
|
13
13
|
BOOL UpdateFailureIsTransient(NSString *log);
|
|
14
14
|
|
|
15
|
-
// 从 GitHub Release
|
|
16
|
-
//
|
|
15
|
+
// 从 GitHub Release 描述里摘出更新要点,给更新弹窗用。Release 是多语言的:
|
|
16
|
+
// 只读取标题完全匹配当前语言的段落(英文是「English」,其他语言见各自表里的
|
|
17
|
+
// "Release Notes Section");没有对应段落时返回空数组,绝不读取全文。只取列表项,
|
|
18
|
+
// 去掉 Markdown 标记,代码块整段跳过。
|
|
17
19
|
// 每条超过 maxLength 个字符截断加「…」;超过 limit 条时只返回前 limit 条并把 *truncated 置 YES。
|
|
18
20
|
// 没有列表项返回空数组——没写说明就不展示,不去猜正文。
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
// language 是 CCPetsSupportedLanguages() 里的某一种(见 CCPetsL10n.h)。
|
|
22
|
+
NSArray<NSString *> *ReleaseNoteHighlightsForLanguage(NSString *body, NSString *language,
|
|
23
|
+
NSUInteger limit, NSUInteger maxLength, BOOL *truncated);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#import "CCPetsL10n.h"
|
|
1
2
|
#import "CCPetsVersion.h"
|
|
2
3
|
#import <signal.h>
|
|
3
4
|
#import <unistd.h>
|
|
@@ -41,7 +42,7 @@ int RestartAfterPID(pid_t pid, NSString *appPath, BOOL managed) {
|
|
|
41
42
|
usleep(100000);
|
|
42
43
|
}
|
|
43
44
|
if (pid > 1 && (kill(pid, 0) == 0 || errno == EPERM)) {
|
|
44
|
-
fprintf(stderr, "
|
|
45
|
+
fprintf(stderr, "%s\n", L(@"Timed out waiting for the old CC Pets to quit.").UTF8String);
|
|
45
46
|
return EXIT_FAILURE;
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -54,7 +55,8 @@ int RestartAfterPID(pid_t pid, NSString *appPath, BOOL managed) {
|
|
|
54
55
|
task.arguments = arguments;
|
|
55
56
|
NSError *error = nil;
|
|
56
57
|
if (![task launchAndReturnError:&error]) {
|
|
57
|
-
fprintf(stderr, "
|
|
58
|
+
fprintf(stderr, "%s\n", [NSString stringWithFormat:L(@"Couldn't restart CC Pets: %@"),
|
|
59
|
+
error.localizedDescription].UTF8String);
|
|
58
60
|
return EXIT_FAILURE;
|
|
59
61
|
}
|
|
60
62
|
[task waitUntilExit];
|
|
@@ -100,15 +102,18 @@ static NSString *StripReleaseNoteMarkdown(NSString *text) {
|
|
|
100
102
|
return [result stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
NSArray<NSString *> *
|
|
104
|
-
BOOL *truncated) {
|
|
105
|
+
NSArray<NSString *> *ReleaseNoteHighlightsForLanguage(NSString *body, NSString *language,
|
|
106
|
+
NSUInteger limit, NSUInteger maxLength, BOOL *truncated) {
|
|
105
107
|
if (truncated) *truncated = NO;
|
|
106
108
|
if (![body isKindOfClass:NSString.class] || body.length == 0 || limit == 0) return @[];
|
|
107
109
|
NSArray<NSString *> *lines = [[body stringByReplacingOccurrencesOfString:@"\r" withString:@""]
|
|
108
110
|
componentsSeparatedByString:@"\n"];
|
|
109
111
|
|
|
110
|
-
//
|
|
112
|
+
// 只取标题完全匹配当前语言的段落:从标题开始,到下一个同级或更高级标题为止。
|
|
113
|
+
// 段落标题来自各语言表里的 "Release Notes Section",见 CCPetsL10n.h。
|
|
114
|
+
NSArray<NSString *> *sectionTitles = CCPetsReleaseNotesSectionTitles(language);
|
|
111
115
|
NSRange section = NSMakeRange(0, lines.count);
|
|
116
|
+
BOOL sectionFound = NO;
|
|
112
117
|
for (NSUInteger index = 0; index < lines.count; index++) {
|
|
113
118
|
NSString *line = [lines[index] stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
|
114
119
|
if (![line hasPrefix:@"#"]) continue;
|
|
@@ -116,7 +121,7 @@ NSArray<NSString *> *ReleaseNoteHighlights(NSString *body, NSUInteger limit, NSU
|
|
|
116
121
|
while (level < line.length && [line characterAtIndex:level] == '#') level++;
|
|
117
122
|
NSString *title = [[line substringFromIndex:level]
|
|
118
123
|
stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
|
|
119
|
-
if (![
|
|
124
|
+
if (![sectionTitles containsObject:title]) continue;
|
|
120
125
|
NSUInteger end = lines.count;
|
|
121
126
|
for (NSUInteger next = index + 1; next < lines.count; next++) {
|
|
122
127
|
NSString *candidate = lines[next];
|
|
@@ -126,8 +131,11 @@ NSArray<NSString *> *ReleaseNoteHighlights(NSString *body, NSUInteger limit, NSU
|
|
|
126
131
|
if (nextLevel <= level) { end = next; break; }
|
|
127
132
|
}
|
|
128
133
|
section = NSMakeRange(index + 1, end - index - 1);
|
|
134
|
+
sectionFound = YES;
|
|
129
135
|
break;
|
|
130
136
|
}
|
|
137
|
+
// Release 必须明确写出当前语言段落;缺失时不读取全文,避免把其他语言展示给用户。
|
|
138
|
+
if (!sectionFound) return @[];
|
|
131
139
|
|
|
132
140
|
static NSRegularExpression *bullet;
|
|
133
141
|
static dispatch_once_t once;
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
target:(id)target action:(SEL)action width:(CGFloat)width {
|
|
7
7
|
// item 要有 action 才会被菜单高亮。鼠标点击由行视图自己处理(菜单不关);
|
|
8
8
|
// 用键盘选中后按回车走的是这个 action,行为与点击一致,菜单照常关闭。
|
|
9
|
+
// 所有设置单选行统一按文案撑宽,避免英文标题被截断。
|
|
10
|
+
width = MAX(width, ceil([title sizeWithAttributes:
|
|
11
|
+
@{NSFontAttributeName: [NSFont menuFontOfSize:13]}].width) + 42);
|
|
9
12
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:@selector(chooseFromMenuItem:)
|
|
10
13
|
keyEquivalent:@""];
|
|
11
14
|
MenuChoiceRowView *row = [[MenuChoiceRowView alloc] initWithFrame:NSMakeRect(0, 0, width, 24)];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#import "MenuPetSizeView.h"
|
|
2
|
+
#import "CCPetsPetSize.h"
|
|
3
|
+
#import "CCPetsL10n.h"
|
|
4
|
+
|
|
5
|
+
@interface MenuPetSizeView ()
|
|
6
|
+
@property NSSlider *slider;
|
|
7
|
+
@property NSTextField *percentage;
|
|
8
|
+
@property(weak) id target;
|
|
9
|
+
@property SEL action;
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation MenuPetSizeView
|
|
13
|
+
- (instancetype)initWithScale:(CGFloat)scale target:(id)target action:(SEL)action {
|
|
14
|
+
CGFloat resetWidth = ceil([L(@"Reset Size") sizeWithAttributes:
|
|
15
|
+
@{NSFontAttributeName: [NSFont menuFontOfSize:12]}].width) + 24;
|
|
16
|
+
CGFloat width = MAX(220, resetWidth + 94);
|
|
17
|
+
self = [super initWithFrame:NSMakeRect(0, 0, width, 92)];
|
|
18
|
+
if (!self) return nil;
|
|
19
|
+
self.autoresizingMask = NSViewWidthSizable;
|
|
20
|
+
self.target = target;
|
|
21
|
+
self.action = action;
|
|
22
|
+
|
|
23
|
+
self.percentage = [NSTextField labelWithString:@""];
|
|
24
|
+
self.percentage.frame = NSMakeRect(14, 65, width - 28, 18);
|
|
25
|
+
self.percentage.font = [NSFont monospacedDigitSystemFontOfSize:13 weight:NSFontWeightMedium];
|
|
26
|
+
self.percentage.alignment = NSTextAlignmentCenter;
|
|
27
|
+
self.percentage.autoresizingMask = NSViewWidthSizable;
|
|
28
|
+
[self addSubview:self.percentage];
|
|
29
|
+
|
|
30
|
+
self.slider = [NSSlider sliderWithValue:scale minValue:CCPetsPetMinimumScale
|
|
31
|
+
maxValue:CCPetsPetMaximumScale target:self action:@selector(sliderChanged:)];
|
|
32
|
+
self.slider.frame = NSMakeRect(14, 37, width - 28, 24);
|
|
33
|
+
self.slider.continuous = YES;
|
|
34
|
+
self.slider.autoresizingMask = NSViewWidthSizable;
|
|
35
|
+
self.slider.accessibilityLabel = L(@"Pet Size");
|
|
36
|
+
[self addSubview:self.slider];
|
|
37
|
+
|
|
38
|
+
NSTextField *minimum = [NSTextField labelWithString:@"50%"];
|
|
39
|
+
minimum.frame = NSMakeRect(14, 10, 44, 16);
|
|
40
|
+
minimum.font = [NSFont menuFontOfSize:11];
|
|
41
|
+
minimum.textColor = NSColor.secondaryLabelColor;
|
|
42
|
+
[self addSubview:minimum];
|
|
43
|
+
NSTextField *maximum = [NSTextField labelWithString:@"200%"];
|
|
44
|
+
maximum.frame = NSMakeRect(width - 58, 10, 44, 16);
|
|
45
|
+
maximum.font = minimum.font;
|
|
46
|
+
maximum.textColor = minimum.textColor;
|
|
47
|
+
maximum.alignment = NSTextAlignmentRight;
|
|
48
|
+
maximum.autoresizingMask = NSViewMinXMargin;
|
|
49
|
+
[self addSubview:maximum];
|
|
50
|
+
|
|
51
|
+
NSButton *reset = [NSButton buttonWithTitle:L(@"Reset Size") target:self action:@selector(resetSize:)];
|
|
52
|
+
reset.bezelStyle = NSBezelStyleRounded;
|
|
53
|
+
reset.font = [NSFont menuFontOfSize:12];
|
|
54
|
+
reset.frame = NSMakeRect((width - resetWidth) / 2, 5, resetWidth, 26);
|
|
55
|
+
reset.autoresizingMask = NSViewMinXMargin | NSViewMaxXMargin;
|
|
56
|
+
[self addSubview:reset];
|
|
57
|
+
[self updatePercentage];
|
|
58
|
+
return self;
|
|
59
|
+
}
|
|
60
|
+
- (void)updatePercentage {
|
|
61
|
+
self.percentage.stringValue = [NSString stringWithFormat:@"%.0f%%", self.slider.doubleValue * 100];
|
|
62
|
+
}
|
|
63
|
+
- (void)sliderChanged:(NSSlider *)sender {
|
|
64
|
+
[NSApp sendAction:self.action to:self.target from:sender];
|
|
65
|
+
[self updatePercentage];
|
|
66
|
+
}
|
|
67
|
+
- (void)resetSize:(id)sender {
|
|
68
|
+
self.slider.doubleValue = 1.0;
|
|
69
|
+
[self sliderChanged:self.slider];
|
|
70
|
+
}
|
|
71
|
+
// 消费行内空白处的点击,菜单保持打开以便继续调整。
|
|
72
|
+
- (void)mouseDown:(NSEvent *)event {}
|
|
73
|
+
@end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "MenuToggleSwitch.h"
|
|
2
|
+
#import "CCPetsL10n.h"
|
|
2
3
|
|
|
3
4
|
@implementation MenuToggleSwitch
|
|
4
5
|
- (instancetype)initWithFrame:(NSRect)frameRect {
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
|
|
63
64
|
- (void)setState:(NSControlStateValue)value {
|
|
64
65
|
[super setState:value];
|
|
65
|
-
[self setAccessibilityValue:value == NSControlStateValueOn ? @"
|
|
66
|
+
[self setAccessibilityValue:value == NSControlStateValueOn ? L(@"API") : L(@"Plan")];
|
|
66
67
|
self.needsDisplay = YES;
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
pillPath.lineWidth = 0.8;
|
|
81
82
|
[pillPath stroke];
|
|
82
83
|
|
|
83
|
-
NSString *title = usesAPI ? @"
|
|
84
|
+
NSString *title = usesAPI ? L(@"API") : L(@"Plan");
|
|
84
85
|
NSDictionary<NSAttributedStringKey, id> *attributes = @{
|
|
85
86
|
NSFontAttributeName: [NSFont systemFontOfSize:11 weight:NSFontWeightSemibold],
|
|
86
87
|
NSForegroundColorAttributeName: NSColor.whiteColor,
|