From 8e85885b53006537dec65f2994c6985e7595e4c2 Mon Sep 17 00:00:00 2001 From: "yanqi.zong" Date: Tue, 6 May 2025 14:38:03 -0700 Subject: [PATCH] feat: update translate config --- .github/workflows/autofix.yml | 1 + .github/workflows/labeler.yml | 1 + .github/workflows/pr.yml | 2 + .github/workflows/translate.yml | 43 ++++++++ translation.config.mjs | 181 ++++++++++++++++++++++++++++++++ 5 files changed, 228 insertions(+) create mode 100644 .github/workflows/translate.yml create mode 100644 translation.config.mjs diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index b348b2b9c8f..d7a4f24788f 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -16,6 +16,7 @@ jobs: autofix: name: autofix runs-on: ubuntu-latest + if: github.repository_owner == 'TanStack' steps: - name: Checkout uses: actions/checkout@v4.2.2 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index a271cb7e680..1906aeb52d2 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -6,6 +6,7 @@ on: jobs: triage: runs-on: ubuntu-latest + if: github.repository_owner == 'TanStack' steps: - uses: actions/labeler@v4.3.0 with: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e031ae811fb..859f8ffa274 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -17,6 +17,7 @@ jobs: test: name: Test runs-on: ubuntu-latest + if: github.repository_owner == 'TanStack' steps: - name: Checkout uses: actions/checkout@v4.2.2 @@ -38,6 +39,7 @@ jobs: preview: name: Preview runs-on: ubuntu-latest + if: github.repository_owner == 'TanStack' steps: - name: Checkout uses: actions/checkout@v4.2.2 diff --git a/.github/workflows/translate.yml b/.github/workflows/translate.yml new file mode 100644 index 00000000000..971ee72983a --- /dev/null +++ b/.github/workflows/translate.yml @@ -0,0 +1,43 @@ +name: Translate Documentation + +on: + schedule: + - cron: + '0 20 * * *' # Daily at 20:00 UTC (DeepSeek API off-peak pricing window 16:30-00:30 UTC) + # Pacific Time: 1:00 PM PDT / 12:00 PM PST + # Off-peak window in PT: ~9:30 AM to 5:30 PM PDT / ~8:30 AM to 4:30 PM PST + workflow_dispatch: # Allow manual triggering + inputs: + custom_arguments: + description: 'Custom arguments to pass to the translation package command' + required: false + type: string + +# Add permissions needed for creating PRs +permissions: + contents: write + pull-requests: write + +jobs: + translate: + runs-on: ubuntu-latest + steps: + # Use the translate-docs-action + - name: Translate documentation + uses: TanStack-dev/translate-docs-action@main + with: + # Required inputs + api_key: ${{ secrets.OPENAI_API_KEY }} + + # Optional inputs with their default values shown + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_arguments: ${{ github.event.inputs.custom_arguments }} + # translation_package: '@tanstack-dev/translate-docs' + # base_branch: 'main' + # pr_branch: 'docs/update-translations' + # pr_title: 'Update translations' + # pr_body: 'This PR updates the documentation translations automatically.\n\nGenerated by the translate workflow.' + # commit_message: 'docs: update documentation translations' + # add_paths: 'docs/**' + # enable_formatting: 'true' + # format_command: 'pnpm prettier:write' diff --git a/translation.config.mjs b/translation.config.mjs new file mode 100644 index 00000000000..e5a41c3164b --- /dev/null +++ b/translation.config.mjs @@ -0,0 +1,181 @@ +const common = { + langs: { + 'zh-Hans': { + code: 'zh-Hans', + name: 'Simplified Chinese', + // 翻译规则和指南 + guide: ` + - For technical terms that should not be fully translated, use the format: "中文翻译 (English term)" + Example: "服务端渲染 (SSR)" instead of just "SSR" or just "服务端渲染" + - Add a space between Chinese characters and English words/symbols to improve readability + - Maintain consistent translations for common terms across the entire document +`, + // 常见技术术语翻译词典 + // 格式: 'English term': '中文翻译' + terms: {}, + }, + // 'zh-Hant': { + // code: 'zh-Hant', + // name: 'Traditional Chinese', + // // 翻譯規則和指南 + // guide: ` + // - For technical terms that should not be fully translated, use the format: "繁體中文翻譯 (English term)" + // Example: "伺服器渲染 (SSR)" instead of just "SSR" or just "伺服器渲染" + // - Add a space between Chinese characters and English words/symbols to improve readability + // - Maintain consistent translations for common terms across the entire document + // `, + // // 常見技術術語翻譯詞典 + // // 格式: 'English term': '繁體中文翻譯' + // terms: {}, + // }, + // ja: { + // code: 'ja', + // name: 'Japanese', + // guide: ` + // - For technical terms that should not be fully translated, use the format: "日本語訳 (English term)" + // Example: "サーバーサイドレンダリング (SSR)" instead of just "SSR" or just "サーバーサイドレンダリング" + // - Maintain consistent translations for common terms across the entire document + // - Use katakana for foreign technical terms where appropriate + // `, + // terms: {}, + // }, + // es: { + // code: 'es', + // name: 'Spanish', + // guide: ` + // - For technical terms that should not be fully translated, use the format: "Traducción en español (English term)" + // Example: "Renderizado del lado del servidor (SSR)" instead of just "SSR" or just "Renderizado del lado del servidor" + // - Maintain consistent translations for common terms across the entire document + // - Use formal "usted" form instead of informal "tú" for instructions + // `, + // terms: {}, + // }, + // de: { + // code: 'de', + // name: 'German', + // guide: ` + // - For technical terms that should not be fully translated, use the format: "Deutsche Übersetzung (English term)" + // Example: "Server-seitiges Rendering (SSR)" instead of just "SSR" or just "Server-seitiges Rendering" + // - Maintain consistent translations for common terms across the entire document + // - Follow German capitalization rules for nouns + // `, + // terms: {}, + // }, + // fr: { + // code: 'fr', + // name: 'French', + // guide: ` + // - For technical terms that should not be fully translated, use the format: "Traduction française (English term)" + // Example: "Rendu côté serveur (SSR)" instead of just "SSR" or just "Rendu côté serveur" + // - Maintain consistent translations for common terms across the entire document + // - Use proper French punctuation with spaces before certain punctuation marks + // `, + // terms: {}, + // }, + // ru: { + // code: 'ru', + // name: 'Russian', + // guide: ` + // - For technical terms that should not be fully translated, use the format: "Русский перевод (English term)" + // Example: "Рендеринг на стороне сервера (SSR)" instead of just "SSR" or just "Рендеринг на стороне сервера" + // - Maintain consistent translations for common terms across the entire document + // - Use proper Russian cases for technical terms where appropriate + // `, + // terms: {}, + // }, + // ar: { + // code: 'ar', + // name: 'Arabic', + // guide: ` + // - For technical terms that should not be fully translated, use the format: "الترجمة العربية (English term)" + // Example: "العرض من جانب الخادم (SSR)" instead of just "SSR" or just "العرض من جانب الخادم" + // - Maintain consistent translations for common terms across the entire document + // - Arabic text should flow right-to-left, but keep code examples and technical terms left-to-right + // `, + // terms: {}, + // }, + }, +} + +export default [ + // Router + { + ...common, + docsRoot: 'docs/router', + docsContext: `**TanStack Router is a router for building React and Solid applications**. Some of its features include: +- 100% inferred TypeScript support +- Typesafe navigation +- Nested Routing and layout routes (with pathless layouts) +- Built-in Route Loaders w/ SWR Caching +- Designed for client-side data caches (TanStack Query, SWR, etc.) +- Automatic route prefetching +- Asynchronous route elements and error boundaries +- File-based Route Generation +- Typesafe JSON-first Search Params state management APIs +- Path and Search Parameter Schema Validation +- Search Param Navigation APIs +- Custom Search Param parser/serializer support +- Search param middleware +- Route matching/loading middleware`, + copyPath: [ + 'framework/solid/**', + // guide + '!framework/solid/guide/custom-link', + '!framework/solid/guide/scroll-restoration', + // routing + '!framework/solid/routing/file-based-routing', + '!framework/solid/routing/installation-with-router-cli', + '!framework/solid/routing/installation-with-vite', + // + '!framework/solid/quick-start', + ], + }, + // Start + { + ...common, + docsRoot: 'docs/start', + docsContext: `TanStack Start is a full-stack React framework powered by TanStack Router. It provides a full-document SSR, streaming, server functions, bundling, and more using tools like [Nitro](https://nitro.unjs.io/) and [Vite](https://vitejs.dev/). It is ready to deploy to your favorite hosting provider! + +## Router or Start? + +TanStack Router is a powerful, type-safe, and full-featured routing system for React applications. It is designed to handle the beefiest of full-stack routing requirements with ease. TanStack Start builds on top of Router's type system to provide type-safe full-stack APIs that keep you in the fast lane. + +What you get with TanStack Router: + +- 100% inferred TypeScript support +- Typesafe navigation +- Nested Routing and pathless layout routes +- Built-in Route Loaders w/ SWR Caching +- Designed for client-side data caches (TanStack Query, SWR, etc.) +- Automatic route prefetching +- Asynchronous route elements and error boundaries +- File-based Route Generation +- Typesafe JSON-first Search Params state management APIs +- Path and Search Parameter Schema Validation +- Search Param Navigation APIs +- Custom Search Param parser/serializer support +- Search param middleware +- Route matching/loading middleware + +What you get with TanStack Start: + +- Full-document SSR +- Streaming +- Server Functions / RPCs +- Bundling +- Deployment +- Full-Stack Type Safety + +**In summary, use TanStack Router for client-side routing and TanStack Start for full-stack routing.**`, + copyPath: [ + 'framework/solid/**', + '!framework/solid/authentication', + '!framework/solid/build-from-scratch', + '!framework/solid/hosting', + '!framework/solid/learn-the-basics', + '!framework/solid/overview', + '!framework/solid/quick-start', + '!framework/solid/server-functions', + ], + }, +]