feat: improve translation system and update workflow
This commit is contained in:
290
.github/workflows/translate.yml
vendored
290
.github/workflows/translate.yml
vendored
@@ -5,30 +5,286 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
translate:
|
translate-zh:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
node-version: "20"
|
||||||
|
- name: Translate to Chinese
|
||||||
- name: Translate with i18n-ai-translate
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t zh
|
||||||
uses: taahamahdi/i18n-ai-translate@master
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
json-file-path: src/locales/en/translation.json
|
name: translations-zh
|
||||||
api-key: ${{ secrets.GEMINI_API_KEY }}
|
path: src/locales/zh/
|
||||||
engine: gemini
|
|
||||||
output-languages: de fr it ko pt-br ru zh
|
|
||||||
base-branch: ${{ github.ref_name }}
|
|
||||||
|
|
||||||
- name: Commit and push translations
|
translate-ru:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Russian
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t ru
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-ru
|
||||||
|
path: src/locales/ru/
|
||||||
|
|
||||||
|
translate-pt-br:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Portuguese (Brazil)
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t pt
|
||||||
git config --local user.name "github-actions[bot]"
|
mv src/locales/pt src/locales/pt-BR || true
|
||||||
git add src/locales/
|
- name: Upload artifacts
|
||||||
git diff --staged --quiet || git commit -m "chore: auto-translate to multiple languages [skip ci]"
|
uses: actions/upload-artifact@v4
|
||||||
git push
|
with:
|
||||||
|
name: translations-pt-br
|
||||||
|
path: src/locales/pt-BR/
|
||||||
|
|
||||||
|
translate-fr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to French
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t fr
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-fr
|
||||||
|
path: src/locales/fr/
|
||||||
|
|
||||||
|
translate-es:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Spanish
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t es
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-es
|
||||||
|
path: src/locales/es/
|
||||||
|
|
||||||
|
translate-de:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to German
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t de
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-de
|
||||||
|
path: src/locales/de/
|
||||||
|
|
||||||
|
translate-hi:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Hindi
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t hi
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-hi
|
||||||
|
path: src/locales/hi/
|
||||||
|
|
||||||
|
translate-bn:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Bengali
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t bn
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-bn
|
||||||
|
path: src/locales/bn/
|
||||||
|
|
||||||
|
translate-ja:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Japanese
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t ja
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-ja
|
||||||
|
path: src/locales/ja/
|
||||||
|
|
||||||
|
translate-vi:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Vietnamese
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t vi
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-vi
|
||||||
|
path: src/locales/vi/
|
||||||
|
|
||||||
|
translate-tr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Turkish
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t tr
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-tr
|
||||||
|
path: src/locales/tr/
|
||||||
|
|
||||||
|
translate-ko:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Korean
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t ko
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-ko
|
||||||
|
path: src/locales/ko/
|
||||||
|
|
||||||
|
translate-it:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Italian
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t it
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-it
|
||||||
|
path: src/locales/it/
|
||||||
|
|
||||||
|
translate-he:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
- name: Translate to Hebrew
|
||||||
|
run: npx i18n-auto-translation -k ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} -d "src/locales" -f en -t he
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: translations-he
|
||||||
|
path: src/locales/he/
|
||||||
|
|
||||||
|
create-pr:
|
||||||
|
needs: [translate-zh, translate-ru, translate-pt-br, translate-fr, translate-es, translate-de, translate-hi, translate-bn, translate-ja, translate-vi, translate-tr, translate-ko, translate-it, translate-he]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: translations-temp
|
||||||
|
|
||||||
|
- name: Move translations to correct locations
|
||||||
|
run: |
|
||||||
|
mkdir -p src/locales
|
||||||
|
cp -r translations-temp/translations-zh/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-ru/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-pt-br/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-fr/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-es/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-de/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-hi/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-bn/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-ja/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-vi/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-tr/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-ko/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-it/* src/locales/ || true
|
||||||
|
cp -r translations-temp/translations-he/* src/locales/ || true
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
commit-message: "chore: auto-translate to multiple languages"
|
||||||
|
branch: translations-update
|
||||||
|
delete-branch: true
|
||||||
|
title: "chore: Update translations for all languages"
|
||||||
|
body: |
|
||||||
|
Auto-generated translations
|
||||||
|
|||||||
900
package-lock.json
generated
900
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,7 @@
|
|||||||
"dotenv": "^17.2.0",
|
"dotenv": "^17.2.0",
|
||||||
"drizzle-orm": "^0.44.3",
|
"drizzle-orm": "^0.44.3",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
|
"i18n-auto-translation": "^2.2.3",
|
||||||
"i18next": "^25.4.2",
|
"i18next": "^25.4.2",
|
||||||
"i18next-browser-languagedetector": "^8.2.0",
|
"i18next-browser-languagedetector": "^8.2.0",
|
||||||
"jose": "^5.2.3",
|
"jose": "^5.2.3",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import i18n from "i18next";
|
|||||||
import { initReactI18next } from "react-i18next";
|
import { initReactI18next } from "react-i18next";
|
||||||
import LanguageDetector from "i18next-browser-languagedetector";
|
import LanguageDetector from "i18next-browser-languagedetector";
|
||||||
|
|
||||||
import enTranslation from "../locales/en/translation.json";
|
import enTranslation from "../locales/en.json";
|
||||||
import zhTranslation from "../locales/zh/translation.json";
|
import zhTranslation from "../locales/zh/translation.json";
|
||||||
import deTranslation from "../locales/de/translation.json";
|
import deTranslation from "../locales/de/translation.json";
|
||||||
import ptbrTranslation from "../locales/pt-BR/translation.json";
|
import ptbrTranslation from "../locales/pt-BR/translation.json";
|
||||||
@@ -10,12 +10,35 @@ import ruTranslation from "../locales/ru/translation.json";
|
|||||||
import frTranslation from "../locales/fr/translation.json";
|
import frTranslation from "../locales/fr/translation.json";
|
||||||
import koTranslation from "../locales/ko/translation.json";
|
import koTranslation from "../locales/ko/translation.json";
|
||||||
import itTranslation from "../locales/it/translation.json";
|
import itTranslation from "../locales/it/translation.json";
|
||||||
|
import esTranslation from "../locales/es/translation.json";
|
||||||
|
import hiTranslation from "../locales/hi/translation.json";
|
||||||
|
import bnTranslation from "../locales/bn/translation.json";
|
||||||
|
import jaTranslation from "../locales/ja/translation.json";
|
||||||
|
import viTranslation from "../locales/vi/translation.json";
|
||||||
|
import trTranslation from "../locales/tr/translation.json";
|
||||||
|
import heTranslation from "../locales/he/translation.json";
|
||||||
|
|
||||||
i18n
|
i18n
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
supportedLngs: ["en", "zh", "de", "ptbr", "ru", "fr", "ko", "it"],
|
supportedLngs: [
|
||||||
|
"en",
|
||||||
|
"zh",
|
||||||
|
"de",
|
||||||
|
"ptbr",
|
||||||
|
"ru",
|
||||||
|
"fr",
|
||||||
|
"ko",
|
||||||
|
"it",
|
||||||
|
"es",
|
||||||
|
"hi",
|
||||||
|
"bn",
|
||||||
|
"ja",
|
||||||
|
"vi",
|
||||||
|
"tr",
|
||||||
|
"he",
|
||||||
|
],
|
||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
debug: false,
|
debug: false,
|
||||||
|
|
||||||
@@ -52,6 +75,27 @@ i18n
|
|||||||
it: {
|
it: {
|
||||||
translation: itTranslation,
|
translation: itTranslation,
|
||||||
},
|
},
|
||||||
|
es: {
|
||||||
|
translation: esTranslation,
|
||||||
|
},
|
||||||
|
hi: {
|
||||||
|
translation: hiTranslation,
|
||||||
|
},
|
||||||
|
bn: {
|
||||||
|
translation: bnTranslation,
|
||||||
|
},
|
||||||
|
ja: {
|
||||||
|
translation: jaTranslation,
|
||||||
|
},
|
||||||
|
vi: {
|
||||||
|
translation: viTranslation,
|
||||||
|
},
|
||||||
|
tr: {
|
||||||
|
translation: trTranslation,
|
||||||
|
},
|
||||||
|
he: {
|
||||||
|
translation: heTranslation,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
interpolation: {
|
interpolation: {
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ const languages = [
|
|||||||
{ code: "fr", name: "French", nativeName: "Français" },
|
{ code: "fr", name: "French", nativeName: "Français" },
|
||||||
{ code: "it", name: "Italian", nativeName: "Italiano" },
|
{ code: "it", name: "Italian", nativeName: "Italiano" },
|
||||||
{ code: "ko", name: "Korean", nativeName: "한국어" },
|
{ code: "ko", name: "Korean", nativeName: "한국어" },
|
||||||
|
{ code: "es", name: "Spanish", nativeName: "Español" },
|
||||||
|
{ code: "hi", name: "Hindi", nativeName: "हिन्दी" },
|
||||||
|
{ code: "bn", name: "Bengali", nativeName: "বাংলা" },
|
||||||
|
{ code: "ja", name: "Japanese", nativeName: "日本語" },
|
||||||
|
{ code: "vi", name: "Vietnamese", nativeName: "Tiếng Việt" },
|
||||||
|
{ code: "tr", name: "Turkish", nativeName: "Türkçe" },
|
||||||
|
{ code: "he", name: "Hebrew", nativeName: "עברית" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function LanguageSwitcher() {
|
export function LanguageSwitcher() {
|
||||||
|
|||||||
Reference in New Issue
Block a user