Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Jan 17, 2024
1 parent cdda635 commit 171da5a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 320 deletions.
5 changes: 3 additions & 2 deletions src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@
"File size is larger than 20MB": "File size is larger than 20MB",
"Learn More": "Learn More",
"Format": "Format",
"Duplicate Book in Trash Bin": "Duplicate Book in Trash Bin"
}
"Duplicate Book in Trash Bin": "Duplicate Book in Trash Bin",
"Subject can't be empty": "Subject can't be empty"
}
8 changes: 6 additions & 2 deletions src/components/dialogs/feedbackDialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FeedbackDialog extends Component<

handleComfirm = async () => {
this.setState({ isSending: true });
toast(this.props.t("Sending"));

let uploadResult = true;
if (this.state.fileContent && this.state.uploadUrl) {
uploadResult = await uploadFile(
Expand Down Expand Up @@ -65,7 +65,11 @@ class FeedbackDialog extends Component<
"#feedback-dialog-email-box"
) as HTMLTextAreaElement
).value;

if (subject === "") {
toast(this.props.t("Subject can't be empty"));
return;
}
toast(this.props.t("Sending"));
let version = packageInfo.version;
const os = window.require("os");
const system = os.platform() + " " + os.version();
Expand Down
79 changes: 1 addition & 78 deletions src/components/popups/popupTrans/component.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import React from "react";
import "./popupTrans.css";
import { PopupTransProps, PopupTransState } from "./interface";
import {
googleTransList,
edgeTransList,
deeplTransList,
yandexTransList,
} from "../../../constants/transList";
import { googleTransList, edgeTransList } from "../../../constants/transList";
import StorageUtil from "../../../utils/serviceUtils/storageUtil";
import { bingTranslate } from "../../../utils/serviceUtils/bingTransUtil";
import { deeplTranslate } from "../../../utils/serviceUtils/deeplTransUtil";
import { yandexTranslate } from "../../../utils/serviceUtils/yandexTransUtil";
import { googleTranslate } from "../../../utils/serviceUtils/googleTransUtil";
class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
constructor(props: PopupTransProps) {
Expand Down Expand Up @@ -43,34 +36,6 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
.catch((err) => {
console.log(err);
});
} else if (this.state.transService === "Yandex") {
yandexTranslate(
text,
StorageUtil.getReaderConfig("transSource") || "",
StorageUtil.getReaderConfig("transTarget") || "en"
)
.then((res) => {
this.setState({
translatedText: res,
});
})
.catch((err) => {
console.log(err);
});
} else if (this.state.transService === "Deepl") {
deeplTranslate(
text,
StorageUtil.getReaderConfig("transSource") || "auto",
StorageUtil.getReaderConfig("transTarget") || "EN"
)
.then((res) => {
this.setState({
translatedText: res,
});
})
.catch((err) => {
console.log(err);
});
} else {
googleTranslate(
text,
Expand Down Expand Up @@ -136,32 +101,6 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
<span className="icon-bing trans-bing-icon"></span>
Bing
</div>
<div
className={
this.state.transService === "Deepl"
? "trans-service-selector"
: "trans-service-selector-inactive"
}
onClick={() => {
this.handleChangeService("Deepl");
}}
>
<span className="icon-deepl trans-deepl-icon"></span>
Deepl
</div>
<div
className={
this.state.transService === "Yandex"
? "trans-service-selector"
: "trans-service-selector-inactive"
}
onClick={() => {
this.handleChangeService("Yandex");
}}
>
<span className="icon-yandex trans-yandex-icon"></span>
Yandex
</div>
</div>
<div className="trans-lang-selector-container">
<div className="original-lang-box">
Expand All @@ -178,10 +117,6 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
>
{(this.state.transService === "Google"
? Object.keys(googleTransList)
: this.state.transService === "Deepl"
? Object.keys(deeplTransList)
: this.state.transService === "Yandex"
? Object.keys(yandexTransList)
: Object.keys(edgeTransList)
).map((item, index) => {
return (
Expand All @@ -198,10 +133,6 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
{
(this.state.transService === "Google"
? Object.values(googleTransList)
: this.state.transService === "Deepl"
? Object.values(deeplTransList)
: this.state.transService === "Yandex"
? Object.values(yandexTransList)
: Object.values(edgeTransList))[index]
}
</option>
Expand All @@ -223,10 +154,6 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
>
{(this.state.transService === "Google"
? Object.keys(googleTransList)
: this.state.transService === "Deepl"
? Object.keys(deeplTransList)
: this.state.transService === "Yandex"
? Object.keys(yandexTransList)
: Object.keys(edgeTransList)
).map((item, index) => {
return (
Expand All @@ -243,10 +170,6 @@ class PopupTrans extends React.Component<PopupTransProps, PopupTransState> {
{
(this.state.transService === "Google"
? Object.values(googleTransList)
: this.state.transService === "Deepl"
? Object.values(deeplTransList)
: this.state.transService === "Yandex"
? Object.values(yandexTransList)
: Object.values(edgeTransList))[index]
}
</option>
Expand Down
12 changes: 2 additions & 10 deletions src/components/popups/popupTrans/popupTrans.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,14 @@
opacity: 1;
}
.trans-google-icon,
.trans-bing-icon,
.trans-deepl-icon {
.trans-bing-icon {
font-size: 13px;
margin: 2px;
margin-right: 5px;
}
.trans-bing-icon {
font-size: 14px;
}
.trans-deepl-icon {
font-size: 15px;
}
.trans-yandex-icon {
font-size: 13px;
font-weight: bold;
}
.trans-service-selector-inactive {
border: 1px solid rgba(0, 0, 0, 0.05);
color: #f16464;
Expand All @@ -123,7 +115,7 @@
.trans-service-selector-container {
position: absolute;
top: 20px;
width: 360px;
width: 180px;
display: flex;
justify-content: space-between;
}
Expand Down
123 changes: 0 additions & 123 deletions src/constants/transList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,126 +220,3 @@ export const edgeTransList = {
yua: "Yucatec Maya",
zu: "Zulu",
};
export const deeplTransList = {
auto: "Automatic",
BG: "Bulgarian",
ZH: "Chinese",
CS: "Czech",
DA: "Danish",
DE: "German",
EL: "Greek",
EN: "English",
ES: "Spanish",
ET: "Estonian",
FI: "Finnish",
FR: "French",
HU: "Hungarian",
ID: "Indonesian",
IT: "Italian",
JA: "Japanese",
KO: "Korean",
LT: "Lithuanian",
LV: "Latvian",
NB: "Norwegian (Bokmål)",
NL: "Dutch",
PL: "Polish",
PT: "Portuguese",
RO: "Romanian",
RU: "Russian",
SK: "Slovak",
SL: "Slovenian",
SV: "Swedish",
TR: "Turkish",
UK: "Ukrainian",
};
export const yandexTransList = {
af: "Afrikaans",
am: "Amharic",
ar: "Arabic",
az: "Azerbaijani",
ba: "Bashkir",
be: "Belarusian",
bg: "Bulgarian",
bn: "Bengali",
bs: "Bosnian",
ca: "Catalan",
cs: "Czech",
zh: "Chinese",
cv: "Chuvash",
cy: "Welsh",
da: "Danish",
de: "German",
el: "Greek",
en: "English",
eo: "Esperanto",
es: "Spanish",
et: "Estonian",
eu: "Basque",
fa: "Persian",
fi: "Finnish",
fr: "French",
ga: "Irish",
gd: "Scottish (Gaelic)",
gl: "Galician",
gu: "Gujarati",
he: "Hebrew",
hi: "Hindi",
hr: "Croatian",
ht: "Haitian",
hu: "Hungarian",
hy: "Armenian",
id: "Indonesian",
is: "Icelandic",
it: "Italian",
ja: "Japanese",
jv: "Javanese",
ka: "Georgian",
kk: "Kazakh",
km: "Khmer",
kn: "Kannada",
ko: "Korean",
ky: "Kirghiz",
la: "Latin",
lb: "Luxembourgish",
lo: "Lao",
lt: "Lithuanian",
lv: "Latvian",
mg: "Malagasy",
mi: "Maori",
mk: "Macedonian",
ml: "Malayalam",
mn: "Mongolian",
mr: "Marathi",
ms: "Malay",
mt: "Maltese",
my: "Burmese",
ne: "Nepali",
nl: "Dutch",
no: "Norwegian",
pa: "Punjabi",
pl: "Polish",
pt: "Portuguese",
ro: "Romanian",
ru: "Russian",
si: "Sinhala",
sk: "Slovak",
sl: "Slovenian",
sq: "Albanian",
sr: "Serbian",
su: "Sundanese",
sv: "Swedish",
sw: "Swahili",
ta: "Tamil",
te: "Telugu",
tg: "Tajik",
th: "Thai",
tl: "Tagalog",
tr: "Turkish",
tt: "Tatar",
uk: "Ukrainian",
ur: "Urdu",
uz: "Uzbek",
vi: "Vietnamese",
xh: "Xhosa",
yi: "Yiddish",
};
73 changes: 0 additions & 73 deletions src/utils/serviceUtils/deeplTransUtil.tsx

This file was deleted.

Loading

0 comments on commit 171da5a

Please sign in to comment.