Skip to content

Instantly share code, notes, and snippets.

@nishio
Created July 15, 2024 07:33
Show Gist options
  • Save nishio/d943564e36d7891cf4e24604ed27f30a to your computer and use it in GitHub Desktop.
Save nishio/d943564e36d7891cf4e24604ed27f30a to your computer and use it in GitHub Desktop.
Make UI Japanese (for Talk to the City Scatter)
From 18a3164dd9f51e97d9e01d9ea7f79cef7bc9a426 Mon Sep 17 00:00:00 2001
From: NISHIO Hirokazu <nishio.hirokazu@gmail.com>
Date: Sat, 15 Jun 2024 10:55:22 +0900
Subject: [PATCH] Make UI Japanese
---
.../hooks/useTranslatorAndReplacements.ts | 68 ++++++++++++++++---
1 file changed, 59 insertions(+), 9 deletions(-)
diff --git a/scatter/next-app/hooks/useTranslatorAndReplacements.ts b/scatter/next-app/hooks/useTranslatorAndReplacements.ts
index d2b4a90..5106aad 100644
--- a/scatter/next-app/hooks/useTranslatorAndReplacements.ts
+++ b/scatter/next-app/hooks/useTranslatorAndReplacements.ts
@@ -4,6 +4,50 @@ import * as OpenCC from "opencc-js";
let missing: { [key: string]: boolean } = {};
+const JapaneseUI: { [key: string]: string } = {
+ Argument: "議論",
+ "Original comment": "元のコメント",
+ "Representative arguments": "代表的な議論",
+ "Open full-screen map": "全画面地図を開く",
+ "Back to report": "レポートに戻る",
+ "Hide labels": "ラベルを非表示にする",
+ "Show labels": "ラベルを表示",
+ "Show filters": "フィルターを表示",
+ "Hide filters": "フィルターを非表示",
+ "Min. votes": "最小投票数",
+ Consensus: "コンセンサス",
+ Showing: "表示中",
+ arguments: "議論",
+ "Reset zoom": "ズームをリセット",
+ "Click anywhere on the map to close this":
+ "このメッセージを閉じるには地図のどこかをクリックしてください",
+ "Click on the dot for details": "詳細を見るには点をクリックしてください",
+ agree: "同意する",
+ disagree: "同意しない",
+ Language: "言語",
+ English: "英語",
+ "of total": "合計",
+ Overview: "概要",
+ "Cluster analysis": "クラスター分析",
+ "Representative comments": "代表的なコメント",
+ Introduction: "導入",
+ Clusters: "クラスター",
+ Appendix: "付録",
+ "This report was generated using an AI pipeline that consists of the following steps":
+ "このレポートは、以下のステップで構成されるAIパイプラインを使用して生成されました",
+ Step: "ステップ",
+ extraction: "抽出",
+ "show code": "コードを表示",
+ "hide code": "コードを非表示",
+ "show prompt": "プロンプトを表示",
+ "hide prompt": "プロンプトを非表示",
+ embedding: "埋め込み",
+ clustering: "クラスタリング",
+ labelling: "ラベリング",
+ takeaways: "まとめ",
+ overview: "概要",
+};
+
const useTranslatorAndReplacements = (
config: Config,
translations: Translations,
@@ -67,15 +111,21 @@ const useTranslatorAndReplacements = (
const t = useCallback(
(txt?: string) => {
if (!txt) return txt;
- if (langIndex === 0) return replaceAll(txt);
- const result = translations[txt]?.[langIndex - 1];
- if (!result) {
- if (!missing[txt]) {
- missing[txt] = true;
- console.log(`Missing translation for "${txt}"`);
- }
- }
- return fixLocalLang(replaceAll(result || txt));
+
+ // force Japanese UI
+ const result = JapaneseUI[txt];
+ if (!result) return txt;
+ return result;
+
+ // if (langIndex === 0) return replaceAll(txt);
+ // const result = translations[txt]?.[langIndex - 1];
+ // if (!result) {
+ // if (!missing[txt]) {
+ // missing[txt] = true;
+ // console.log(`Missing translation for "${txt}"`);
+ // }
+ // }
+ // return fixLocalLang(replaceAll(result || txt));
},
[langIndex, replaceAll]
);
--
2.37.1 (Apple Git-137.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment