Skip to content

Commit def1806

Browse files
committed
Update
1 parent 8a3f009 commit def1806

File tree

10 files changed

+56
-37
lines changed

10 files changed

+56
-37
lines changed

public/locales/en-GB/translation.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"切韻音系自動推導器": "Tshet-uinh Autoderiver",
3-
"schemaCompareDifferent": "Found {{count}} different items.",
4-
"phonologicalPosition": "Phonological Position",
3+
"音韻地位": "Phonological Position",
54
"代表字": "Representative Character",
6-
"schemaCompareSame": "The results of the program derivation are the same.",
5+
"找到 {{count}} 個相異項目。": "Found {{count}} different items.",
6+
"方案推導結果相同。": "The results of the program derivation are the same.",
77
"全部複製": "Copy all",
88
"已複製": "Copied",
99
"複製失敗": "Copy failed",
@@ -14,13 +14,16 @@
1414
"要刪除此方案嗎?": "Delete this scheme?",
1515
"此動作無法復原。": "This action cannot be undone.",
1616
"確定": "Confirm",
17+
"確定-OK": "OK",
1718
"取消": "Cancel",
1819
"關閉": "Close",
20+
"新增": "Add",
21+
"錯誤": "Error",
1922
"開啟檔案時發生錯誤": "An error occurred while opening the file",
2023
"此推導方案無需選項。": "This derivation scheme requires no options.",
21-
"載入更多注音方案": "Load More Transcription Schemes",
2224
"新增方案": "Add New Scheme",
2325
"新增空白方案……": "Add Blank Scheme...",
26+
"載入更多注音方案": "Load More Transcription Schemes",
2427
"前往舊版": "Go to Legacy Version",
2528
"推導結果": "Derivation Result",
2629
"選項": "Options",
@@ -32,5 +35,12 @@
3235
"比較多個方案,並導出結果相異的音韻地位": "Compare multiple schemes and export differing phonological positions",
3336
"導出所有音節": "Export all syllables",
3437
"導出所有音節,並計數": "Export all syllables with counts",
38+
"計數": "Count",
39+
"方案名稱顯示為": "Display scheme name as",
40+
"將所有選項恢復為預設值": "Reset all options to default values",
41+
"此選項需要兩個或以上方案": "This option requires two or more schemes",
42+
"方案名稱為空": "Scheme name is empty",
43+
"方案名稱含有特殊字元": "Scheme name contains special characters",
44+
"方案名稱與現有方案重複": "Scheme name duplicates an existing scheme name",
3545
"轉換異體字": "Convert Variant Characters"
3646
}

public/locales/zh-HK/translation.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"切韻音系自動推導器": "切韻音系自動推導器",
3-
"schemaCompareDifferent": "找到 {{count}} 個相異項目。",
4-
"phonologicalPosition": "音韻地位",
3+
"音韻地位": "音韻地位",
54
"代表字": "代表字",
6-
"schemaCompareSame": "方案推導結果相同。",
5+
"找到 {{count}} 個相異項目。": "找到 {{count}} 個相異項目。",
6+
"方案推導結果相同。": "方案推導結果相同。",
77
"全部複製": "全部複製",
88
"已複製": "已複製",
99
"複製失敗": "複製失敗",
@@ -14,8 +14,11 @@
1414
"要刪除此方案嗎?": "要刪除此方案嗎?",
1515
"此動作無法復原。": "此動作無法復原。",
1616
"確定": "確定",
17+
"確定-OK": "確定",
1718
"取消": "取消",
1819
"關閉": "關閉",
20+
"新增": "新增",
21+
"錯誤": "錯誤",
1922
"開啟檔案時發生錯誤": "開啟檔案時發生錯誤",
2023
"此推導方案無需選項。": "此推導方案無需選項。",
2124
"新增方案": "新增方案",
@@ -32,5 +35,12 @@
3235
"比較多個方案,並導出結果相異的音韻地位": "比較多個方案,並導出結果相異的音韻地位",
3336
"導出所有音節": "導出所有音節",
3437
"導出所有音節,並計數": "導出所有音節,並計數",
38+
"計數": "計數",
39+
"方案名稱顯示為": "方案名稱顯示為",
40+
"將所有選項恢復為預設值": "將所有選項恢復為預設值",
41+
"此選項需要兩個或以上方案": "此選項需要兩個或以上方案",
42+
"方案名稱為空": "方案名稱為空",
43+
"方案名稱含有特殊字元": "方案名稱含有特殊字元",
44+
"方案名稱與現有方案重複": "方案名稱與現有方案重複",
3545
"轉換異體字": "轉換異體字"
3646
}

