Step 1: เลือกผู้ให้บริการแปลภาษา
การดําเนินการทํางานร่วมกับ นักแปล Azure AI, แปลภาษาของ AWS และ การแปลของ Google Cloud ที่อยู่เบื้องหลังพื้นผิว API แบบรวมเดียว เลือกผู้ให้บริการรายเดียวต่อการเรียกใช้ด้วยอินพุต provider — เวิร์กโฟลว์จะทํางานเหมือนกันโดยไม่คํานึงถึงผู้ให้บริการ มีเพียงข้อมูลประจําตัวเท่านั้นที่ต่างกัน ดู ผู้ให้บริการแปลภาษา สําหรับการเปรียบเทียบแบบเต็ม
Step 2: เพิ่มข้อมูลประจําตัวและเวิร์กโฟลว์
จัดเก็บข้อมูลประจําตัวของผู้ให้บริการของคุณเป็นข้อมูลลับของที่เก็บ GitHub จากนั้นสร้าง .github/workflows/translate.yml เลือกผู้ให้บริการของคุณด้านล่างสําหรับการตั้งค่าเฉพาะ — เวิร์กโฟลว์ที่เหลือจะเหมือนกัน
นักแปล Azure AI
Azure เป็นผู้ให้บริการเริ่มต้น ดังนั้นอาจละเว้น provider เตรียมใช้งานทรัพยากร Azure AI Translator ในพอร์ทัล Azure จากนั้นจัดเก็บข้อมูลประจําตัว:
จัดเก็บข้อมูลเหล่านี้เป็นข้อมูลลับของที่เก็บ
TRANSLATOR_KEY— คีย์การสมัครใช้งานสําหรับทรัพยากรTRANSLATOR_ENDPOINT— URL ปลายทางระดับภูมิภาคTRANSLATOR_REGION— ภูมิภาค Azure ของทรัพยากร
เพิ่มเวิร์กโฟลว์
name: translate
on: push: branches: [main] paths: - "src/**/*.en.resx" - "src/**/*.en.json"
permissions: contents: write pull-requests: write
jobs: translate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - id: translate uses: IEvangelist/resource-translator@v3 with: provider: | azure: subscriptionKey: ${{ secrets.TRANSLATOR_KEY }} endpoint: ${{ secrets.TRANSLATOR_ENDPOINT }} region: ${{ secrets.TRANSLATOR_REGION }} sourceLocale: en toLocales: '["fr","de","es"]' - if: steps.translate.outputs.has-new-translations == 'true' uses: peter-evans/create-pull-request@v7 with: title: ${{ steps.translate.outputs.summary-title }} body: ${{ steps.translate.outputs.summary-details }} branch: machine-translationแปลภาษาของ AWS
ตั้งค่า provider เป็น aws ต้องการ OIDC ผ่าน aws-actions/configure-aws-credentials เพื่อไม่ให้เก็บความลับที่มีอายุยืนยาว — ขั้นตอนจะส่งออก AWS_REGION ให้คุณ หากต้องการใช้คีย์แบบคงที่แทน ให้จัดเก็บข้อมูลต่อไปนี้
จัดเก็บข้อมูลเหล่านี้เป็นข้อมูลลับของที่เก็บ
AWS_ACCESS_KEY_ID— ID คีย์การเข้าถึง AWS ของคุณAWS_SECRET_ACCESS_KEY— คีย์การเข้าถึงข้อมูลลับของ AWS ของคุณ
จําเป็นต้องมีภูมิภาคเสมอ — ตั้งค่าด้วย awsRegion หรือตัวแปรสภาพแวดล้อม AWS_REGION
เพิ่มเวิร์กโฟลว์
name: translate
on: push: branches: [main] paths: - "src/**/*.en.resx" - "src/**/*.en.json"
permissions: id-token: write # for aws-actions/configure-aws-credentials (OIDC) contents: write pull-requests: write
jobs: translate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::123456789012:role/gh-actions-translate aws-region: us-east-1 - id: translate uses: IEvangelist/resource-translator@v3 with: provider: | aws: region: us-east-1 # or rely on AWS_REGION from the step above formality: FORMAL brevity: true sourceLocale: en toLocales: '["fr","de","es"]' - if: steps.translate.outputs.has-new-translations == 'true' uses: peter-evans/create-pull-request@v7 with: title: ${{ steps.translate.outputs.summary-title }} body: ${{ steps.translate.outputs.summary-details }} branch: machine-translationการแปลของ Google Cloud
ตั้งค่า provider เป็น google ตรวจสอบสิทธิ์ด้วยข้อมูลเข้าสู่ระบบ JSON ของบัญชีบริการหรือคีย์ API โดยระบุเพียงอย่างเดียว:
จัดเก็บข้อมูลเหล่านี้เป็นข้อมูลลับของที่เก็บ
GCP_TRANSLATE_CREDENTIALS— คีย์ JSON ของบัญชีบริการ (เป็นสตริง JSON)GCP_TRANSLATE_API_KEY— หรือคีย์ Google Cloud API
googleProjectId เสริมจะอนุมานจากข้อมูลประจําตัวเมื่อละเว้น
เพิ่มเวิร์กโฟลว์
name: translate
on: push: branches: [main] paths: - "src/**/*.en.resx" - "src/**/*.en.json"
permissions: contents: write pull-requests: write
jobs: translate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - id: translate uses: IEvangelist/resource-translator@v3 with: provider: | google: # Provide EITHER a service-account JSON credential... credentials: ${{ secrets.GCP_TRANSLATE_CREDENTIALS }} # ...OR an API key: # apiKey: ${{ secrets.GCP_TRANSLATE_API_KEY }} model: nmt sourceLocale: en toLocales: '["fr","de","es"]' - if: steps.translate.outputs.has-new-translations == 'true' uses: peter-evans/create-pull-request@v7 with: title: ${{ steps.translate.outputs.summary-title }} body: ${{ steps.translate.outputs.summary-details }} branch: machine-translationStep 3: คอมมิตไฟล์ทรัพยากรต้นทาง
ไฟล์ทรัพยากรใช้แบบแผน Name.<sourceLocale>.<ext> ตัวอย่างเช่น Greetings.en.resx จะกลายเป็น Greetings.fr.resx, Greetings.de.resx และอื่นๆ หลังจากวิ่ง
Step 4: Let smart change detection protect your bill
changeDetection defaults to smart and stores a compact .github/resource-translator-state.json manifest in the repo. Commit that file so future runs can reuse stable translations, preserve manual target edits, and send only new, missing, changed, or settings-invalidated keys to the provider. If localized files already exist, run once with snapshotOnly: true to create the manifest without provider calls.
Step 5: ตรวจสอบเอาต์พุต
เมื่อเวิร์กโฟลว์เสร็จสิ้นการดําเนินการจะแสดงเอาต์พุตสามรายการที่คุณสามารถต่อเข้ากับคําอธิบาย PR ได้: summary-title, summary-details และ has-new-translations นอกจากนี้ยังเขียนสรุป Markdown ลงในหน้างานผ่าน core.summary