Step 1: Xaiv ib tug txhais lus muab kev pab
Qhov kev nqis tes ua haujlwm nrog Azure AI Tus Neeg Txhais Lus, AWS Txhais Lus thiab Google Huab Txhais lus tom qab ib qho kev sib koom ua ke API nto. Xaiv ib tus neeg zov me nyuam ib qho kev khiav nrog cov tswv yim provider - cov txheej txheem ua haujlwm zoo ib yam tsis hais tus neeg muab kev pabcuam; tsuas yog cov ntawv pov thawj sib txawv. Saib Cov chaw muab kev txhais lus rau kev sib piv tag nrho.
Step 2: Ntxiv cov ntawv pov thawj thiab kev ua haujlwm
Khaws koj tus neeg zov me nyuam cov ntawv pov thawj raws li GitHub repository secrets, tom qab ntawd tsim .github/workflows/translate.yml. Xaiv koj tus kws kho mob hauv qab no rau nws qhov kev teeb tsa tshwj xeeb - tus so ntawm kev ua haujlwm zoo ib yam.
Azure AI Tus Neeg Txhais Lus
Azure yog lub neej ntawd tus muab kev pab, yog li provider tej zaum yuav raug rho tawm. Muab Azure AI Txhais lus cov peev txheej hauv Azure portal, tom qab ntawd khaws nws cov ntawv pov thawj:
Khaws cov no raws li repository secrets
TRANSLATOR_KEY— tus yuam sij subscription rau cov peev txheej.TRANSLATOR_ENDPOINT— lub cheeb tsam endpoint URL.TRANSLATOR_REGION— cov peev txheej Azure cheeb tsam.
Ntxiv cov workflow
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-translationAWS Txhais Lus
Teem provider rau aws. Nyiam OIDC los ntawm aws-actions/configure-aws-credentials yog li tsis muaj kev zais cia ntev ntev - cov kauj ruam xa tawm AWS_REGION rau koj. Txhawm rau siv cov yuam sij zoo li qub, khaws cia:
Khaws cov no raws li repository secrets
AWS_ACCESS_KEY_ID— koj AWS nkag mus rau tus ID tseem ceeb.AWS_SECRET_ACCESS_KEY— koj AWS zais cia nkag yuam sij.
Ib cheeb tsam ib txwm yuav tsum tau ua — teeb tsa nws nrog awsRegion lossis AWS_REGION ib puag ncig hloov pauv.
Ntxiv cov workflow
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-translationGoogle Huab Txhais lus
Teem provider rau google. Txheeb xyuas qhov tseeb nrog ib qho kev pabcuam-account JSON daim ntawv pov thawj lossis API tus yuam sij — muab raws nraim ib qho:
Khaws cov no raws li repository secrets
GCP_TRANSLATE_CREDENTIALS— ib qho kev pabcuam-account JSON tus yuam sij (raws li JSON hlua).GCP_TRANSLATE_API_KEY— lossis Google Cloud API yuam sij.
Ib qho kev googleProjectId yeem yog inferred los ntawm daim ntawv pov thawj thaum rho tawm.
Ntxiv cov workflow
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: Cog lus ib qho ntaub ntawv peev txheej
Cov ntaub ntawv peev txheej siv cov Name.<sourceLocale>.<ext> lus cog tseg. Piv txwv li Greetings.en.resx dhau los ua Greetings.fr.resx, Greetings.de.resx thiab lwm yam tom qab khiav.
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: Xyuas cov zis
Thaum lub workflow tiav, qhov kev txiav txim nthuav tawm peb cov zis uas koj tuaj yeem xaim rau hauv PR cov lus piav qhia: summary-title, summary-details thiab has-new-translations. Nws kuj sau ib tug Markdown ntsiab lus rau hauv txoj hauj lwm nplooj ntawv los ntawm core.summary.