src/Components/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useCallback, useEffect, useRef } from "react";
22

3+
import { t } from "i18next";
34
import "purecss/build/pure.css";
5+
import { useTranslation } from "react-i18next";
46
// NOTE sweetalert2's ESM export does not setup styles properly, manually importing
57
import "sweetalert2/dist/sweetalert2.css";
68

@@ -12,10 +14,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1214
import Main from "./Main";
1315
import Swal from "../Classes/SwalReact";
1416
import { codeFontFamily, noop } from "../consts";
15-
import { useTranslation } from "react-i18next";
16-
1717
import i18n from "../i18n";
18-
import { t } from "i18next";
1918

2019
injectGlobal`
2120
html,

src/Components/CreateSchemaDialog.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
22
import { createPortal } from "react-dom";
33

4+
import { t } from "i18next";
5+
46
import { css } from "@emotion/react";
57
import styled from "@emotion/styled";
68
import { faFile, faFileCode } from "@fortawesome/free-regular-svg-icons";
@@ -14,7 +16,6 @@ import { fetchFile, normalizeFileName, stopPropagation } from "../utils";
1416

1517
import type { Folder, Sample, SchemaState } from "../consts";
1618
import type { ChangeEventHandler, FormEvent, RefObject } from "react";
17-
import { t } from "i18next";
1819

1920
const Container = styled.dialog`
2021
transform: scale(0.9);
@@ -209,9 +210,9 @@ const CreateSchemaDialog = forwardRef<HTMLDialogElement, CreateSchemaDialogProps
209210

210211
const validation = useMemo(() => {
211212
const name = normalizeFileName(createSchemaName);
212-
if (!name) return "方案名稱為空";
213-
if (invalidCharsRegex.test(name)) return "方案名稱含有特殊字元";
214-
if (hasSchemaName(name)) return "方案名稱與現有方案重複";
213+
if (!name) return t("方案名稱為空");
214+
if (invalidCharsRegex.test(name)) return t("方案名稱含有特殊字元");
215+
if (hasSchemaName(name)) return t("方案名稱與現有方案重複");
215216
return "";
216217
}, [createSchemaName, hasSchemaName]);
217218

@@ -339,7 +340,7 @@ const CreateSchemaDialog = forwardRef<HTMLDialogElement, CreateSchemaDialogProps
339340
<Action method="dialog" className="pure-form" onSubmit={addSchema}>
340341
<Rename>
341342
<label>
342-
<div>方案名稱顯示為</div>
343+
<div>{t("方案名稱顯示為")}</div>
343344
<input
344345
ref={inputRef}
345346
type="text"
@@ -354,10 +355,10 @@ const CreateSchemaDialog = forwardRef<HTMLDialogElement, CreateSchemaDialogProps
354355
</label>
355356
</Rename>
356357
<button type="reset" className="pure-button" onClick={closeDialog}>
357-
取消
358+
{t("取消")}
358359
</button>
359360
<button type="submit" className="pure-button pure-button-primary">
360-
新增
361+
{t("新增")}
361362
</button>
362363
</Action>
363364
<Validation>{validation || "\xa0"}</Validation>

