MCPcopy
hub / github.com/wensonsmith/YoudaoTranslator / addResult

Method addResult

src/adapters/youdao.ts:127–140  ·  view source on GitHub ↗
( title: string, subtitle: string, arg: string = "", pronounce: string = "")

Source from the content-addressed store, hash-verified

125 }
126
127 private addResult( title: string, subtitle: string, arg: string = "", pronounce: string = ""): Result[] {
128 const quicklookurl = "https://www.youdao.com/w/" + this.word;
129
130 const maxLength = this.detectChinese(title) ? 27 : 60;
131
132 if (title.length > maxLength) {
133 const copy = title;
134 title = copy.slice(0, maxLength);
135 subtitle = copy.slice(maxLength);
136 }
137
138 this.results.push({ title, subtitle, arg, pronounce, quicklookurl });
139 return this.results;
140 }
141
142 private detectChinese(word: string): boolean {
143 return /^[\u4e00-\u9fa5]+$/.test(word);

Callers 4

parseTranslationMethod · 0.95
parseBasicMethod · 0.95
parseWebMethod · 0.95
parseErrorMethod · 0.95

Calls 1

detectChineseMethod · 0.95

Tested by

no test coverage detected