diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..42e366c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,6 @@ +github: poli0981 +ko_fi: skullmute +buy_me_a_coffee: skullmute +patreon: skullmute +custom: + - paypal.me/DungDang212 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..b9d14b7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: + - name: Questions & general discussion + url: https://github.com/poli0981/jsonprism/discussions + about: Ask about usage, share workflows, or propose ideas before opening an issue. + - name: Security vulnerability + url: https://github.com/poli0981/jsonprism/security/advisories/new + about: Report security issues privately via GitHub Security Advisory (not in public issues). + - name: Live demo + url: https://poli0981.github.io/jsonprism/ + about: Try the latest deployed build in your browser before filing a bug. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..5fc8772 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,49 @@ + + +## Summary + + + +- +- + +Closes # + +## Test plan + + + +- [ ] `npm run typecheck` +- [ ] `npm run lint` +- [ ] `npm test` +- [ ] `npm run build` +- [ ] Manual smoke (describe what you clicked / loaded) + +## Screenshots / recordings (UI changes only) + + + +## AI-assist disclosure + + + +- + +## Checklist + +- [ ] My changes follow the conventions in [CLAUDE.md](../CLAUDE.md). +- [ ] I added or updated tests where relevant. +- [ ] I updated docs / i18n keys if user-visible strings changed. +- [ ] I did not include unrelated drive-by changes. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f168772 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,65 @@ +version: 2 + +# Dependency update schedule for JSONPrism. +# Groups minor + patch bumps together to reduce PR churn; majors get their +# own PR so they can be evaluated individually. + +updates: + # npm ecosystem (root package.json + lockfile) + - package-ecosystem: npm + directory: "/" + schedule: + interval: weekly + day: monday + time: "08:00" + timezone: Asia/Ho_Chi_Minh + open-pull-requests-limit: 10 + versioning-strategy: increase + labels: + - dependencies + - npm + groups: + npm-minor-patch: + applies-to: version-updates + update-types: + - minor + - patch + + # GitHub Actions used in .github/workflows/ + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + day: monday + time: "08:00" + timezone: Asia/Ho_Chi_Minh + open-pull-requests-limit: 5 + labels: + - dependencies + - github-actions + groups: + actions-minor-patch: + applies-to: version-updates + update-types: + - minor + - patch + + # Cargo ecosystem for the Tauri shell. + - package-ecosystem: cargo + directory: "/src-tauri" + schedule: + interval: weekly + day: monday + time: "08:00" + timezone: Asia/Ho_Chi_Minh + open-pull-requests-limit: 5 + labels: + - dependencies + - rust + - tauri + groups: + cargo-minor-patch: + applies-to: version-updates + update-types: + - minor + - patch diff --git a/.github/workflows/announce-discussion.yml b/.github/workflows/announce-discussion.yml new file mode 100644 index 0000000..1402080 --- /dev/null +++ b/.github/workflows/announce-discussion.yml @@ -0,0 +1,131 @@ +name: Announce Release / Deploy in Discussions + +# Create a Discussion post in the "Announcements" category when: +# • a GitHub Release is published (tag-based deploys) +# • the Deploy to GitHub Pages workflow finishes successfully +# +# Prerequisites (one-time manual setup): +# 1. Enable Discussions in the repo Settings → Features. +# 2. Create a category named "Announcements" (any kind; this workflow +# auto-discovers its node ID at runtime). +# +# Permissions: +# • `contents: read` — read commit / release metadata. +# • `discussions: write` — required to create the post. + +on: + release: + types: [published] + workflow_run: + workflows: ["Deploy to GitHub Pages"] + types: [completed] + workflow_dispatch: + inputs: + message: + description: 'Announcement body (Markdown)' + required: true + type: string + +permissions: + contents: read + discussions: write + +concurrency: + group: announce-discussion-${{ github.event_name }} + cancel-in-progress: false + +jobs: + announce: + name: Create Discussion post + runs-on: ubuntu-latest + # Skip when triggered by a failed deploy. + if: > + github.event_name == 'release' + || github.event_name == 'workflow_dispatch' + || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') + timeout-minutes: 5 + steps: + - name: Resolve repository + category IDs + id: ids + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + QUERY='query($owner: String!, $name: String!) { + repository(owner: $owner, name: $name) { + id + discussionCategories(first: 25) { + nodes { id name } + } + } + }' + response=$(gh api graphql \ + -f query="$QUERY" \ + -F owner="${{ github.repository_owner }}" \ + -F name="${{ github.event.repository.name }}") + repo_id=$(echo "$response" | jq -r '.data.repository.id') + cat_id=$(echo "$response" | jq -r '.data.repository.discussionCategories.nodes[] | select(.name == "Announcements") | .id') + if [ -z "$cat_id" ] || [ "$cat_id" = "null" ]; then + echo "::error::Discussion category 'Announcements' not found. Enable Discussions and create the category in Settings → Features." + exit 1 + fi + echo "repo_id=$repo_id" >> "$GITHUB_OUTPUT" + echo "cat_id=$cat_id" >> "$GITHUB_OUTPUT" + + - name: Compose title + body + id: msg + env: + EVENT: ${{ github.event_name }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_URL: ${{ github.event.release.html_url }} + RELEASE_BODY: ${{ github.event.release.body }} + DEPLOY_SHA: ${{ github.event.workflow_run.head_sha }} + DEPLOY_URL: ${{ github.event.workflow_run.html_url }} + DISPATCH_MSG: ${{ inputs.message }} + run: | + set -euo pipefail + case "$EVENT" in + release) + title="Release $RELEASE_TAG" + body=$'## $RELEASE_TAG\n\n$RELEASE_BODY\n\n[View release →]($RELEASE_URL)' + ;; + workflow_run) + short_sha="${DEPLOY_SHA:0:7}" + title="Deploy succeeded — $short_sha" + body=$'Latest commit deployed to GitHub Pages.\n\n[Deploy run →]($DEPLOY_URL)' + ;; + workflow_dispatch) + title="Announcement" + body="$DISPATCH_MSG" + ;; + *) + echo "::error::Unsupported event: $EVENT" + exit 1 + ;; + esac + { + echo "title<> "$GITHUB_OUTPUT" + + - name: Create Discussion + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + MUTATION='mutation($repo: ID!, $cat: ID!, $title: String!, $body: String!) { + createDiscussion(input: {repositoryId: $repo, categoryId: $cat, title: $title, body: $body}) { + discussion { url } + } + }' + gh api graphql \ + -f query="$MUTATION" \ + -F repo="${{ steps.ids.outputs.repo_id }}" \ + -F cat="${{ steps.ids.outputs.cat_id }}" \ + -F title="${{ steps.msg.outputs.title }}" \ + -F body="${{ steps.msg.outputs.body }}" \ + --jq '.data.createDiscussion.discussion.url' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db14750..a60f2ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Node ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: npm diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 81dd157..f602f59 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,10 +22,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Node 22 - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 22.x cache: npm diff --git a/.github/workflows/notify-ci-failure.yml b/.github/workflows/notify-ci-failure.yml index a450438..521decc 100644 --- a/.github/workflows/notify-ci-failure.yml +++ b/.github/workflows/notify-ci-failure.yml @@ -2,7 +2,11 @@ name: Notify CI Failures on: workflow_run: - workflows: ["*"] + # Subscribe only to the workflow we actually want failure notifications + # for. The previous catch-all ("*") triggered this workflow on every + # completion (deploy, release, notify itself), most of which immediately + # skipped — adding noise to the Actions tab. + workflows: ["CI"] types: [completed] # REQUIRED: declare permissions matching the reusable workflow's needs. diff --git a/.github/workflows/notify-release-pipeline.yml b/.github/workflows/notify-release-pipeline.yml index 6daf133..769554b 100644 --- a/.github/workflows/notify-release-pipeline.yml +++ b/.github/workflows/notify-release-pipeline.yml @@ -2,7 +2,10 @@ name: Notify Release Pipeline on: workflow_run: - workflows: ["*"] + # Subscribe only to release-pipeline workflows. The previous catch-all + # ("*") triggered this workflow on every completion (including CI and + # this workflow itself), most of which immediately skipped. + workflows: ["Release Tauri bundles", "Deploy to GitHub Pages"] types: [completed] permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a9a35c..f72c466 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install Linux build dependencies if: matrix.platform.runner == 'ubuntu-22.04' @@ -49,7 +49,7 @@ jobs: libgtk-3-dev - name: Setup Node 22 - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 22.x cache: npm diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 3df157d..c79397f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -25,6 +25,12 @@ tauri-plugin-shell = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" +# Desktop-only: prevent multiple JSONPrism windows / processes when the user +# launches the app while it's already open. The plugin focuses the existing +# window instead of spawning a new instance. +[target.'cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))'.dependencies] +tauri-plugin-single-instance = "2" + [features] # this feature is used for production builds or when `devUrl` points to the # filesystem and the built-in dev server is disabled. diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index ce6a0e0..ca6202c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -23,7 +23,25 @@ fn host_info() -> HostInfo { #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { - let app = tauri::Builder::default() + let mut builder = tauri::Builder::default(); + + // Single-instance plugin must be registered FIRST so it can intercept + // launches before other plugins initialize. Desktop only — the plugin + // doesn't compile for mobile. + #[cfg(desktop)] + { + builder = builder.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { + // A second JSONPrism launch arrived — focus the existing window + // instead of starting another process. + if let Some(window) = app.get_webview_window("main") { + let _ = window.unminimize(); + let _ = window.show(); + let _ = window.set_focus(); + } + })); + } + + let app = builder .plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_fs::init()) diff --git a/src/components/common/LanguageSwitcher.tsx b/src/components/common/LanguageSwitcher.tsx index 9552a17..700eefe 100644 --- a/src/components/common/LanguageSwitcher.tsx +++ b/src/components/common/LanguageSwitcher.tsx @@ -4,6 +4,8 @@ import { cn } from '@/lib/utils'; const LANGUAGES = [ { code: 'en', label: 'EN' }, { code: 'vi', label: 'VI' }, + { code: 'ja', label: 'JA' }, + { code: 'zh-CN', label: 'ZH' }, ] as const; export function LanguageSwitcher() { diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 2df52fe..809e7eb 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -4,6 +4,8 @@ import { initReactI18next } from 'react-i18next'; import en from './locales/en.json'; import vi from './locales/vi.json'; +import ja from './locales/ja.json'; +import zhCN from './locales/zh-CN.json'; void i18n .use(LanguageDetector) @@ -12,9 +14,11 @@ void i18n resources: { en: { translation: en }, vi: { translation: vi }, + ja: { translation: ja }, + 'zh-CN': { translation: zhCN }, }, fallbackLng: 'en', - supportedLngs: ['en', 'vi'], + supportedLngs: ['en', 'vi', 'ja', 'zh-CN'], interpolation: { escapeValue: false }, detection: { order: ['localStorage', 'navigator', 'htmlTag'], diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index a10805b..f0b84c9 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -233,5 +233,8 @@ "loading": "Loading…", "error": "Error", "retry": "Retry" + }, + "disclaimer": { + "translation": "Non-English translations are AI-generated. Accuracy is not guaranteed." } } diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json new file mode 100644 index 0000000..b3e6f81 --- /dev/null +++ b/src/i18n/locales/ja.json @@ -0,0 +1,240 @@ +{ + "app": { + "name": "JSONPrism", + "tagline": "JSON を様々な形式に分散", + "description": "JSON 入力ひとつ。ターゲット形式は 8 種類以上。ブラウザ内で完結。" + }, + "nav": { + "home": "変換", + "about": "概要", + "github": "GitHub" + }, + "home": { + "input_label": "JSON 入力", + "input_placeholder": "ここに JSON を貼り付け、ファイルをドロップ、またはサンプルを読み込み…", + "output_label": "出力", + "output_empty": "有効な JSON を入力すると、ここに出力が表示されます。", + "drop_zone": "JSON ファイルをここにドロップ", + "drop_zone_active": "ドロップして読み込み", + "drop_zone_hint": "最大 500 ファイル。すべてブラウザ内で処理 — データは端末から外に出ません。", + "load_sample": "サンプル", + "open_file": "開く", + "clear": "クリア", + "format_picker_label": "ターゲット形式", + "convert": "変換", + "copy": "コピー", + "download": "ダウンロード", + "options": "オプション" + }, + "formats": { + "jsonl": "JSONL", + "csv": "CSV", + "tsv": "TSV", + "yaml": "YAML", + "xml": "XML", + "toml": "TOML", + "resx": "RESX", + "markdown": "Markdown テーブル", + "sql": "SQL INSERT", + "bson": "BSON", + "cbor": "CBOR", + "msgpack": "MessagePack" + }, + "format_status": { + "ready": "利用可能", + "suggested": "検出されたデータ形状に適しています", + "planned": "Phase {{phase}} で対応予定", + "no_reverse": "この形式は逆方向のパースに対応していません" + }, + "direction": { + "forward": "JSON →", + "reverse": "→ JSON", + "title": "変換方向", + "hint": "変換方向を切り替え" + }, + "options": { + "jsonl": { + "pretty": "各行を整形して出力", + "pretty_desc": "標準の JSONL は 1 行 1 レコードです。人間が読みやすい複数行を希望する場合に有効化。" + }, + "csv": { + "header": "ヘッダー行を含める", + "header_desc": "オブジェクトのキーから生成した列名を最初の行に出力します。", + "newline": "改行コード", + "newline_lf": "LF (\\n)", + "newline_crlf": "CRLF (\\r\\n)", + "nested_strategy": "ネストされた値", + "nested_strategy_desc": "セル内のオブジェクト/配列の扱いを指定します。", + "nested_json": "JSON 文字列化", + "nested_flatten": "キーをフラット化 (アルファ版)" + }, + "yaml": { + "indent": "インデント (スペース数)", + "quote_style": "クォートスタイル", + "quote_auto": "自動", + "quote_single": "シングル", + "quote_double": "ダブル" + }, + "xml": { + "indent": "インデント (スペース数)", + "root_name": "ルート要素名", + "item_name": "配列項目の要素名", + "item_name_desc": "ルートが配列の場合に使用されます。オブジェクトキーは自身の配列項目を命名します。", + "declaration": "XML 宣言を含める", + "declaration_desc": " を先頭に追加します。" + }, + "toml": { + "sort_keys": "キーをアルファベット順に並べ替え", + "sort_keys_desc": "ネストの全階層に再帰的に適用。安定した diff に有用。" + }, + "markdown": { + "alignment": "列の配置", + "align_left": "左", + "align_center": "中央", + "align_right": "右", + "align_none": "なし", + "escape_pipes": "セル内のパイプをエスケープ", + "escape_pipes_desc": "| を \\| に置換してテーブルが壊れないようにします。" + }, + "sql": { + "table_name": "テーブル名", + "dialect": "方言", + "dialect_standard": "標準 SQL", + "dialect_postgres": "PostgreSQL", + "dialect_mysql": "MySQL", + "dialect_sqlite": "SQLite", + "dialect_mssql": "MS SQL Server", + "multi_row": "複数行 INSERT", + "multi_row_desc": "チャンクごとに 1 つの INSERT 文に複数行をまとめます。", + "chunk_size": "チャンクサイズ", + "chunk_size_desc": "複数行モード時、INSERT あたりの最大行数。", + "include_create": "CREATE TABLE を含める", + "include_create_desc": "最初の行から列の型を推定し、CREATE TABLE 文を出力します。" + }, + "resx": { + "comment_key": "コメントキー", + "comment_key_desc": "エントリが { value, _comment } の形を持つ場合、このキーが 要素になります。", + "include_schema": "xsd:schema ヘッダーを含める", + "include_schema_desc": "Visual Studio はこれを期待します。diff 生成時のみ無効化してください。", + "sort_keys": "エントリをアルファベット順に並べ替え", + "sort_keys_desc": "ロケールファイル間で安定した diff を取りたい時に有用。" + }, + "bson": { + "encoding": "表示エンコーディング", + "encoding_desc": "バイナリ BSON 出力をテキストとして表示する方法。ダウンロード時は常に生バイトです。", + "encoding_base64": "Base64", + "encoding_hex": "Hex" + }, + "cbor": { + "encoding": "表示エンコーディング", + "encoding_desc": "バイナリ CBOR 出力をテキストとして表示する方法。ダウンロード時は常に生バイトです。", + "encoding_base64": "Base64", + "encoding_hex": "Hex" + }, + "msgpack": { + "encoding": "表示エンコーディング", + "encoding_desc": "バイナリ MessagePack 出力をテキストとして表示する方法。ダウンロード時は常に生バイトです。", + "encoding_base64": "Base64", + "encoding_hex": "Hex" + } + }, + "shape": { + "detected": "検出された形状", + "scalar": "スカラー", + "object": "オブジェクト", + "array": "配列", + "flat-object": "フラットオブジェクト", + "array-of-objects": "オブジェクトの配列", + "unknown": "不明" + }, + "status": { + "in": "入力", + "out": "出力", + "time": "parse" + }, + "shortcut": { + "clear": "クリア", + "download": "ダウンロード", + "settings": "設定" + }, + "settings": { + "title": "オプション", + "description": "この形式の生成方法を調整します。設定は形式ごとに保存されます。", + "no_options": "この形式には現在オプションがありません。", + "no_options_long": "このコンバーターはまだオプションを公開していません。Phase 2 で方言、インデントなどが追加される予定です。", + "reset": "デフォルトに戻す" + }, + "toast": { + "copied": "{{format}} をクリップボードにコピーしました", + "copy_failed": "クリップボードへのコピーに失敗しました", + "downloaded": "{{filename}} をダウンロードしました", + "file_loaded": "{{name}} を読み込みました", + "file_failed": "ファイルの読み込みに失敗: {{message}}", + "options_reset": "オプションをデフォルトに戻しました" + }, + "batch": { + "trigger": "バッチ", + "title": "バッチキュー", + "description": "複数の JSON ファイルを {{format}} に一括変換します。すべてブラウザ内で処理されます。", + "drop_idle": "JSON ファイルをここにドロップ", + "drop_active": "離してファイルを追加", + "browse": "またはクリックして選択…", + "empty": "キューにファイルがありません。上に JSON ファイルをドロップして開始してください。", + "stat": { + "queued": "待機中", + "done": "完了", + "failed": "失敗" + }, + "process": "処理開始", + "cancel": "キャンセル", + "clear": "クリア", + "download_zip": ".zip をダウンロード", + "row": { + "out": "出力", + "remove": "キューから削除" + }, + "toast": { + "added": "{{count}} ファイルをキューに追加しました", + "added_other": "{{count}} ファイルをキューに追加しました", + "skipped": "{{count}} ファイルをスキップ (上限: {{max}})", + "skipped_other": "{{count}} ファイルをスキップ (上限: {{max}})", + "started": "{{count}} ファイルを処理中…", + "started_other": "{{count}} ファイルを処理中…", + "finished": "バッチ完了", + "cancelled": "バッチをキャンセルしました", + "failed": "バッチ失敗: {{message}}", + "zipped": "{{count}} ファイルを .zip にまとめました", + "zipped_other": "{{count}} ファイルを .zip にまとめました", + "zip_failed": ".zip の作成に失敗: {{message}}", + "nothing_to_process": "処理するキューがありません。" + } + }, + "theme": { + "light": "ライト", + "dark": "ダーク", + "system": "システム" + }, + "errors": { + "invalid_json": "無効な JSON: {{message}}", + "empty_input": "入力が空です。", + "converter_not_ready": "このコンバーターはまだ実装されていません。", + "converter_not_ready_phase": "このコンバーターは Phase {{phase}} で対応予定です。ロードマップを参照してください。", + "batch_limit": "バッチ上限に達しました ({{max}} ファイル)。一部のファイルを削除してください。", + "unknown": "問題が発生しました。{{message}}" + }, + "about": { + "title": "JSONPrism について", + "lead": "開発者のための分光ツール。", + "p1": "JSONPrism は単一の JSON 入力を受け取り、プリズムを通る白色光のように様々なターゲット形式に分散します。すべての処理はクライアントサイドで行われ、データは端末から外に出ません。", + "p2": "React 19、Vite 6、Tailwind CSS v4、shadcn/ui で構築。ソースコードは GitHub で公開しています。", + "version": "バージョン {{version}}" + }, + "common": { + "loading": "読み込み中…", + "error": "エラー", + "retry": "再試行" + }, + "disclaimer": { + "translation": "このページの翻訳は AI 生成です。100% の正確性は保証されません。" + } +} diff --git a/src/i18n/locales/vi.json b/src/i18n/locales/vi.json index 25ff46f..a4b768f 100644 --- a/src/i18n/locales/vi.json +++ b/src/i18n/locales/vi.json @@ -233,5 +233,8 @@ "loading": "Đang tải…", "error": "Lỗi", "retry": "Thử lại" + }, + "disclaimer": { + "translation": "Các bản dịch không phải tiếng Anh do AI tạo, không đảm bảo chính xác 100%." } } diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json new file mode 100644 index 0000000..9cde180 --- /dev/null +++ b/src/i18n/locales/zh-CN.json @@ -0,0 +1,240 @@ +{ + "app": { + "name": "JSONPrism", + "tagline": "将 JSON 分散为多种格式", + "description": "一份 JSON 输入,八种以上目标格式,全程在浏览器中完成。" + }, + "nav": { + "home": "转换", + "about": "关于", + "github": "GitHub" + }, + "home": { + "input_label": "JSON 输入", + "input_placeholder": "在此处粘贴 JSON、拖入文件或加载示例…", + "output_label": "输出", + "output_empty": "提供有效的 JSON 后,输出将显示在此处。", + "drop_zone": "将 JSON 文件拖到此处", + "drop_zone_active": "释放即可加载", + "drop_zone_hint": "最多 500 个文件。全部在浏览器中运行 — 数据不会离开你的设备。", + "load_sample": "示例", + "open_file": "打开", + "clear": "清除", + "format_picker_label": "目标格式", + "convert": "转换", + "copy": "复制", + "download": "下载", + "options": "选项" + }, + "formats": { + "jsonl": "JSONL", + "csv": "CSV", + "tsv": "TSV", + "yaml": "YAML", + "xml": "XML", + "toml": "TOML", + "resx": "RESX", + "markdown": "Markdown 表格", + "sql": "SQL INSERT", + "bson": "BSON", + "cbor": "CBOR", + "msgpack": "MessagePack" + }, + "format_status": { + "ready": "可用", + "suggested": "适用于检测到的数据形状", + "planned": "将在阶段 {{phase}} 推出", + "no_reverse": "此格式不支持反向解析" + }, + "direction": { + "forward": "JSON →", + "reverse": "→ JSON", + "title": "转换方向", + "hint": "切换转换方向" + }, + "options": { + "jsonl": { + "pretty": "美化每一行", + "pretty_desc": "标准 JSONL 为每条记录一行。如需多行人类可读输出,请启用此项。" + }, + "csv": { + "header": "包含表头行", + "header_desc": "以对象键作为列名输出第一行。", + "newline": "换行符", + "newline_lf": "LF (\\n)", + "newline_crlf": "CRLF (\\r\\n)", + "nested_strategy": "嵌套值处理", + "nested_strategy_desc": "单元格中嵌套对象或数组的处理方式。", + "nested_json": "JSON 字符串化", + "nested_flatten": "扁平化键 (alpha)" + }, + "yaml": { + "indent": "缩进 (空格数)", + "quote_style": "引号样式", + "quote_auto": "自动", + "quote_single": "单引号", + "quote_double": "双引号" + }, + "xml": { + "indent": "缩进 (空格数)", + "root_name": "根元素名称", + "item_name": "数组项元素名称", + "item_name_desc": "当根为数组时使用。对象键则为各自的数组项命名。", + "declaration": "包含 XML 声明", + "declaration_desc": "在开头添加 。" + }, + "toml": { + "sort_keys": "按字母顺序排序键", + "sort_keys_desc": "递归应用到每一层嵌套,有助于产生稳定的 diff。" + }, + "markdown": { + "alignment": "列对齐方式", + "align_left": "左对齐", + "align_center": "居中", + "align_right": "右对齐", + "align_none": "无", + "escape_pipes": "转义单元格中的竖线", + "escape_pipes_desc": "将 | 替换为 \\|,避免破坏表格结构。" + }, + "sql": { + "table_name": "表名", + "dialect": "方言", + "dialect_standard": "标准 SQL", + "dialect_postgres": "PostgreSQL", + "dialect_mysql": "MySQL", + "dialect_sqlite": "SQLite", + "dialect_mssql": "MS SQL Server", + "multi_row": "多行 INSERT", + "multi_row_desc": "按 chunk 将多行合并到同一条 INSERT 语句中。", + "chunk_size": "分块大小", + "chunk_size_desc": "启用多行模式时,每条 INSERT 的最大行数。", + "include_create": "包含 CREATE TABLE", + "include_create_desc": "从第一行推断列类型并输出 CREATE TABLE 语句。" + }, + "resx": { + "comment_key": "注释键", + "comment_key_desc": "当条目形如 { value, _comment } 时,该键的值将作为 元素。", + "include_schema": "包含 xsd:schema 头", + "include_schema_desc": "Visual Studio 需要该头。仅在生成 diff 时关闭。", + "sort_keys": "按字母顺序排序条目", + "sort_keys_desc": "便于在不同 locale 文件之间产生稳定的 diff。" + }, + "bson": { + "encoding": "显示编码", + "encoding_desc": "将二进制 BSON 输出渲染为文本的方式。下载时始终为原始字节。", + "encoding_base64": "Base64", + "encoding_hex": "Hex" + }, + "cbor": { + "encoding": "显示编码", + "encoding_desc": "将二进制 CBOR 输出渲染为文本的方式。下载时始终为原始字节。", + "encoding_base64": "Base64", + "encoding_hex": "Hex" + }, + "msgpack": { + "encoding": "显示编码", + "encoding_desc": "将二进制 MessagePack 输出渲染为文本的方式。下载时始终为原始字节。", + "encoding_base64": "Base64", + "encoding_hex": "Hex" + } + }, + "shape": { + "detected": "检测到的形状", + "scalar": "标量", + "object": "对象", + "array": "数组", + "flat-object": "扁平对象", + "array-of-objects": "对象数组", + "unknown": "未知" + }, + "status": { + "in": "输入", + "out": "输出", + "time": "parse" + }, + "shortcut": { + "clear": "清除", + "download": "下载", + "settings": "设置" + }, + "settings": { + "title": "选项", + "description": "调整该格式的生成方式。设置按格式分别保存。", + "no_options": "该格式暂无可用选项。", + "no_options_long": "此转换器尚未暴露任何选项。阶段 2 落地后,你将在此找到方言、缩进等设置。", + "reset": "恢复默认" + }, + "toast": { + "copied": "已将 {{format}} 复制到剪贴板", + "copy_failed": "无法复制到剪贴板", + "downloaded": "已下载 {{filename}}", + "file_loaded": "已加载 {{name}}", + "file_failed": "加载文件失败: {{message}}", + "options_reset": "已恢复默认选项" + }, + "batch": { + "trigger": "批量", + "title": "批量队列", + "description": "一次性将多个 JSON 文件转换为 {{format}}。全部在浏览器中处理。", + "drop_idle": "将 JSON 文件拖到此处", + "drop_active": "释放以添加文件", + "browse": "或点击浏览…", + "empty": "队列中暂无文件。将 JSON 文件拖到上方即可开始。", + "stat": { + "queued": "等待中", + "done": "完成", + "failed": "失败" + }, + "process": "处理", + "cancel": "取消", + "clear": "清空", + "download_zip": "下载 .zip", + "row": { + "out": "输出", + "remove": "从队列中移除" + }, + "toast": { + "added": "已添加 {{count}} 个文件到队列", + "added_other": "已添加 {{count}} 个文件到队列", + "skipped": "已跳过 {{count}} 个文件 (上限: {{max}})", + "skipped_other": "已跳过 {{count}} 个文件 (上限: {{max}})", + "started": "正在处理 {{count}} 个文件…", + "started_other": "正在处理 {{count}} 个文件…", + "finished": "批量完成", + "cancelled": "已取消批量任务", + "failed": "批量失败: {{message}}", + "zipped": "已将 {{count}} 个文件打包为 .zip", + "zipped_other": "已将 {{count}} 个文件打包为 .zip", + "zip_failed": "无法构建 .zip: {{message}}", + "nothing_to_process": "队列中没有可处理的内容。" + } + }, + "theme": { + "light": "浅色", + "dark": "深色", + "system": "跟随系统" + }, + "errors": { + "invalid_json": "无效的 JSON: {{message}}", + "empty_input": "输入为空。", + "converter_not_ready": "该转换器尚未实现。", + "converter_not_ready_phase": "该转换器将在阶段 {{phase}} 推出。详见路线图。", + "batch_limit": "已达批量上限 ({{max}} 个文件)。请先移除一些文件。", + "unknown": "发生错误。{{message}}" + }, + "about": { + "title": "关于 JSONPrism", + "lead": "为开发者打造的分光工具。", + "p1": "JSONPrism 接收单份 JSON 输入,并像白光穿过棱镜一样将其分散为多种目标格式。一切都在客户端完成,数据不会离开你的设备。", + "p2": "使用 React 19、Vite 6、Tailwind CSS v4 与 shadcn/ui 构建。源码在 GitHub。", + "version": "版本 {{version}}" + }, + "common": { + "loading": "加载中…", + "error": "错误", + "retry": "重试" + }, + "disclaimer": { + "translation": "本页面译文由 AI 生成,不保证 100% 准确。" + } +} diff --git a/src/main.tsx b/src/main.tsx index 114fc10..0414871 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -10,7 +10,11 @@ if (!rootEl) { throw new Error('Root element #root not found in index.html'); } -const basename = import.meta.env.PROD ? '/jsonprism' : '/'; +// Tauri serves the bundle from `tauri://localhost/` regardless of the web +// deploy path. Web prod ships at `/jsonprism/` on GitHub Pages. The split +// is build-time, so use a Vite `define` flag instead of `isTauri()` runtime +// (which is false at module load before Tauri injects __TAURI__). +const basename = __IS_TAURI_BUILD__ ? '/' : import.meta.env.PROD ? '/jsonprism' : '/'; createRoot(rootEl).render( diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index dbb4c62..20575f3 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,3 +1,4 @@ /// declare const __APP_VERSION__: string; +declare const __IS_TAURI_BUILD__: boolean; diff --git a/vite.config.ts b/vite.config.ts index 9223d42..87dc007 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,6 +15,7 @@ export default defineConfig(({ mode }) => ({ define: { __APP_VERSION__: JSON.stringify(pkg.version), + __IS_TAURI_BUILD__: JSON.stringify(isTauriContext), }, plugins: [react(), tailwindcss()], diff --git a/vitest.config.ts b/vitest.config.ts index 20f0d80..fb1ab7d 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,6 +7,7 @@ export default defineConfig({ plugins: [react()], define: { __APP_VERSION__: JSON.stringify(pkg.version), + __IS_TAURI_BUILD__: 'false', }, resolve: { alias: {