Step 1: Khetha mofani oa phetolelo
Ketso e sebetsa le Azure AI Translator, Phetolelo ea AWS le Phetolelo ea Google Cloud ka mor'a bokaholimo bo le bong bo kopaneng ba API. Khetha mofani a le mong ka ho matha ka ho kenya provider — ts'ebetso ea mosebetsi e itšoara ka mokhoa o ts'oanang ho sa tsotelehe mofani; Ke litlhaloso feela tse fapane. Sheba Bafani ba phetolelo bakeng sa papiso e felletseng.
Step 2: Eketsa li-credentials le ts'ebetso ea mosebetsi
Boloka mangolo a mofani oa hau e le liphiri tsa polokelo ea GitHub, ebe u theha .github/workflows/translate.yml. Khetha mofani oa hau ka tlase bakeng sa tlhophiso ea eona e ikhethileng — ts'ebetso eohle ea ts'ebetso e ts'oana.
Azure AI Translator
Azure ke mofani ea fosahetseng, ka hona provider ka tloheloa. Fana ka mohloli oa mofetoleli oa Azure AI ho portal ea Azure, ebe u boloka mangolo a eona:
Boloka tsena e le liphiri tsa polokelo
TRANSLATOR_KEY— Senotlolo sa ho ngolisa bakeng sa sesebelisoa.TRANSLATOR_ENDPOINT— URL ea sebaka sa ho qetelaTRANSLATOR_REGION— Sebaka sa Azure sa Resource.
Eketsa ts'ebetso ea ts'ebetso
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-translationPhetolelo ea AWS
Beha provider ho aws. Khetha OIDC ka aws-actions/configure-aws-credentials e le hore ho se be liphiri tse phelang nako e telele tse bolokiloeng — mohato o romelloang kantle ho naha o AWS_REGION oa hau. Ho sebelisa linotlolo tsa static ho e-na le hoo, boloka:
Boloka tsena e le liphiri tsa polokelo
AWS_ACCESS_KEY_ID— ID ea hau ea senotlolo sa AWS AccessAWS_SECRET_ACCESS_KEY— Senotlolo sa hau sa phihlello ea lekunutu sa AWS
Sebaka se lula se hlokahala — se behe ka awsRegion kapa AWS_REGION tikoloho e fetohang.
Eketsa ts'ebetso ea ts'ebetso
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-translationPhetolelo ea Google Cloud
Beha provider ho google. Netefatsa ka setifikeiti sa JSON sa ak'haonte ea ts'ebeletso kapa senotlolo sa API — fana ka e le 'ngoe:
Boloka tsena e le liphiri tsa polokelo
GCP_TRANSLATE_CREDENTIALS— Senotlolo sa JSON sa ak'haonte ea ts'ebeletso (joalo ka khoele ea JSON).GCP_TRANSLATE_API_KEY— Kapa senotlolo sa Google Cloud API.
googleProjectId ea boikhethelo e kenngoa ho tsoa ho setifikeiti ha e tlositsoe.
Eketsa ts'ebetso ea ts'ebetso
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: Etsa file ea mohloli oa mohloli
Lifaele tsa lisebelisoa li sebelisa kopano ea Name.<sourceLocale>.<ext>. Ka mohlala, Greetings.en.resx ba Greetings.fr.resx, Greetings.de.resx, joalo-joalo kamora ho matha.
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: Hlahloba tlhahiso
Hang ha ts'ebetso e felile, ketso e pepesa liphetho tse tharo tseo u ka li hokahanyang le tlhaloso ea PR: summary-title, summary-details le has-new-translations. E boetse e ngola kakaretso ea Markdown leqepheng la mosebetsi ka core.summary.