Skip to content

Commit

Permalink
perf: improve Youdao Chinese phonetic
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Oct 11, 2022
1 parent cb41959 commit cdf003d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ npm install && npm run dev

支持 19 种语言,(中文,日语,俄语),英语,法语,西班牙语,葡萄牙语,意大利语,德语,瑞典语,罗马尼亚语,斯洛伐克语,荷兰语,匈牙利语,希腊语,丹麦语,芬兰语,波兰语,捷克语。

Linguee 默认支持系统代理。

#### 翻译

**目前支持 DeepL,Google,Bing,🍎 系统翻译,百度,腾讯,火山,有道和彩云翻译,总计 9 家翻译服务。**
Expand Down
6 changes: 3 additions & 3 deletions src/dataManager/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ModernChineseDataList, QueryWordInfo, YoudaoDictionaryListItemType } from "./../dictionary/youdao/types";
/*
* @author: tisfeng
* @createTime: 2022-08-17 17:41
* @lastEditor: tisfeng
* @lastEditTime: 2022-10-10 22:41
* @lastEditTime: 2022-10-11 19:48
* @fileName: utils.ts
*
* Copyright (c) 2022 by tisfeng, All Rights Reserved.
Expand Down Expand Up @@ -35,6 +34,7 @@ import {
checkIsWord,
checkIsYoudaoDictionaryListItem,
} from "../utils";
import { ModernChineseDataList, QueryWordInfo, YoudaoDictionaryListItemType } from "./../dictionary/youdao/types";
import { chineseLanguageItem, englishLanguageItem } from "./../language/consts";

/**
Expand Down Expand Up @@ -288,7 +288,7 @@ export function getModernChineseDictMarkdown(modernChineseDict: ModernChineseDat
let formsMarkdown = "";
if (cat && i === 0) {
const pinyin = dictData.pinyin ? `${dictData.pinyin}` : "";
const catTex = cat ? ` ${cat}` : "";
const catTex = cat ? ` ${cat}` : "";
markdown += `${pinyin}${catTex}`;
}
if (def) {
Expand Down
7 changes: 4 additions & 3 deletions src/dictionary/youdao/formatData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author: tisfeng
* @createTime: 2022-08-03 00:02
* @lastEditor: tisfeng
* @lastEditTime: 2022-10-10 12:33
* @lastEditTime: 2022-10-10 22:54
* @fileName: formatData.ts
*
* Copyright (c) 2022 by tisfeng, All Rights Reserved.
Expand Down Expand Up @@ -131,8 +131,9 @@ export function updateYoudaoDictionaryDisplay(
const modernChineseDictItems: ListDisplayItem[] = [];
modernChineseDict.forEach((forms) => {
const pinyin = forms.pinyin ? `${forms.pinyin}` : "";
if (pinyin && translationItem.accessoryItem) {
translationItem.accessoryItem.phonetic = pinyin;
const accessoryItem = translationItem.accessoryItem;
if (pinyin && accessoryItem && !accessoryItem.phonetic) {
accessoryItem.phonetic = `/ ${pinyin} /`;
}

if (forms.sense?.length) {
Expand Down
4 changes: 2 additions & 2 deletions src/dictionary/youdao/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @author: tisfeng
* @createTime: 2022-08-04 23:21
* @lastEditor: tisfeng
* @lastEditTime: 2022-10-10 09:05
* @lastEditTime: 2022-10-10 22:45
* @fileName: types.ts
*
* Copyright (c) 2022 by tisfeng, All Rights Reserved.
Expand All @@ -25,7 +25,7 @@ export interface YoudaoDictionaryFormatResult {
export enum YoudaoDictionaryListItemType {
Translation = "Translation",
Explanation = "Explanation",
ModernChineseDict = "ModernChineseDict",
ModernChineseDict = "Modern Chinese Dict",
Forms = "Forms and Tenses",
WebTranslation = "Web Translation",
WebPhrase = "Web Phrase",
Expand Down

0 comments on commit cdf003d

Please sign in to comment.