Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/settings-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function SettingsPage({
setActiveSection(section);
document.getElementById(sectionId)?.scrollIntoView?.({ block: "start", behavior: "smooth" });
}}
className={`whitespace-nowrap rounded-md px-3 py-2 text-left text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-background ${
className={`min-w-0 whitespace-normal break-words rounded-md px-3 py-2 text-left text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-background ${
selected
? "bg-indigo-600 text-white shadow-sm"
: "text-muted-foreground hover:bg-muted hover:text-foreground"
Expand Down Expand Up @@ -174,6 +174,7 @@ export function SettingsPage({
<SelectContent>
<SelectItem value="en">{t("settings.lang_en")}</SelectItem>
<SelectItem value="zh">{t("settings.lang_zh")}</SelectItem>
<SelectItem value="ja">{t("settings.lang_ja")}</SelectItem>
</SelectContent>
</Select>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import en from "./locales/en.json";
import zh from "./locales/zh.json";
import ja from "./locales/ja.json";

// Initialize language from localStorage or navigator language
const getInitialLanguage = (): string => {
try {
const saved = localStorage.getItem("language");
if (saved === "zh" || saved === "en") {
if (saved === "zh" || saved === "ja" || saved === "en") {
return saved;
}
} catch (e) {
Expand All @@ -19,6 +20,9 @@ const getInitialLanguage = (): string => {
if (browserLang.toLowerCase().includes("zh")) {
return "zh";
}
if (browserLang.toLowerCase().startsWith("ja")) {
return "ja";
}
return "en";
};

Expand All @@ -28,6 +32,7 @@ void i18n
resources: {
en: { translation: en },
zh: { translation: zh },
ja: { translation: ja },
},
lng: getInitialLanguage(),
fallbackLng: "en",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"title": "Codex Token Usage",
"subtitle": "Local developer token tracking and cost estimator.",
"last_updated": "Last updated {{time}}",
"updated_today": "Today at {{time}}",
"last_updated_never": "Never updated",
"rescan_duration": "Rescan completed in {{duration}}",
"refresh": "Refresh",
Expand Down Expand Up @@ -586,6 +587,7 @@
"language_label": "App Language",
"lang_en": "English",
"lang_zh": "简体中文",
"lang_ja": "日本語",
"menu_bar_title": "Menu Bar / System Tray Settings",
"menu_bar_desc": "Configure metrics for the macOS menu bar title, Windows tray tooltip, and tray menu.",
"menu_bar_show_title": "Show in Menu Bar / Tray Tooltip",
Expand Down
Loading