MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / sync

Method sync

src/main/translate-controller.ts:553–577  ·  view source on GitHub ↗
(language?: { source: Language; target: Language })

Source from the content-addressed store, hash-verified

551 }
552
553 sync(language?: { source: Language; target: Language }) {
554 if (!language) {
555 language = {
556 source: this.source,
557 target: this.target,
558 };
559 }
560 let sharedResult: SharedResult = emptySharedResult();
561 if (this.translateResult != undefined) {
562 sharedResult = this.translateResult;
563 }
564 store.dispatch("setShared", sharedResult);
565 if (this.translateResult != undefined) {
566 if (this.get<boolean>("enableNotify")) {
567 eventBus.at("dispatch", "notify", sharedResult.translation);
568 }
569 logger.toast(
570 `翻译完成 ${this.getL(<Language>sharedResult.from)} -> ${this.getL(
571 <Language>sharedResult.to
572 )}`
573 );
574 } else {
575 logger.toast(`清空`);
576 }
577 }
578
579 isWord(text: string) {
580 text = trimEnd(text.trim(), ",.!?. ");

Callers 3

clearResultMethod · 0.95
postProcessMethod · 0.95
translateSentenceMethod · 0.95

Calls 5

getMethod · 0.95
getLMethod · 0.95
emptySharedResultFunction · 0.90
dispatchMethod · 0.80
toastMethod · 0.80

Tested by

no test coverage detected