-
+
-
+
-
+
-
+
-
+
@@ -45,4 +46,11 @@ const Settings = () => {
);
};
-render(() =>
, document.getElementById("root") as HTMLElement);
+render(
+ () => (
+
+
+
+ ),
+ document.getElementById("root") as HTMLElement
+);
diff --git a/src/store/app-store.ts b/src/store/app-store.ts
index 79ee8eb8..7757bbd7 100644
--- a/src/store/app-store.ts
+++ b/src/store/app-store.ts
@@ -2,15 +2,23 @@ import { BsStarFill } from "solid-icons/bs";
import { CgMore } from "solid-icons/cg";
import { TbSearch } from "solid-icons/tb";
import { VsHistory } from "solid-icons/vs";
-import { createRoot, createSignal } from "solid-js";
+import { createResource, createRoot, createSignal } from "solid-js";
import { Tabs } from "../types";
-import { HotkeyEvent } from "../types/enums";
-import { TAB_NAMES, Tab } from "../utils/constants";
+import { HotkeyEvent, Language } from "../types/enums";
+import { LANGUAGE_KEY, TAB_NAMES, Tab } from "../utils/constants";
import { ClipboardStore } from "./clipboard-store";
import { HotkeyStore } from "./hotkey-store";
import { SettingsStore } from "./settings-store";
+import { invokeCommand } from "../lib/tauri";
+import { InvokeCommand } from "../types/tauri-invoke";
function createAppStore() {
+ const detectedLocale = localStorage.getItem(LANGUAGE_KEY) || Object.values(Language)[0];
+
+ const [locale, setLocale] = createResource(
+ async () => (await invokeCommand(InvokeCommand.GetSettings))?.language || detectedLocale
+ );
+
const [tabs, setTabs] = createSignal
([
{
name: TAB_NAMES[0],
@@ -46,6 +54,7 @@ function createAppStore() {
ClipboardStore.initClipboards();
await SettingsStore.initSettings();
darkMode();
+ setLocale.refetch();
};
const darkMode = () =>
@@ -54,6 +63,8 @@ function createAppStore() {
: document.querySelector("html")?.classList?.remove?.("dark");
return {
+ locale,
+ setLocale,
tabs,
setTabs,
changeTab,
diff --git a/src/store/clipboard-store.ts b/src/store/clipboard-store.ts
index 02544ed1..60a9013d 100644
--- a/src/store/clipboard-store.ts
+++ b/src/store/clipboard-store.ts
@@ -1,7 +1,7 @@
import { createRoot, createSignal } from "solid-js";
+import { invokeCommand } from "../lib/tauri";
import { ClipboardWhere, ClipboardWithRelations } from "../types";
import { InvokeCommand } from "../types/tauri-invoke";
-import { invokeCommand } from "../utils/tauri";
export const initialWhere: ClipboardWhere = {
cursor: undefined,
diff --git a/src/store/hotkey-store.ts b/src/store/hotkey-store.ts
index a7b8b651..4cef3d17 100644
--- a/src/store/hotkey-store.ts
+++ b/src/store/hotkey-store.ts
@@ -1,8 +1,8 @@
import { createRoot, createSignal } from "solid-js";
+import { invokeCommand } from "../lib/tauri";
import { Hotkey } from "../types";
import { HotkeyEvent } from "../types/enums";
import { InvokeCommand } from "../types/tauri-invoke";
-import { invokeCommand } from "../utils/tauri";
function createHotkeyStore() {
const [globalHotkeyEvent, enableGlobalHotkeyEvent] = createSignal(false);
diff --git a/src/store/settings-store.ts b/src/store/settings-store.ts
index f7e4d123..465c64f2 100644
--- a/src/store/settings-store.ts
+++ b/src/store/settings-store.ts
@@ -1,14 +1,14 @@
import { BsDatabaseFillGear } from "solid-icons/bs";
import { HiSolidCog8Tooth } from "solid-icons/hi";
import { RiDeviceKeyboardFill } from "solid-icons/ri";
+import { TbResize } from "solid-icons/tb";
import { VsHistory } from "solid-icons/vs";
import { createRoot, createSignal } from "solid-js";
+import { invokeCommand } from "../lib/tauri";
import { Settings, SettingsTab } from "../types";
import { WebWindow } from "../types/enums";
import { InvokeCommand } from "../types/tauri-invoke";
import { SETTINGS_TAB, SettingsTabName } from "../utils/constants";
-import { invokeCommand } from "../utils/tauri";
-import { TbResize } from "solid-icons/tb";
function createSettingsStore() {
const [tabs, setTabs] = createSignal([
diff --git a/src/types/enums.ts b/src/types/enums.ts
index a0f832b6..9740715e 100644
--- a/src/types/enums.ts
+++ b/src/types/enums.ts
@@ -58,6 +58,33 @@ export enum Language {
// ~200 million speakers
Urdu = "ur",
+
+ // ~170 million speakers
+ Japanese = "ja",
+
+ // ~160 million speakers
+ German = "de",
+
+ // ~130 million speakers
+ Korean = "ko",
+
+ // ~100 million speakers
+ Vietnamese = "vi",
+
+ // ~95 million speakers
+ Turkish = "tr",
+
+ // ~85 million speakers
+ Italian = "it",
+
+ // ~80 million speakers
+ Thai = "th",
+
+ // ~45 million speakers
+ Polish = "pl",
+
+ // ~30 million speakers
+ Dutch = "nl",
}
export enum HotkeyEvent {
diff --git a/src/types/index.ts b/src/types/index.ts
index df5d716f..f848a8e9 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -1,6 +1,7 @@
import { IconTypes } from "solid-icons";
-import { SettingsTabName, Tab, TabName } from "../utils/constants";
+import { Tab, TabName } from "../utils/constants";
import { ClipboardTextType, ClipboardType, ClippyPosition, HotkeyEvent, Language } from "./enums";
+import { DictionaryKey } from "../lib/i18n";
export type DatabaseInfo = {
records: number;
@@ -22,7 +23,7 @@ export type ClipboardWhere = {
};
export type SettingsTab = {
- name: SettingsTabName;
+ name: DictionaryKey;
Icon: IconTypes;
current: boolean;
};
@@ -114,7 +115,7 @@ export type Settings = {
dark_mode: boolean;
display_scale: number;
position: ClippyPosition;
-
+
max_file_size: number;
max_image_size: number;
max_text_size: number;
diff --git a/src/utils/constants.ts b/src/utils/constants.ts
index fcc268bd..85ecd129 100644
--- a/src/utils/constants.ts
+++ b/src/utils/constants.ts
@@ -1,6 +1,14 @@
+import { msg } from "../lib/i18n";
import { HotkeyEvent } from "../types/enums";
-export const SETTINGS_TAB = ["General", "Backup", "History", "Hotkeys", "Limits"] as const;
+export const LANGUAGE_KEY = "lang";
+export const SETTINGS_TAB = [
+ msg("SETTINGS.TAB.GENERAL"),
+ msg("SETTINGS.TAB.BACKUP"),
+ msg("SETTINGS.TAB.HISTORY"),
+ msg("SETTINGS.TAB.HOTKEYS"),
+ msg("SETTINGS.TAB.LIMITS"),
+] as const;
export const VIEW_MORE_NAMES = ["Sync Clipboard History", "Settings", "About", "Exit"] as const;
export const TAB_NAMES = ["Recent Clipboards", "Starred Clipboards", "History", "View more"] as const;
export const TABS = [
diff --git a/src/utils/helpers.ts b/src/utils/index.ts
similarity index 100%
rename from src/utils/helpers.ts
rename to src/utils/index.ts