每次執行後開啟拉取請求
- id: translate uses: IEvangelist/resource-translator@v3 with: sourceLocale: en subscriptionKey: ${{ secrets.TRANSLATOR_KEY }} endpoint: ${{ secrets.TRANSLATOR_ENDPOINT }} region: ${{ secrets.TRANSLATOR_REGION }}
- if: steps.translate.outputs.has-new-translations == 'true' uses: peter-evans/create-pull-request@v7 with: branch: machine-translation title: ${{ steps.translate.outputs.summary-title }} body: ${{ steps.translate.outputs.summary-details }} labels: localizationMonorepos:每個套件的範圍轉換
with: sourceLocale: en include: | apps/web/**/*.en.resx packages/shared/**/*.en.json exclude: | **/dist/** **/__tests__/**品牌名稱與產品術語詞彙表
把.github/resource-translator.yml放進倉庫:
glossary: Acme: Contoso Octocat: Octocat ".NET": ".NET" "C++": "C++"詞彙表術語會之後翻譯,因此機器翻譯的輸出即使模型換成同義詞,仍保留你偏好的品牌名稱。
自訂翻譯器類別(產業/領域)
with: sourceLocale: en subscriptionKey: ${{ secrets.TRANSLATOR_KEY }} endpoint: ${{ secrets.TRANSLATOR_ENDPOINT }} categoryId: 1234abcd-5678-90ef-... 用一個能捕捉你產業詞彙和語氣(法律、醫療、行銷、內部工程等)的語料庫訓練 Azure Custom Translator 類別,並透過 categoryId 通過識別碼。這是 Azure 最強的語氣槓桿。
音色控制 + 嚴格備援
# .github/resource-translator.yml# Industry / domain — choose your tone via a Custom Translator categorycategoryId: legal-en
# Treat profanity strictly for content aimed at younger audiencesprofanityAction: MarkedprofanityMarker: Tag
# Fail the run rather than silently fall back to the general modelallowFallback: false 將自訂翻譯器categoryId與 profanityAction 和 allowFallback: false 結合,以確保語音一致性,若所選類別沒有針對目標區域的部署,工作流程就會失敗。
在開啟工作流程前先做一次試演
with: dryRun: true failOnError: false 動作仍會輸出摘要和步驟摘要,但不會寫入檔案。搭配failOnError: false,在反覆迭代時將每個問題都當作警告。