Skip to content

Commit

Permalink
refactor: change translate component to use constant module
Browse files Browse the repository at this point in the history
  • Loading branch information
rockbenben committed Mar 18, 2024
1 parent 757a9c5 commit b206e3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
26 changes: 26 additions & 0 deletions src/app/components/transalteConstants.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const translationMethods = [
{ value: "google", label: "Google Translate" },
{ value: "deepl", label: "DeepL" },
{ value: "deeplx", label: "DeepLX(免费,无需填 API)" },
];

export type LanguageOption = {
value: string;
label: string;
};

export const languages: LanguageOption[] = [
{ value: "en", label: "英语(English)" },
{ value: "zh", label: "中文(Chinese)" },
{ value: "ja", label: "日本語" },
{ value: "ko", label: "韩语(한국어)" },
{ value: "es", label: "西班牙语" },
{ value: "fr", label: "法语(Français)" },
{ value: "de", label: "德语(Deutsch)" },
{ value: "it", label: "意大利语" },
{ value: "ru", label: "俄语(Русский)" },
{ value: "pt", label: "葡萄牙语" },
{ value: "ar", label: "阿拉伯语" },
{ value: "hi", label: "印地语 (仅 Google)" },
{ value: "bn", label: "孟加拉语 (仅 Google)" },
];
28 changes: 1 addition & 27 deletions src/app/json-translate/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { JSONPath } from "jsonpath-plus";
import { translateText } from "../components/translateText";
import { preprocessJson } from "../components/preprocessJson";
import KeyMappingInput from "../components/KeyMappingInput";
import { translationMethods, languages } from "../components/transalteConstants";

const { Title, Paragraph } = Typography;

Expand All @@ -26,33 +27,6 @@ const JsonTranslate = () => {
setShowSimpleInput(!showSimpleInput);
};

const translationMethods = [
{ value: "google", label: "Google Translate" },
{ value: "deepl", label: "DeepL" },
{ value: "deeplx", label: "DeepLX(免费,无需填 API)" },
];

type LanguageOption = {
value: string;
label: string;
};

const languages: LanguageOption[] = [
{ value: "en", label: "英语(English)" },
{ value: "zh", label: "中文(Chinese)" },
{ value: "ja", label: "日本語" },
{ value: "ko", label: "韩语(한국어)" },
{ value: "es", label: "西班牙语" },
{ value: "fr", label: "法语(Français)" },
{ value: "de", label: "德语(Deutsch)" },
{ value: "it", label: "意大利语" },
{ value: "ru", label: "俄语(Русский)" },
{ value: "pt", label: "葡萄牙语" },
{ value: "hi", label: "印地语 (仅 Google)" },
{ value: "ar", label: "阿拉伯语 (仅 Google)" },
{ value: "bn", label: "孟加拉语 (仅 Google)" },
];

const handleJsonInputChange = (e) => {
const input = e.target.value;
setJsonInput(input);
Expand Down

0 comments on commit b206e3e

Please sign in to comment.