每次运行后打开一个拉取请求
- 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 传递其 ID。 这是 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,在迭代时将每个问题都显示出来作为警告。