src/Components/Main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export default function Main({ evaluateHandlerRef }: { evaluateHandlerRef: Mutab
349349
<TooltipLabel description={copyTooltipText} onHideTooltip={onHideTooltip}>
350350
<CopyButton onClick={copyEvaluationResult}>
351351
<FontAwesomeIcon icon={faCopy} size="sm" />
352-
<div>全部複製</div>
352+
<div>{t("全部複製")}</div>
353353
</CopyButton>
354354
</TooltipLabel>
355355
<form method="dialog">

src/Components/SchemaEditor.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
22
import { createPortal } from "react-dom";
33

4+
import { t } from "i18next";
5+
46
import { css } from "@emotion/react";
57
import styled from "@emotion/styled";
68
import { faFileCode } from "@fortawesome/free-regular-svg-icons";
@@ -26,7 +28,6 @@ import {
2628

2729
import type { UseMainState, ReactNode } from "../consts";
2830
import type { MouseEvent, MutableRefObject } from "react";
29-
import { t } from "i18next";
3031

3132
const TabBar = styled.div`
3233
display: flex;
@@ -590,9 +591,9 @@ export default function SchemaEditor({ state, setState, commonOptions, evaluateH
590591

591592
function validateFileName(name: string) {
592593
const hasSchemaName = (name: string) => schemas.find(schema => schema.name === name);
593-
if (!name) return "方案名稱為空";
594-
if (invalidCharsRegex.test(name)) return "方案名稱含有特殊字元";
595-
if (hasSchemaName(name)) return "方案名稱與現有方案重複";
594+
if (!name) return t("方案名稱為空");
595+
if (invalidCharsRegex.test(name)) return t("方案名稱含有特殊字元");
596+
if (hasSchemaName(name)) return t("方案名稱與現有方案重複");
596597
return "";
597598
}
598599

@@ -852,9 +853,9 @@ export default function SchemaEditor({ state, setState, commonOptions, evaluateH
852853
<OptionsTitle>
853854
<span>{t("選項")}</span>
854855
{activeSchema?.parameters.size || activeSchema?.parameters.errors.length ? (
855-
<ResetButton title="將所有選項恢復成預設值" onClick={resetParameters}>
856+
<ResetButton onClick={resetParameters}>
856857
<FontAwesomeIcon icon={faRotateLeft} size="sm" />
857-
<div>將所有選項恢復成預設值</div>
858+
<div>{t("將所有選項恢復為預設值")}</div>
858859
</ResetButton>
859860
) : null}
860861
</OptionsTitle>

src/evaluate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { t } from "i18next";
12
import { 推導方案 } from "tshet-uinh-deriver-tools";
23

34
import { Formatter } from "./Classes/CustomElement";
@@ -30,7 +31,7 @@ export default async function evaluate(state: MainState): Promise<ReactNode> {
3031

3132
if (option === "convertPresetArticle" && !getArticle())
3233
setArticle(await fetchFile(tshetUinhTextLabelURLPrefix + "index.txt"));
33-
else if (option === "compareSchemas" && schemas.length < 2) throw notifyError("此選項需要兩個或以上方案");
34+
else if (option === "compareSchemas" && schemas.length < 2) throw notifyError(t("此選項需要兩個或以上方案"));
3435
else await new Promise(resolve => setTimeout(resolve));
3536

3637
try {

src/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { createRoot } from "react-dom/client";
33

44
import App from "./Components/App";
55

6-
import "./i18n";
7-
86
const root = createRoot(document.getElementById("root")!);
97
root.render(
108
<StrictMode>

src/options.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export const evaluateOption: Record<Option, Handler> = {
169169
},
170170

171171
exportAllPositions({ schemas }, callDeriver) {
172-
return <Table head={["音韻地位", ...title(schemas), "代表字"]} body={finalize(iterate(callDeriver))} />;
172+
return <Table head={[t("音韻地位"), ...title(schemas), t("代表字")]} body={finalize(iterate(callDeriver))} />;
173173
},
174174

175175
exportAllSyllables({ schemas }, callDeriver) {
@@ -192,7 +192,7 @@ export const evaluateOption: Record<Option, Handler> = {
192192
}, null);
193193
return (
194194
<Table
195-
head={[...title(schemas), "計數"]}
195+
head={[...title(schemas), t("計數")]}
196196
body={result.sort((a, b) => b[2] - a[2]).map(([, 擬音陣列, count]) => [...wrap(擬音陣列), count + ""])}
197197
/>
198198
);
@@ -205,16 +205,13 @@ export const evaluateOption: Record<Option, Handler> = {
205205
return result.length ? (
206206
<>
207207
<Title>
208-
{t("schemaCompareDifferent", { count: result.length })}
208+
{t("找到 {{count}} 個相異項目。", { count: result.length })}
209209
<span hidden>{"\n\n"}</span>
210210
</Title>
211-
<Table
212-
head={[t("phonologicalPosition"), ...title(schemas), t("代表字")]}
213-
body={finalize(result)}
214-
/>
211+
<Table head={[t("音韻地位"), ...title(schemas), t("代表字")]} body={finalize(result)} />
215212
</>
216213
) : (
217-
<h3>{t("schemaCompareSame")}</h3>
214+
<h3>{t("方案推導結果相同。")}</h3>
218215
);
219216
},
220217
};

src/utils.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { t } from "i18next";
2+
13
import { css as stylesheet } from "@emotion/css";
24
import styled from "@emotion/styled";
35

@@ -66,9 +68,9 @@ export function notifyError(msg: string, err?: unknown) {
6668
}
6769
const config: SweetAlertOptions = {
6870
icon: "error",
69-
title: "錯誤",
71+
title: t("錯誤"),
7072
text: msg,
71-
confirmButtonText: "確定",
73+
confirmButtonText: t("確定-OK"),
7274
};
7375
if (technical !== null) {
7476
config.customClass = errorModal;

0 commit comments

Comments
 (0)