Feature: i18n (#70)

* chore: add @inlang/paraglide-sveltekit to @kksh/ui

* feat: add i18n to desktop

* fix: add shrink-0 class to mode-toggle button for consistent styling

* feat: add i18n to settings, not working yet

* feat: i18 working

* feat: add i18n for about

* feat: migrate all goto to use i18n.resolveRoute

* feat: finish translating settings to chinese

* feat: add Chinese i18n for troubleshooters

* feat: add russian translation (by AI)

* format: run prettier

* format

* chore: update .prettierignore to exclude src/lib/paraglide/**
This commit is contained in:
Huakun Shen 2025-01-19 23:22:15 -05:00 committed by GitHub
parent c260ca2fc2
commit b115e0a574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 1516 additions and 246 deletions

View File

@ -14,7 +14,6 @@
"@kksh/utils",
"@kksh/extension",
"@kksh/schema",
"@kksh/supabase",
"@kksh/ui"
"@kksh/supabase"
]
}

23
.github/workflows/ninja_i18n.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: Ninja i18n action
on: pull_request_target
# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
permissions:
pull-requests: write # Necessary to comment on PRs
issues: read # Necessary to read issue comments
contents: read # Necessary to access the repo content
jobs:
ninja-i18n:
name: Ninja i18n - GitHub Lint Action
runs-on: ubuntu-latest
steps:
- name: Run Ninja i18n
# @main ensures that the latest version of the action is used
uses: opral/ninja-i18n-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -43,3 +43,8 @@ pnpm --filter @kksh/desktop tauri dev
cd apps/desktop
pnpm tauri dev
```
## i188n
If you are willing to help with the translation, please use translations in json files in `apps/desktop/messages`.
Use `en.json` as a reference.

View File

@ -1,11 +1,5 @@
# kksh
## 0.0.30
### Patch Changes
- Add version check to cli, check if package.json and jsr.json have different versions
## 0.0.29
### Patch Changes

BIN
apps/cli/bun.lockb Executable file

Binary file not shown.

View File

@ -1,7 +1,7 @@
{
"name": "kksh",
"module": "dist/cli.js",
"version": "0.0.30",
"version": "0.0.29",
"type": "module",
"bin": {
"kksh": "./dist/cli.js",

View File

@ -32,45 +32,6 @@ export function verifyTemplateUiCommand(projectRoot: string, cmd: TemplateUiCmd)
return true
}
export function verifyVersion(projectPath: string): boolean {
const pkgJsonPath = path.join(projectPath, "package.json")
const jsrJsonPath = path.join(projectPath, "jsr.json")
const denoJsonPath = path.join(projectPath, "deno.json")
const versions = { npm: undefined, jsr: undefined, deno: undefined }
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"))
versions.npm = pkgJson.version
if (fs.existsSync(jsrJsonPath)) {
const jsrJson = JSON.parse(fs.readFileSync(jsrJsonPath, "utf-8"))
versions.jsr = jsrJson.version
}
if (fs.existsSync(denoJsonPath)) {
const denoJson = JSON.parse(fs.readFileSync(denoJsonPath, "utf-8"))
versions.deno = denoJson.version
}
if (!versions.npm) {
logger.error(`version is not set in package.json`)
return false
}
if (fs.existsSync(jsrJsonPath) && fs.existsSync(denoJsonPath)) {
logger.error(`Both jsr.json and deno.json are present, only one is allowed`)
return false
}
if (versions.jsr && versions.jsr !== versions.npm) {
logger.error(
`jsr.json version ${versions.jsr} does not match package.json version ${versions.npm}`
)
return false
}
if (versions.deno && versions.deno !== versions.npm) {
logger.error(
`deno.json version ${versions.deno} does not match package.json version ${versions.npm}`
)
return false
}
return true
}
export function verifySingleProject(projectPath: string): boolean {
logger.info(`Verifying project at ${projectPath}`)
const pkgJsonPath = path.join(projectPath, "package.json")
@ -91,7 +52,7 @@ export function verifySingleProject(projectPath: string): boolean {
logger.info(`name`, pkg.name)
logger.info(`version`, pkg.version)
logger.info(`identifier`, pkg.kunkun.identifier)
if (!pkg.files?.length) {
if (pkg.files.length === 0) {
logger.warn(
`"files" field is empty, it is recommended to include only the necessary files, e.g. dist`
)
@ -105,9 +66,6 @@ export function verifySingleProject(projectPath: string): boolean {
pkg.kunkun.identifier = folderName
// }
}
if (!verifyVersion(projectPath)) {
return false
}
for (const cmd of pkg.kunkun.customUiCmds ?? []) {
if (!verifyCustomUiCommand(projectPath, cmd)) {
return false

View File

@ -1 +1,2 @@
src-tauri
src-tauri
src/lib/paraglide/**

View File

@ -0,0 +1,81 @@
{
"$schema": "https://inlang.com/schema/inlang-message-format",
"app_name": "KunKun",
"secondary_app_name": "KunKun",
"common_edit": "Edit",
"common_clear": "Clear",
"common_check": "Check",
"common_install": "Install",
"home_command_input_placeholder": "Type a command or search...",
"home_command_input_dropdown_quit": "Quit",
"home_command_input_dropdown_developer_title": "Developer",
"home_command_input_dropdown_close_window": "Close Window",
"home_command_input_dropdown_toggle_devtools": "Toggle Devtools",
"home_command_input_dropdown_reload_window": "Reload Window",
"home_command_input_dropdown_toggle_dev_extension_hmr": "Toggle Dev Extension HMR",
"command_group_heading_dev_ext": "Dev Extensions",
"command_group_heading_ext": "Extensions",
"command_group_heading_quick_links": "Quick Links",
"settings_menu_settings": "Settings",
"settings_menu_general": "General",
"settings_menu_developer": "Developer",
"settings_menu_extensions": "Extensions",
"settings_menu_set_dev_ext": "Set Dev Extension",
"settings_menu_add_dev_ext": "Add Dev Extension",
"settings_menu_about": "About",
"settings_general_launch_at_login": "Launch at Login",
"settings_general_hotkey": "Hotkey",
"settings_general_menu_bar_icon": "Menu Bar Icon",
"settings_general_hide_on_blur": "Hide On Blur",
"settings_general_extension_auto_upgrade": "Extension Auto Upgrade",
"settings_general_dev_extension_hmr": "Dev Extension HMR",
"settings_general_join_beta_updates": "Join Beta Updates",
"settings_general_developer_mode": "Developer Mode",
"settings_general_language": "Language",
"settings_about_version": "Version",
"settings_about_author": "Author",
"settings_about_source_code": "Source Code",
"settings_about_extensions_source_code": "Extensions Source Code",
"settings_about_check_for_updates": "Check for Updates",
"settings_set_dev_ext_title": "Set Dev Extension Path",
"settings_set_dev_ext_description": "This is where your extensions will be installed.",
"settings_set_dev_ext_enter_path": "Enter Path",
"settings_extensions_title": "Your Extensions",
"settings_extensions_table_col_name": "Name",
"settings_extensions_table_col_identifier": "Identifier",
"settings_extensions_table_col_type": "Type",
"settings_extensions_table_col_version": "Version",
"settings_extensions_table_col_uninstall": "Uninstall",
"settings_add_dev_ext_title": "Add Dev Extension",
"settings_add_dev_ext_description": "There are 4 options to install an extension in developer mode. Either load it from your local tarball file, a tarball remote URL, npm package name or load from a remote URL.",
"settings_add_dev_ext_install_from_ext_folders": "Install from Extension Folders",
"settings_add_dev_ext_install_from_ext_files": "Install from Extension Tarball File",
"settings_add_dev_ext_drag_and_drop": "Drag and Drop",
"settings_add_dev_ext_drag_and_drop2": "Extension Folder or Tarball",
"settings_add_dev_ext_install_tarball_from_url": "Install Tarball From URL",
"troubleshooters_sidebar_title": "Troubleshooters",
"troubleshooters_sidebar_extension_loading_title": "Extension Loading",
"troubleshooters_sidebar_extension_window_title": "Extension Window",
"troubleshooters_sidebar_mdns_debugger_title": "MDNS Debugger",
"troubleshooters_extension_window_title": "Extension Window Troubleshooter",
"troubleshooters_extension_window_refresh_every_second": "Refresh Every Second",
"troubleshooters_extension_window_refresh": "Refresh",
"troubleshooters_extension_window_refreshed": "Refreshed {count} times",
"troubleshooters_extension_loading_title": "Extension Loading Troubleshooter",
"troubleshooters_extension_loading_table_col_identifier": "Identifier",
"troubleshooters_extension_loading_table_col_path": "Path",
"troubleshooters_extension_loading_table_col_error": "Error"
}

View File

@ -0,0 +1,81 @@
{
"$schema": "https://inlang.com/schema/inlang-message-format",
"app_name": "KunKun",
"secondary_app_name": "KunKun",
"common_edit": "Редактировать",
"common_clear": "Очистить",
"common_check": "Проверить",
"common_install": "Установить",
"home_command_input_placeholder": "Введите команду или поиск...",
"home_command_input_dropdown_quit": "Выйти",
"home_command_input_dropdown_developer_title": "Разработчик",
"home_command_input_dropdown_close_window": "Закрыть окно",
"home_command_input_dropdown_toggle_devtools": "Переключить Devtools",
"home_command_input_dropdown_reload_window": "Перезагрузить окно",
"home_command_input_dropdown_toggle_dev_extension_hmr": "Переключить HMR",
"command_group_heading_dev_ext": "Разработчики",
"command_group_heading_ext": "Расширения",
"command_group_heading_quick_links": "Быстрые ссылки",
"settings_menu_settings": "Настройки",
"settings_menu_general": "Общие",
"settings_menu_developer": "Разработчик",
"settings_menu_extensions": "Расширения",
"settings_menu_set_dev_ext": "Установить расширение",
"settings_menu_add_dev_ext": "Добавить расширение",
"settings_menu_about": "О программе",
"settings_general_launch_at_login": "Запуск при входе",
"settings_general_hotkey": "Горячая клавиша",
"settings_general_menu_bar_icon": "Иконка в меню",
"settings_general_hide_on_blur": "Скрыть при потере фокуса",
"settings_general_extension_auto_upgrade": "Автообновление расширений",
"settings_general_dev_extension_hmr": "HMR",
"settings_general_join_beta_updates": "Присоединиться к бета-версиям",
"settings_general_developer_mode": "Режим разработчика",
"settings_general_language": "Язык",
"settings_about_version": "Версия",
"settings_about_author": "Автор",
"settings_about_source_code": "Исходный код",
"settings_about_extensions_source_code": "Исходный код расширений",
"settings_about_check_for_updates": "Проверить на наличие обновлений",
"settings_set_dev_ext_title": "Установить путь к расширению",
"settings_set_dev_ext_description": "Это место, где будут установлены ваши расширения.",
"settings_set_dev_ext_enter_path": "Введите путь",
"settings_extensions_title": "Ваши расширения",
"settings_extensions_table_col_name": "Название",
"settings_extensions_table_col_identifier": "Идентификатор",
"settings_extensions_table_col_type": "Тип",
"settings_extensions_table_col_version": "Версия",
"settings_extensions_table_col_uninstall": "Удалить",
"settings_add_dev_ext_title": "Добавить расширение",
"settings_add_dev_ext_description": "Есть 4 способа установить расширение в режиме разработчика. Либо загрузите его из вашего локального файла tarball, URL-адреса tarball, npm-пакета или URL-адреса.",
"settings_add_dev_ext_install_from_ext_folders": "Установить из папки расширений",
"settings_add_dev_ext_install_from_ext_files": "Установить из файла tarball",
"settings_add_dev_ext_drag_and_drop": "Перетащите и отпустите",
"settings_add_dev_ext_drag_and_drop2": "Папка расширений или файл tarball",
"settings_add_dev_ext_install_tarball_from_url": "Установить tarball из URL",
"troubleshooters_sidebar_title": "Troubleshooters",
"troubleshooters_sidebar_extension_loading_title": "Загрузка расширения",
"troubleshooters_sidebar_extension_window_title": "Окно расширения",
"troubleshooters_sidebar_mdns_debugger_title": "MDNS Debugger",
"troubleshooters_extension_window_title": "Troubleshooter расширения",
"troubleshooters_extension_window_refresh_every_second": "Обновлять каждую секунду",
"troubleshooters_extension_window_refresh": "Обновить",
"troubleshooters_extension_window_refreshed": "Обновлено {count} раз",
"troubleshooters_extension_loading_title": "Troubleshooter загрузки расширения",
"troubleshooters_extension_loading_table_col_identifier": "Идентификатор",
"troubleshooters_extension_loading_table_col_path": "Путь",
"troubleshooters_extension_loading_table_col_error": "Ошибка"
}

View File

@ -0,0 +1,81 @@
{
"$schema": "https://inlang.com/schema/inlang-message-format",
"app_name": "KunKun",
"secondary_app_name": "鲲鲲",
"common_edit": "编辑",
"common_clear": "清除",
"common_check": "检查",
"common_install": "安装",
"home_command_input_placeholder": "输入命令或搜索...",
"home_command_input_dropdown_quit": "退出",
"home_command_input_dropdown_developer_title": "开发者",
"home_command_input_dropdown_close_window": "关闭窗口",
"home_command_input_dropdown_toggle_devtools": "切换开发者工具",
"home_command_input_dropdown_reload_window": "重新加载窗口",
"home_command_input_dropdown_toggle_dev_extension_hmr": "切换开发插件 HMR",
"command_group_heading_dev_ext": "开发插件",
"command_group_heading_ext": "插件",
"command_group_heading_quick_links": "快捷链接",
"settings_menu_settings": "设置",
"settings_menu_general": "通用",
"settings_menu_developer": "开发者",
"settings_menu_extensions": "插件",
"settings_menu_set_dev_ext": "设置开发插件",
"settings_menu_add_dev_ext": "添加开发插件",
"settings_menu_about": "关于",
"settings_general_launch_at_login": "开机启动",
"settings_general_hotkey": "快捷键",
"settings_general_menu_bar_icon": "菜单栏图标",
"settings_general_hide_on_blur": "隐藏在后台",
"settings_general_extension_auto_upgrade": "自动更新插件",
"settings_general_dev_extension_hmr": "开发模式",
"settings_general_join_beta_updates": "加入 Beta 更新",
"settings_general_developer_mode": "开发者模式",
"settings_general_language": "语言",
"settings_about_version": "版本",
"settings_about_author": "作者",
"settings_about_source_code": "源代码",
"settings_about_extensions_source_code": "插件源代码",
"settings_about_check_for_updates": "检查更新",
"settings_set_dev_ext_title": "设置开发插件安装路径",
"settings_set_dev_ext_description": "这是你的开发插件将被安装的地方。",
"settings_set_dev_ext_enter_path": "输入路径",
"settings_extensions_title": "你的插件",
"settings_extensions_table_col_name": "名称",
"settings_extensions_table_col_identifier": "标识符",
"settings_extensions_table_col_type": "类型",
"settings_extensions_table_col_version": "版本",
"settings_extensions_table_col_uninstall": "卸载",
"settings_add_dev_ext_title": "添加开发插件",
"settings_add_dev_ext_description": "有四种方法可以在开发模式下安装插件。 从本地 tarball 文件、tarball 远程 URL、npm 包名称或远程 URL 加载。",
"settings_add_dev_ext_install_from_ext_folders": "从插件文件夹安装",
"settings_add_dev_ext_install_from_ext_files": "从插件 tarball 文件安装",
"settings_add_dev_ext_drag_and_drop": "拖放",
"settings_add_dev_ext_drag_and_drop2": "插件文件夹或 tarball",
"settings_add_dev_ext_install_tarball_from_url": "从 tarball URL 安装",
"troubleshooters_sidebar_title": "故障排除器",
"troubleshooters_sidebar_extension_loading_title": "插件加载",
"troubleshooters_sidebar_extension_window_title": "插件窗口",
"troubleshooters_sidebar_mdns_debugger_title": "MDNS 调试器",
"troubleshooters_extension_window_title": "插件窗口故障排除器",
"troubleshooters_extension_window_refresh_every_second": "每秒刷新",
"troubleshooters_extension_window_refresh": "刷新",
"troubleshooters_extension_window_refreshed": "已刷新 {count} 次",
"troubleshooters_extension_loading_title": "插件加载故障排除器",
"troubleshooters_extension_loading_table_col_identifier": "标识符",
"troubleshooters_extension_loading_table_col_path": "路径",
"troubleshooters_extension_loading_table_col_error": "错误"
}

View File

@ -1,6 +1,6 @@
{
"name": "@kksh/desktop",
"version": "0.1.16",
"version": "0.1.17",
"description": "",
"type": "module",
"scripts": {
@ -35,7 +35,8 @@
"sveltekit-superforms": "^2.22.1",
"tauri-plugin-clipboard-api": "^2.1.11",
"tauri-plugin-user-input-api": "workspace:*",
"uuid": "^11.0.3"
"uuid": "^11.0.3",
"@inlang/paraglide-sveltekit": "0.15.5"
},
"devDependencies": {
"@eslint/js": "^9.18.0",
@ -68,6 +69,7 @@
"tslib": "^2.8.1",
"typescript": "^5.6.3",
"typescript-eslint": "^8.20.0",
"vite": "^6.0.3"
"vite": "^6.0.3",
"@inlang/paraglide-js": "1.11.8"
}
}

View File

@ -0,0 +1 @@
cache

View File

@ -0,0 +1 @@
9800f324a732adb2ed22a4b600a0025820caaba8c4d886b0949b04616bba4726

View File

@ -0,0 +1,15 @@
{
"$schema": "https://inlang.com/schema/project-settings",
"sourceLanguageTag": "en",
"languageTags": ["en", "zh", "ru"],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js"
],
"plugin.inlang.messageFormat": {
"pathPattern": "./messages/{languageTag}.json"
}
}

View File

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="%paraglide.lang%" dir="%paraglide.textDirection%">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />

View File

@ -0,0 +1,6 @@
// file initialized by the Paraglide-SvelteKit CLI - Feel free to edit it
import { sequence } from "@sveltejs/kit/hooks"
import { i18n } from "$lib/i18n"
// add your own hooks as part of the sequence here
export const handle = sequence(i18n.handle())

View File

@ -0,0 +1,4 @@
// file initialized by the Paraglide-SvelteKit CLI - Feel free to edit it
import { i18n } from "$lib/i18n"
export const reroute = i18n.reroute()

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { appConfig, appState, auth, extensions } from "@/stores"
import { checkUpdateAndInstall } from "@/utils/updater"
import { setTransparentTitlebar } from "@kksh/api/commands"
@ -25,7 +26,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Go to Extension Store",
function: async () => {
appState.clearSearchTerm()
goto("/app/extension/store")
goto(i18n.resolveRoute("/app/extension/store"))
}
},
{
@ -36,7 +37,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "",
function: async () => {
goto("/app/auth")
goto(i18n.resolveRoute("/app/auth"))
}
},
{
@ -98,7 +99,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "",
function: async () => {
goto("/app/extension/file-transfer")
goto(i18n.resolveRoute("/app/extension/file-transfer"))
appState.clearSearchTerm()
}
},
@ -112,7 +113,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/settings/add-dev-extension")
goto(i18n.resolveRoute("/app/settings/add-dev-extension"))
}
},
{
@ -137,7 +138,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
function: async () => {
// const appStateStore = useAppStateStore()
appState.clearSearchTerm()
goto("/app/settings/set-dev-ext-path")
goto(i18n.resolveRoute("/app/settings/set-dev-ext-path"))
}
},
{
@ -149,7 +150,6 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
// goto("/app/window-troubleshooter")
const winLabel = `main:extension-window-troubleshooter-${uuidv4()}`
console.log(winLabel)
new WebviewWindow(winLabel, {
@ -168,7 +168,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/help/deno-install")
goto(i18n.resolveRoute("/app/help/deno-install"))
},
keywords: ["help", "deno", "install"]
},
@ -181,7 +181,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/help/ffmpeg-install")
goto(i18n.resolveRoute("/app/help/ffmpeg-install"))
},
keywords: ["help", "ffmpeg", "install"]
},
@ -194,7 +194,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/help/brew-install")
goto(i18n.resolveRoute("/app/help/brew-install"))
},
keywords: ["help", "brew", "install", "homebrew"]
},
@ -207,7 +207,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/help/onboarding")
goto(i18n.resolveRoute("/app/help/onboarding"))
},
flags: {
dev: true,
@ -223,7 +223,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/extension/permission-inspector")
goto(i18n.resolveRoute("/app/extension/permission-inspector"))
},
keywords: ["extension"]
},
@ -236,7 +236,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "",
function: async () => {
appState.clearSearchTerm()
goto("/app/troubleshooters/extension-loading")
goto(i18n.resolveRoute("/app/troubleshooters/extension-loading"))
},
keywords: ["extension", "troubleshooter"]
},
@ -249,7 +249,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Create a Quicklink",
function: async () => {
appState.clearSearchTerm()
goto("/app/extension/create-quick-link")
goto(i18n.resolveRoute("/app/extension/create-quick-link"))
}
},
{
@ -261,7 +261,6 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Display the current key",
function: async () => {
appState.clearSearchTerm()
// goto("/app/extension/key-displayer")
const label = `main:extension:key-displayer-${uuidv4()}`
new WebviewWindow(label, {
url: "/app/extension/key-displayer",
@ -284,7 +283,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "Open Settings",
function: async () => {
goto("/app/settings")
goto(i18n.resolveRoute("/app/settings"))
appState.clearSearchTerm()
}
},
@ -344,7 +343,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "Dance",
function: async () => {
goto("/app/dance")
goto(i18n.resolveRoute("/app/dance"))
}
},
{
@ -385,7 +384,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
description: "Clipboard History",
function: async () => {
appState.clearSearchTerm()
goto("/app/extension/clipboard")
goto(i18n.resolveRoute("/app/extension/clipboard"))
}
},
{
@ -422,7 +421,7 @@ export const rawBuiltinCmds: BuiltinCmd[] = [
},
description: "MDNS Debugger",
function: async () => {
goto("/app/troubleshooters/mdns-debugger")
goto(i18n.resolveRoute("/app/troubleshooters/mdns-debugger"))
},
flags: {
developer: true

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { appState } from "@/stores"
import { winExtMap } from "@/stores/winExtMap"
import { trimSlash } from "@/utils/url"
@ -7,6 +8,7 @@ import { HeadlessWorkerExtension } from "@kksh/api/headless"
import { CustomUiCmd, ExtPackageJsonExtra, HeadlessCmd, TemplateUiCmd } from "@kksh/api/models"
import { constructJarvisServerAPIWithPermissions, type IApp } from "@kksh/api/ui"
import { launchNewExtWindow, loadExtensionManifestFromDisk } from "@kksh/extension"
import type { IKunkunFullServerAPI } from "@kunkunapi/src/api/server"
import { convertFileSrc } from "@tauri-apps/api/core"
import * as path from "@tauri-apps/api/path"
import * as fs from "@tauri-apps/plugin-fs"
@ -38,7 +40,7 @@ export async function onTemplateUiCmdSelect(
} else {
return winExtMap
.registerExtensionWithWindow({ windowLabel: "main", extPath: ext.extPath })
.then(() => goto(url))
.then(() => goto(i18n.resolveRoute(url)))
}
}
@ -65,16 +67,19 @@ export async function onHeadlessCmdSelect(
loadedExt.kunkun.permissions,
loadedExt.extPath
)
serverAPI.iframeUi = undefined
serverAPI.workerUi = undefined
serverAPI.db = new db.JarvisExtDB(extInfoInDB.extId)
serverAPI.kv = new db.KV(extInfoInDB.extId)
serverAPI.app = {
language: () => Promise.resolve("en")
} satisfies IApp
const serverAPI2 = {
...serverAPI,
iframeUi: undefined,
workerUi: undefined,
db: new db.JarvisExtDB(extInfoInDB.extId),
kv: new db.KV(extInfoInDB.extId),
app: {
language: () => Promise.resolve("en")
} satisfies IApp
}
const io = new WorkerParentIO(worker)
const rpc = new RPCChannel<typeof serverAPI, HeadlessWorkerExtension>(io, {
expose: serverAPI
const rpc = new RPCChannel<typeof serverAPI2, HeadlessWorkerExtension>(io, {
expose: serverAPI2
})
const workerAPI = rpc.getAPI()
await workerAPI.load()
@ -124,7 +129,7 @@ export async function onCustomUiCmdSelect(
const newUrl = `http://${addr}`
url2 = `/app/extension/ui-iframe?url=${encodeURIComponent(newUrl)}&extPath=${encodeURIComponent(ext.extPath)}`
}
goto(url2)
goto(i18n.resolveRoute(url2))
}
appState.clearSearchTerm()
}

View File

@ -1,43 +1,85 @@
<script lang="ts">
import HotkeyPick from "@/components/standalone/settings/hotkey-pick.svelte"
import { LanguageMap } from "@/constants"
import { i18n, switchToLanguage } from "@/i18n"
import * as m from "@/paraglide/messages"
import {
availableLanguageTags,
languageTag,
setLanguageTag,
type AvailableLanguageTag
} from "@/paraglide/runtime"
import { appConfig } from "@/stores"
import { Button, Switch } from "@kksh/svelte5"
import { Select, Switch } from "@kksh/svelte5"
const languages = availableLanguageTags.map((lang) => ({
value: lang,
label: LanguageMap[lang] ?? lang
}))
let value = $state(languageTag())
const triggerContent = $derived(languages.find((f) => f.value === value)?.label ?? "Language")
</script>
<ul class="rounded-lg border">
<li>
<span>Launch at Login</span>
<span>{m.settings_general_launch_at_login()}</span>
<Switch bind:checked={$appConfig.launchAtLogin} />
</li>
<li class="">
<span>Hotkey</span>
<span>{m.settings_general_hotkey()}</span>
<HotkeyPick />
</li>
<li>
<span>Menu Bar Icon</span>
<span>{m.settings_general_menu_bar_icon()}</span>
<Switch bind:checked={$appConfig.showInTray} />
</li>
<li>
<span>Hide On Blur</span>
<span>{m.settings_general_hide_on_blur()}</span>
<Switch bind:checked={$appConfig.hideOnBlur} />
</li>
<li>
<span>Extension Auto Upgrade</span>
<span>{m.settings_general_extension_auto_upgrade()}</span>
<Switch bind:checked={$appConfig.extensionAutoUpgrade} />
</li>
<li>
<span>Dev Extension HMR</span>
<span>{m.settings_general_dev_extension_hmr()}</span>
<Switch bind:checked={$appConfig.hmr} />
</li>
<li>
<span>Join Beta Updates</span>
<span>{m.settings_general_join_beta_updates()}</span>
<Switch bind:checked={$appConfig.joinBetaProgram} />
</li>
<li>
<span>Developer Mode</span>
<span>{m.settings_general_developer_mode()}</span>
<Switch bind:checked={$appConfig.developerMode} />
</li>
<li>
<span>{m.settings_general_language()}</span>
<Select.Root type="single" name="language" bind:value>
<Select.Trigger class="w-fit">
{triggerContent}
</Select.Trigger>
<Select.Content>
<Select.Group>
<Select.GroupHeading>{m.settings_general_language()}</Select.GroupHeading>
{#each languages as lang}
<Select.Item
onclick={() => {
appConfig.setLanguage(lang.value)
switchToLanguage(lang.value as AvailableLanguageTag)
}}
value={lang.value}
label={lang.label}>{lang.label}</Select.Item
>
{/each}
</Select.Group>
</Select.Content>
</Select.Root>
</li>
</ul>
<style scoped>

View File

@ -1,6 +1,8 @@
<script lang="ts">
import DragNDrop from "@/components/common/DragNDrop.svelte"
import DevExtPathForm from "@/components/standalone/settings/DevExtPathForm.svelte"
import { i18n } from "@/i18n"
import * as m from "@/paraglide/messages"
import { appConfig, extensions } from "@/stores"
import { goBackOnEscape } from "@/utils/key"
import { goBack } from "@/utils/route"
@ -87,7 +89,7 @@
async function pickExtFiles() {
if (!$appConfig.devExtensionPath) {
toast.warning("Please set the dev extension path in the settings")
return goto("/app/settings/set-dev-ext-path")
return goto(i18n.resolveRoute("/app/settings/set-dev-ext-path"))
}
const selected = await openFileSelector({
directory: false,
@ -109,12 +111,15 @@
</script>
<div class="my-3 flex justify-center gap-3">
<Button size="sm" onclick={pickExtFolders}>Install from Extension Folders</Button>
<Button size="sm" onclick={pickExtFiles}>Install from Extension Tarball File</Button>
<Button size="sm" onclick={pickExtFolders}
>{m.settings_add_dev_ext_install_from_ext_folders()}</Button
>
<Button size="sm" onclick={pickExtFiles}>{m.settings_add_dev_ext_install_from_ext_files()}</Button
>
</div>
<StrikeSeparator class="my-1">
<h3 class="text-muted-foreground font-mono text-sm">Drag and Drop</h3>
<h3 class="text-muted-foreground font-mono text-sm">{m.settings_add_dev_ext_drag_and_drop()}</h3>
</StrikeSeparator>
<Layouts.Center>
@ -145,15 +150,21 @@
icon={{ value: "mdi:folder-cog-outline", type: IconEnum.Iconify }}
class="h-10 w-10"
/>
<small class="select-none font-mono text-xs">Drag and Drop</small>
<small class="select-none font-mono text-xs">Extension Folder or Tarball</small>
<small class="select-none font-mono text-xs"
>{m.settings_add_dev_ext_drag_and_drop()}</small
>
<small class="select-none font-mono text-xs"
>{m.settings_add_dev_ext_drag_and_drop2()}</small
>
</div>
</button>
</Card.Root>
</DragNDrop>
</Layouts.Center>
<StrikeSeparator class="my-1">
<h3 class="text-muted-foreground font-mono text-sm">Install Tarball From URL</h3>
<h3 class="text-muted-foreground font-mono text-sm">
{m.settings_add_dev_ext_install_tarball_from_url()}
</h3>
</StrikeSeparator>
<InstallTarballUrlForm />
<InstallNpmPackageNameForm />

View File

@ -1,13 +1,11 @@
<script lang="ts">
import * as m from "@/paraglide/messages"
import { appConfig } from "@/stores"
import Icon from "@iconify/svelte"
import { Button, Input } from "@kksh/svelte5"
import { open } from "@tauri-apps/plugin-dialog"
import { exists } from "@tauri-apps/plugin-fs"
import { toast } from "svelte-sonner"
import { superForm, type Infer, type SuperValidated } from "sveltekit-superforms"
import { zodClient } from "sveltekit-superforms/adapters"
import { z } from "zod"
let devExtPath = $state<string | undefined>(undefined)
@ -31,13 +29,18 @@
</script>
<form class="flex w-full items-center space-x-2">
<Input disabled type="text" placeholder="Enter Path" bind:value={$appConfig.devExtensionPath} />
<Input
disabled
type="text"
placeholder={m.settings_set_dev_ext_enter_path()}
bind:value={$appConfig.devExtensionPath}
/>
<Button size="sm" type="button" onclick={clear}>
Clear
{m.common_clear()}
<Icon icon="material-symbols:delete-outline" class="ml-1 h-5 w-5" />
</Button>
<Button size="sm" type="button" onclick={pickDirectory}>
Edit
{m.common_edit()}
<Icon icon="flowbite:edit-outline" class="ml-1 h-5 w-5" />
</Button>
</form>

View File

@ -1,4 +1,5 @@
<script lang="ts">
import { i18n } from "@/i18n"
import { appConfig, extensions } from "@/stores"
import { Input } from "@kksh/svelte5"
import { Form } from "@kksh/ui"
@ -17,7 +18,7 @@
toast.warning(
"Please set the dev extension path in the settings to install tarball extension"
)
return goto("/app/settings/set-dev-ext-path")
return goto(i18n.resolveRoute("/app/settings/set-dev-ext-path"))
}
await extensions
.installFromNpmPackageName(data.name, $appConfig.devExtensionPath)

View File

@ -1,4 +1,6 @@
<script lang="ts">
import { i18n } from "@/i18n"
import * as m from "@/paraglide/messages"
import { appConfig, extensions } from "@/stores"
import { Input } from "@kksh/svelte5"
import { Form } from "@kksh/ui"
@ -19,7 +21,7 @@
toast.warning(
"Please set the dev extension path in the settings to install tarball extension"
)
return goto("/app/settings/set-dev-ext-path")
return goto(i18n.resolveRoute("/app/settings/set-dev-ext-path"))
}
await extensions
.installFromTarballUrl(data.url, $appConfig.devExtensionPath)
@ -53,7 +55,7 @@
{#snippet children({ props })}
<div class="flex items-center gap-2">
<Input {...props} bind:value={$formData.url} placeholder="Tarball URL" />
<Form.Button class="my-1">Install</Form.Button>
<Form.Button class="my-1">{m.common_install()}</Form.Button>
</div>
{/snippet}
</Form.Control>

View File

@ -19,3 +19,9 @@ export function getExtensionsFolder() {
export const IS_IN_TAURI =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof window !== "undefined" && (window as any).__TAURI_INTERNALS__ !== undefined
export const LanguageMap = {
en: "English",
zh: "中文",
ru: "Русский"
}

View File

@ -0,0 +1,17 @@
// file initialized by the Paraglide-SvelteKit CLI - Feel free to edit it
import { createI18n } from "@inlang/paraglide-sveltekit"
import { goto } from "$app/navigation"
import { page } from "$app/state"
import * as runtime from "$lib/paraglide/runtime.js"
import { tick } from "svelte"
export const i18n = createI18n(runtime)
export function switchToLanguage(newLanguage: runtime.AvailableLanguageTag) {
runtime.setLanguageTag(newLanguage)
const canonicalPath = i18n.route(page.url.pathname)
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage)
tick().then(() => {
goto(localisedPath)
})
}

View File

@ -7,10 +7,12 @@ import * as os from "@tauri-apps/plugin-os"
import { load } from "@tauri-apps/plugin-store"
import { get, writable } from "svelte/store"
import * as v from "valibot"
import { setLanguageTag } from "../paraglide/runtime"
export const defaultAppConfig: AppConfig = {
isInitialized: false,
platform: "macos",
language: "en",
theme: {
theme: "zinc",
radius: 0.5,
@ -38,9 +40,10 @@ interface AppConfigAPI {
setDevExtensionPath: (devExtensionPath: string | null) => void
setTriggerHotkey: (triggerHotkey: string[]) => void
setOnBoarded: (onBoarded: boolean) => void
setLanguage: (language: string) => void
}
function createAppConfig(): WithSyncStore<AppConfig> & AppConfigAPI {
function createAppConfig(): WithSyncStore<AppConfig & { language: string }> & AppConfigAPI {
const store = createTauriSyncStore("app-config", defaultAppConfig)
async function init() {
@ -86,6 +89,9 @@ function createAppConfig(): WithSyncStore<AppConfig> & AppConfigAPI {
setOnBoarded: (onBoarded: boolean) => {
store.update((config) => ({ ...config, onBoarded }))
},
setLanguage: (language: string) => {
store.update((config) => ({ ...config, language }))
},
init
}
}

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { emitRefreshDevExt } from "@/utils/tauri-events"
import {
DEEP_LINK_PATH_AUTH_CONFIRM,
@ -59,7 +60,7 @@ export async function handleKunkunProtocol(parsedUrl: URL) {
if (parsed.identifier) {
goto(`/extension/store/${parsed.identifier}`)
} else {
goto("/app/extension/store")
goto(i18n.resolveRoute("/app/extension/store"))
}
} else if (href.startsWith(DEEP_LINK_PATH_REFRESH_DEV_EXTENSION)) {
emitRefreshDevExt()

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { appState } from "@/stores"
import { keys } from "@/stores/keys"
import { toggleDevTools } from "@kksh/api/commands"
@ -78,7 +79,7 @@ export async function globalKeyDownHandler(e: KeyboardEvent) {
if ((_platform === "macos" && e.metaKey) || (_platform === "windows" && e.ctrlKey)) {
if (e.key === ",") {
e.preventDefault()
goto("/app/settings")
goto(i18n.resolveRoute("/app/settings"))
}
}
// Toggle Devtools with control + shift + I

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { getCurrentWindow } from "@tauri-apps/api/window"
import { goto } from "$app/navigation"
import { isInMainWindow } from "./window"
@ -7,7 +8,7 @@ export function goBack() {
}
export function goHome() {
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
export function goHomeOrCloseDependingOnWindow() {

View File

@ -1,4 +1,6 @@
<script lang="ts">
import { ParaglideJS } from "@inlang/paraglide-sveltekit"
import { i18n } from "$lib/i18n"
import { onMount } from "svelte"
import "../app.css"
import { init } from "@/utils/init"
@ -12,8 +14,10 @@
let { children } = $props()
</script>
<ModeWatcher />
<Toaster richColors closeButton />
<ThemeWrapper>
{@render children()}
</ThemeWrapper>
<ParaglideJS {i18n}>
<ModeWatcher />
<Toaster richColors closeButton />
<ThemeWrapper>
{@render children()}
</ThemeWrapper>
</ParaglideJS>

View File

@ -1,5 +1,7 @@
<script lang="ts">
import AppContext from "@/components/context/AppContext.svelte"
import { i18n, switchToLanguage } from "@/i18n"
import { setLanguageTag, type AvailableLanguageTag } from "@/paraglide/runtime"
import { appConfig, appState, extensions, quickLinks, winExtMap } from "@/stores"
import { initDeeplink } from "@/utils/deeplink"
import { updateAppHotkey } from "@/utils/hotkey"
@ -60,7 +62,11 @@
.catch(error)
quickLinks.init()
appConfig.init()
appConfig.init().then(() => {
console.log("appConfig.language", $appConfig.language)
setLanguageTag($appConfig.language as AvailableLanguageTag)
switchToLanguage($appConfig.language as AvailableLanguageTag)
})
if (isInMainWindow()) {
if ($appConfig.triggerHotkey) {
updateAppHotkey($appConfig.triggerHotkey)

View File

@ -3,6 +3,8 @@
import { commandLaunchers } from "@/cmds"
import { builtinCmds } from "@/cmds/builtin"
import { systemCommands } from "@/cmds/system"
import { i18n } from "@/i18n"
import * as m from "@/paraglide/messages"
import {
appConfig,
appConfigLoaded,
@ -62,7 +64,7 @@
// to keep track of the loading status
if (loaded) {
if (!appConfig.get().onBoarded) {
goto("/app/help/onboarding")
goto(i18n.resolveRoute("/app/help/onboarding"))
}
}
})
@ -97,7 +99,7 @@
autofocus
bind:ref={inputEle}
id="main-command-input"
placeholder={$cmdQueries.length === 0 ? "Type a command or search..." : undefined}
placeholder={$cmdQueries.length === 0 ? m.home_command_input_placeholder() : undefined}
bind:value={$appState.searchTerm}
onkeydown={onKeyDown}
>
@ -136,19 +138,21 @@
<DropdownMenu.Group>
<DropdownMenu.Item onclick={() => exit()}>
<CircleXIcon class="h-4 w-4 text-red-500" />
Quit
{m.home_command_input_dropdown_quit()}
</DropdownMenu.Item>
<DropdownMenu.Item onclick={() => getCurrentWebviewWindow().hide()}>
<CircleXIcon class="h-4 w-4 text-red-500" />
Close Window
{m.home_command_input_dropdown_close_window()}
</DropdownMenu.Item>
</DropdownMenu.Group>
<DropdownMenu.Separator />
<DropdownMenu.Group>
<DropdownMenu.GroupHeading data-tauri-drag-region>Developer</DropdownMenu.GroupHeading>
<DropdownMenu.GroupHeading data-tauri-drag-region>
{m.home_command_input_dropdown_developer_title()}
</DropdownMenu.GroupHeading>
<DropdownMenu.Item onclick={toggleDevTools}>
<Icon icon="mingcute:code-fill" class="mr-2 h-5 w-5 text-green-500" />
Toggle Devtools
{m.home_command_input_dropdown_toggle_devtools()}
<DropdownMenu.Shortcut
><span class="flex items-center">⌃+<ArrowBigUpIcon class="h-4 w-4" />+I</span
></DropdownMenu.Shortcut
@ -156,7 +160,7 @@
</DropdownMenu.Item>
<DropdownMenu.Item onclick={() => location.reload()}>
<RefreshCcwIcon class="mr-2 h-4 w-4 text-green-500" />
Reload Window
{m.home_command_input_dropdown_reload_window()}
<DropdownMenu.Shortcut
><span class="flex items-center">⌃+<ArrowBigUpIcon class="h-4 w-4" />+R</span
></DropdownMenu.Shortcut
@ -171,7 +175,7 @@
icon={$appConfig.hmr ? "fontisto:toggle-on" : "fontisto:toggle-off"}
class={cn("mr-1 h-5 w-5", { "text-green-500": $appConfig.hmr })}
/>
Toggle Dev Extension HMR
{m.home_command_input_dropdown_toggle_dev_extension_hmr()}
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
@ -183,7 +187,7 @@
{#if $appConfig.extensionsInstallDir && $devStoreExts.length > 0}
<ExtCmdsGroup
extensions={$devStoreExts}
heading="Dev Extensions"
heading={m.command_group_heading_dev_ext()}
isDev={true}
onExtCmdSelect={commandLaunchers.onExtCmdSelect}
hmr={$appConfig.hmr}
@ -192,7 +196,7 @@
{#if $appConfig.extensionsInstallDir && $installedStoreExts.length > 0}
<ExtCmdsGroup
extensions={$installedStoreExts}
heading="Extensions"
heading={m.command_group_heading_ext()}
isDev={false}
hmr={false}
onExtCmdSelect={commandLaunchers.onExtCmdSelect}

View File

@ -1,4 +1,5 @@
<script lang="ts">
import { i18n } from "@/i18n.js"
import { auth } from "@/stores"
import { supabase } from "@/supabase"
import { goHomeOnEscape } from "@/utils/key"
@ -44,7 +45,7 @@
function onSignOut() {
auth
.signOut()
.then(() => goto("/app/auth"))
.then(() => goto(i18n.resolveRoute("/app/auth")))
.catch((err) => toast.error("Failed to sign out", { description: err.message }))
}
</script>
@ -56,7 +57,7 @@
size="icon"
onclick={() => {
console.log("go Home")
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}}
>
<ArrowLeft class="size-4" />

View File

@ -1,11 +1,12 @@
<script lang="ts">
import { i18n } from "@/i18n"
import { Error, Layouts } from "@kksh/ui"
import { goto } from "$app/navigation"
import { page } from "$app/stores"
function handleKeyDown(event: KeyboardEvent) {
if (event.key === "Enter") {
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
}
</script>
@ -17,7 +18,7 @@
title="Fail to Load Extension"
class="w-fit max-w-screen-sm border-2 border-red-500"
message={$page.error?.message ?? "Unknown Error"}
onGoBack={() => goto("/app/")}
onGoBack={() => goto(i18n.resolveRoute("/app/"))}
rawJsonError={JSON.stringify($page, null, 2)}
/>
</Layouts.Center>

View File

@ -1,5 +1,6 @@
<script lang="ts">
import { getExtensionsFolder } from "@/constants.js"
import { i18n } from "@/i18n.js"
import { extensions, installedStoreExts } from "@/stores/extensions.js"
import { supabaseAPI } from "@/supabase"
import { goBack } from "@/utils/route.js"
@ -149,7 +150,7 @@
function handleKeydown(e: KeyboardEvent) {
if (e.key === "Escape") {
if (!delayedImageDialogOpen) {
goto("/app/extension/store")
goto(i18n.resolveRoute("/app/extension/store"))
}
}
}
@ -161,7 +162,7 @@
size="icon"
class={cn("fixed left-3 top-3 z-50", Constants.CLASSNAMES.BACK_BUTTON)}
data-flip-id={Constants.CLASSNAMES.BACK_BUTTON}
onclick={() => goto("/app/extension/store")}
onclick={() => goto(i18n.resolveRoute("/app/extension/store"))}
>
<ArrowLeftIcon />
</Button>

View File

@ -1,5 +1,6 @@
<script lang="ts">
import DanceTransition from "@/components/dance/dance-transition.svelte"
import { i18n } from "@/i18n"
import { appConfig, winExtMap } from "@/stores"
import { goBackOnEscape } from "@/utils/key"
import { goHome } from "@/utils/route"
@ -51,7 +52,7 @@
const iframeUiAPI: IUiIframeServer2 = {
goBack: async () => {
if (isInMainWindow()) {
goto("/app/")
goto(i18n.resolveRoute("/app/"))
} else {
appWin.close()
}

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { db, unregisterExtensionWindow } from "@kksh/api/commands"
import type { Ext as ExtInfoInDB, ExtPackageJsonExtra } from "@kksh/api/models"
import { loadExtensionManifestFromDisk } from "@kksh/extension"
@ -24,7 +25,7 @@ export const load: PageLoad = async ({
if (!_extPath || !_extUrl) {
toast.error("Invalid extension path or url")
error("Invalid extension path or url")
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
const extPath = z.string().parse(_extPath)
const extUrl = z.string().parse(_extUrl)
@ -36,7 +37,7 @@ export const load: PageLoad = async ({
toast.error("Error loading extension manifest", {
description: `${err}`
})
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
const loadedExt = _loadedExt!
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
@ -44,7 +45,7 @@ export const load: PageLoad = async ({
toast.error("Unexpected Error", {
description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.`
})
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
return { extPath, url: extUrl, loadedExt, extInfoInDB: extInfoInDB! }
}

View File

@ -1,4 +1,5 @@
<script lang="ts">
import { i18n } from "@/i18n.js"
import { appState } from "@/stores/appState.js"
import { keys } from "@/stores/keys"
import { winExtMap } from "@/stores/winExtMap.js"
@ -54,7 +55,7 @@
async function goBack() {
if (isInMainWindow()) {
goto("/app/")
goto(i18n.resolveRoute("/app/"))
} else {
appWin.close()
}

View File

@ -1,3 +1,4 @@
import { i18n } from "@/i18n"
import { db, unregisterExtensionWindow } from "@kksh/api/commands"
import type { Ext as ExtInfoInDB, ExtPackageJsonExtra } from "@kksh/api/models"
import { loadExtensionManifestFromDisk } from "@kksh/extension"
@ -9,16 +10,6 @@ import { goto } from "$app/navigation"
import { toast } from "svelte-sonner"
import type { PageLoad } from "./$types"
// : Promise<{
// extPath: string
// scriptPath: string
// // workerScript: string
// pkgJsonPath: string
// cmdName: string
// loadedExt: ExtPackageJsonExtra
// extInfoInDB: ExtInfoInDB
// }>
export const load: PageLoad = async ({ url }) => {
// both query parameter must exist
@ -27,7 +18,7 @@ export const load: PageLoad = async ({ url }) => {
if (!extPath || !cmdName) {
toast.error("Invalid extension path or url")
error("Invalid extension path or url")
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
let _loadedExt: ExtPackageJsonExtra | undefined
@ -38,7 +29,7 @@ export const load: PageLoad = async ({ url }) => {
toast.error("Error loading extension manifest", {
description: `${err}`
})
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
const loadedExt = _loadedExt!
const extInfoInDB = await db.getUniqueExtensionByPath(loadedExt.extPath)
@ -46,7 +37,7 @@ export const load: PageLoad = async ({ url }) => {
toast.error("Unexpected Error", {
description: `Extension ${loadedExt.kunkun.identifier} not found in database. Run Troubleshooter.`
})
goto("/app/")
goto(i18n.resolveRoute("/app/"))
}
const pkgJsonPath = await join(extPath!, "package.json")
if (!(await exists(extPath!))) {

View File

@ -2,6 +2,7 @@
import GeneralSettings from "@/components/standalone/general-settings.svelte"
import DenoInstall from "@/components/standalone/help/deno-install.svelte"
import FFmpegInstall from "@/components/standalone/help/ffmpeg-install.svelte"
import { i18n } from "@/i18n"
import { appConfig } from "@/stores/appConfig"
import { Button } from "@kksh/svelte5"
import { goto } from "$app/navigation"
@ -35,7 +36,7 @@
}
} else if (step > Step.FFmpegInstall) {
appConfig.setOnBoarded(true)
goto("/app")
goto(i18n.resolveRoute("/app"))
}
})
</script>

View File

@ -1,7 +1,9 @@
<script lang="ts">
import GeneralSettings from "@/components/standalone/general-settings.svelte"
import * as m from "@/paraglide/messages"
</script>
<main class="container flex flex-col space-y-2">
<pre>{m.settings_general_language()}</pre>
<GeneralSettings />
</main>

View File

@ -1,4 +1,5 @@
<script lang="ts">
import * as m from "@/paraglide/messages"
import { goHome } from "@/utils/route"
import { checkUpdateAndInstall } from "@/utils/updater"
import Icon from "@iconify/svelte"
@ -18,10 +19,17 @@
<div class="flex w-full items-center space-x-5">
<img src="/favicon.png" class="w-44" alt="Logo" />
<div class="flex flex-col space-y-1">
<p class="text-3xl font-bold">KunKun Shell</p>
<p class="text-xs">Version: {appVersion}</p>
<p class="text-3xl font-bold">
{m.app_name()}
{#if m.secondary_app_name() !== m.app_name()}
<span class="text-secondary-foreground text-md">({m.secondary_app_name()})</span>
{/if}
</p>
<p class="text-xs">
{m.settings_about_version()}: {appVersion}
</p>
<p class="flex gap-1">
<strong class="font-bold">Author: </strong>
<strong class="font-bold">{m.settings_about_author()}: </strong>
<a
href="https://github.com/HuakunShen"
target="_blank"
@ -38,7 +46,7 @@
rel="noreferrer"
class="flex items-center gap-2 font-mono text-sm hover:text-blue-600 hover:underline hover:dark:text-blue-500"
>
Source Code
<strong>{m.settings_about_source_code()}</strong>
<Icon icon="mdi:github" class="h-5 w-5" />
</a>
<a
@ -47,11 +55,11 @@
rel="noreferrer"
class="flex items-center gap-2 font-mono text-sm hover:text-blue-600 hover:underline hover:dark:text-blue-500"
>
Extensions Source Code
<strong>{m.settings_about_extensions_source_code()}</strong>
<Icon icon="mdi:github" class="h-5 w-5" />
</a>
<Button onclick={checkUpdateAndInstall} size="sm" variant="secondary">
Check for Updates
{m.settings_about_check_for_updates()}
</Button>
</div>
</div>

View File

@ -1,12 +1,12 @@
<script lang="ts">
import AddDevExtForm from "@/components/standalone/settings/AddDevExtForm.svelte"
import * as m from "@/paraglide/messages"
</script>
<main class="container">
<h2 class="text-2xl font-bold">Add Dev Extension</h2>
<h2 class="text-2xl font-bold">{m.settings_add_dev_ext_title()}</h2>
<small>
There are 4 options to install an extension in developer mode. Either load it from your local
tarball file, a tarball remote URL, npm package name or load from a remote URL.
{m.settings_add_dev_ext_description()}
</small>
<AddDevExtForm />
</main>

View File

@ -1,4 +1,5 @@
<script lang="ts">
import * as m from "@/paraglide/messages"
import { appConfig, devStoreExts, extensions, installedStoreExts } from "@/stores"
import { ExtPackageJsonExtra } from "@kksh/api/models"
import * as extAPI from "@kksh/extension"
@ -53,16 +54,16 @@
</Table.Row>
{/snippet}
<main class="container">
<h1 class="text-2xl font-bold">Your Extensions</h1>
<h1 class="text-2xl font-bold">{m.settings_extensions_title()}</h1>
<Table.Root>
<Table.Caption>Your Extensions</Table.Caption>
<Table.Caption>{m.settings_extensions_title()}</Table.Caption>
<Table.Header>
<Table.Row>
<Table.Head>Name</Table.Head>
<Table.Head>Identifier</Table.Head>
<Table.Head>Type</Table.Head>
<Table.Head>Version</Table.Head>
<Table.Head>Uninstall</Table.Head>
<Table.Head>{m.settings_extensions_table_col_name()}</Table.Head>
<Table.Head>{m.settings_extensions_table_col_identifier()}</Table.Head>
<Table.Head>{m.settings_extensions_table_col_type()}</Table.Head>
<Table.Head>{m.settings_extensions_table_col_version()}</Table.Head>
<Table.Head>{m.settings_extensions_table_col_uninstall()}</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>

View File

@ -1,9 +1,10 @@
<script lang="ts">
import DevExtPathForm from "@/components/standalone/settings/DevExtPathForm.svelte"
import * as m from "@/paraglide/messages"
</script>
<main class="container">
<h2 class="text-2xl font-bold">Set Dev Extension Path</h2>
<p>This is where your extensions will be installed.</p>
<h2 class="text-2xl font-bold">{m.settings_set_dev_ext_title()}</h2>
<p>{m.settings_set_dev_ext_description()}</p>
<DevExtPathForm />
</main>

View File

@ -1,4 +1,6 @@
<script lang="ts">
import { i18n } from "@/i18n"
import * as m from "@/paraglide/messages"
import { goHome } from "@/utils/route"
import { Button, SideBar } from "@kksh/svelte5"
import { Constants } from "@kksh/ui"
@ -9,37 +11,36 @@
import Info from "lucide-svelte/icons/info"
import Route from "lucide-svelte/icons/route"
import SquareTerminal from "lucide-svelte/icons/square-terminal"
import { onMount } from "svelte"
const items = [
{
title: "General",
url: "/app/settings",
title: m.settings_menu_general(),
url: i18n.resolveRoute("/app/settings"),
icon: Cog
},
{
title: "Developer",
url: "/app/settings/developer",
title: m.settings_menu_developer(),
url: i18n.resolveRoute("/app/settings/developer"),
icon: SquareTerminal
},
{
title: "Extensions",
url: "/app/settings/extensions",
title: m.settings_menu_extensions(),
url: i18n.resolveRoute("/app/settings/extensions"),
icon: Blocks
},
{
title: "Set Dev Extension",
url: "/app/settings/set-dev-ext-path",
title: m.settings_menu_set_dev_ext(),
url: i18n.resolveRoute("/app/settings/set-dev-ext-path"),
icon: Route
},
{
title: "Add Dev Extension",
url: "/app/settings/add-dev-extension",
title: m.settings_menu_add_dev_ext(),
url: i18n.resolveRoute("/app/settings/add-dev-extension"),
icon: FileCode2
},
{
title: "About",
url: "/app/settings/about",
title: m.settings_menu_about(),
url: i18n.resolveRoute("/app/settings/about"),
icon: Info
}
]
@ -63,7 +64,7 @@
</SideBar.Header>
<SideBar.Content>
<SideBar.Group>
<SideBar.GroupLabel data-tauri-drag-region>Settings</SideBar.GroupLabel>
<SideBar.GroupLabel data-tauri-drag-region>{m.settings_menu_settings()}</SideBar.GroupLabel>
<SideBar.GroupContent>
<SideBar.Menu>
{#each items as item (item.title)}

View File

@ -1,12 +1,10 @@
<script lang="ts">
import { goBackOnEscape } from "@/utils/key"
import { goBack } from "@/utils/route"
import * as m from "@/paraglide/messages"
import { db } from "@kksh/api/commands"
import { loadExtensionManifestFromDisk } from "@kksh/extension"
import { Button, Dialog, ScrollArea, Table } from "@kksh/svelte5"
import { Button, Dialog, Table } from "@kksh/svelte5"
import { join } from "@tauri-apps/api/path"
import { exists } from "@tauri-apps/plugin-fs"
import { ArrowLeftIcon } from "lucide-svelte"
import { onMount } from "svelte"
import { toast } from "svelte-sonner"
import { open } from "tauri-plugin-shellx-api"
@ -78,8 +76,8 @@
</script>
<div class="container">
<h1 class="text-2xl font-bold">Extension Loading Troubleshooter</h1>
<Button class="my-2" onclick={check}>Check</Button>
<h1 class="text-2xl font-bold">{m.troubleshooters_extension_loading_title()}</h1>
<Button class="my-2" onclick={check}>{m.common_check()}</Button>
<Dialog.Root bind:open={isDialogOpen}>
<Dialog.Content class="sm:max-w-[425px]">
<Dialog.Header>
@ -92,9 +90,11 @@
<Table.Caption>A list of your extensions.</Table.Caption>
<Table.Header>
<Table.Row>
<Table.Head class="">Identifier</Table.Head>
<Table.Head>Path</Table.Head>
<Table.Head>Error</Table.Head>
<Table.Head class=""
>{m.troubleshooters_extension_loading_table_col_identifier()}</Table.Head
>
<Table.Head>{m.troubleshooters_extension_loading_table_col_path()}</Table.Head>
<Table.Head>{m.troubleshooters_extension_loading_table_col_error()}</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>

View File

@ -1,4 +1,5 @@
<script lang="ts">
import * as m from "@/paraglide/messages"
import { winExtMap } from "@/stores"
import { goBackOnEscape, goBackOnEscapeClearSearchTerm } from "@/utils/key"
import { goBack, goHome } from "@/utils/route"
@ -73,12 +74,12 @@
for="refreshEverySecond"
class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Refresh Every Second
{m.troubleshooters_extension_window_refresh_every_second()}
</label>
</div>
<span class="flex items-center space-x-2">
<Button size="sm" onclick={refresh}>Refresh</Button>
<span>Refreshed {refreshCount} times</span>
<Button size="sm" onclick={refresh}>{m.troubleshooters_extension_window_refresh()}</Button>
<span>{m.troubleshooters_extension_window_refreshed({ count: refreshCount })}</span>
</span>
</div>
<ScrollArea class="py-5" orientation="both">

View File

@ -1,4 +1,6 @@
<script lang="ts">
import { i18n } from "@/i18n"
import * as m from "@/paraglide/messages"
import { goHome } from "@/utils/route"
import { Button, SideBar } from "@kksh/svelte5"
import { Constants } from "@kksh/ui"
@ -10,18 +12,18 @@
let { class: className }: { class?: string } = $props()
const items = [
{
title: "Extension Loading",
url: "/app/troubleshooters/extension-loading",
title: m.troubleshooters_sidebar_extension_loading_title(),
url: i18n.resolveRoute("/app/troubleshooters/extension-loading"),
icon: Loader
},
{
title: "Extension Window",
url: "/app/troubleshooters/extension-window",
title: m.troubleshooters_sidebar_extension_window_title(),
url: i18n.resolveRoute("/app/troubleshooters/extension-window"),
icon: AppWindow
},
{
title: "MDNS Debugger",
url: "/app/troubleshooters/mdns-debugger",
title: m.troubleshooters_sidebar_mdns_debugger_title(),
url: i18n.resolveRoute("/app/troubleshooters/mdns-debugger"),
icon: Network
}
]
@ -45,7 +47,9 @@
</SideBar.Header>
<SideBar.Content>
<SideBar.Group>
<SideBar.GroupLabel data-tauri-drag-region>Settings</SideBar.GroupLabel>
<SideBar.GroupLabel data-tauri-drag-region>
{m.troubleshooters_sidebar_title()}
</SideBar.GroupLabel>
<SideBar.GroupContent>
<SideBar.Menu>
{#each items as item (item.title)}

View File

@ -1,3 +1,4 @@
import { paraglide } from "@inlang/paraglide-sveltekit/vite"
import { sveltekit } from "@sveltejs/kit/vite"
import { defineConfig } from "vite"
@ -6,7 +7,7 @@ const host = process.env.TAURI_DEV_HOST
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [sveltekit()],
plugins: [paraglide({ project: "./project.inlang", outdir: "./src/lib/paraglide" }), sveltekit()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors

View File

@ -1,4 +1,3 @@
## Permission Table
<table>
@ -7,7 +6,6 @@
<th>Description</th>
</tr>
<tr>
<td>

View File

@ -11,6 +11,7 @@ export const PersistedAppConfig = v.object({
triggerHotkey: v.nullable(v.array(v.string())),
launchAtLogin: v.boolean(),
showInTray: v.boolean(),
language: v.string(),
devExtensionPath: v.nullable(v.string()),
hmr: v.boolean(),
hideOnBlur: v.boolean(),
@ -24,6 +25,7 @@ export type PersistedAppConfig = v.InferOutput<typeof PersistedAppConfig>
export type AppConfig = PersistedAppConfig & {
isInitialized: boolean
language: string
extensionsInstallDir?: string
platform: Platform
}

View File

@ -67,6 +67,7 @@
},
"dependencies": {
"@formkit/auto-animate": "^0.8.2",
"@inlang/paraglide-sveltekit": "^0.15.5",
"@internationalized/date": "^3.7.0",
"@kksh/supabase": "workspace:*",
"@std/semver": "npm:@jsr/std__semver@^1.0.3",

View File

@ -46,7 +46,7 @@
<Carousel.Content class="max-h-[75vh]">
{#each imageSrcs as src}
<Carousel.Item class="flex justify-center">
<img {src} class="object-contain" alt="" />
<img {src} class="object-contain" alt="" />
</Carousel.Item>
{/each}
</Carousel.Content>

View File

@ -5,7 +5,7 @@
import { toggleMode } from "mode-watcher"
</script>
<Button onclick={toggleMode} variant="outline" size="icon">
<Button onclick={toggleMode} variant="outline" size="icon" class="shrink-0">
<Sun
class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"
/>

959
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff