如果你需要一個非預設位置,請用configPath輸入覆蓋路徑。
圖式
# .github/resource-translator.ymlsourceLocale: entoLocales: - fr - de - esinclude: - "src/**/*.en.json" - "apps/**/*.en.resx"exclude: - "**/__tests__/**"glossary: Acme: Contoso Octocat: Octocat # keep brand names verbatim
# Domain / industry — uses an Azure Custom Translator category trained on# your tone and vocabulary. Leave unset for the general model.categoryId: my-custom-translator-category
# Translator request shape — most users can ignore these.textType: plain # plain | htmlprofanityAction: NoAction # NoAction | Marked | DeletedprofanityMarker: Asterisk # Asterisk | Tag (only when profanityAction == Marked)allowFallback: true # false fails when the categoryId has no deployment
apiVersion: "3.0"
# Resilience — Translator returns 429 under load. Defaults are usually# fine; tune only if your runs are large enough to hit them.maxRetries: 5retryBackoffMs: 30000 # cap on any single backoff sleep (ms)
# Placeholder protection. ON by default — wraps tokens like {{name}},# {0}, %s, ${var} into sentinels before translation and restores them# on the way back. Set false only when source intentionally contains# placeholder-shaped literals.protectPlaceholders: truecustomPlaceholderPatterns: - "<<.+?>>" # any extra token syntax you use
# Per-key opt-out. Keys matching any glob are dropped from the request# and pass through with the source value preserved.noTranslatePatterns: - "errors.code.*" - "brands.*"場參
| 菲爾德 | 種類 | 註釋 |
|---|---|---|
sourceLocale | string | 如果未設定,則回退到sourceLocale輸入。 同時轉發到翻譯器作為from=<locale>所以短字串唔會自動偵測。 |
toLocales | string[] | 數組或者逗號分隔嘅字串。 |
include / exclude | string[] | 根據絕對路徑和工作空間相對路徑評估的 Glob 模式。 |
glossary | map<string,string> | 譯後術語覆蓋。 詞界感知(處理C++,.NET)。 |
categoryId | string | Azure Custom Translator類別 — 你的行業/領域旋鈕(法律、醫療、營銷語氣等)。 以?category=...派出。 |
textType | "plain" | "html" | 預設為plain。 只有當你嘅資源值包含真實嘅HTML片段時,才用html。 |
profanityAction | "NoAction" | "Marked" | "Deleted" | 點樣處理翻譯輸出入面嘅褻瀆詞彙。 |
profanityMarker | "Asterisk" | "Tag" | 只有當profanityAction "Marked"時才有意義。 |
allowFallback | boolean | 設定為false,當你的categoryId沒有為目標語言環境部署時,翻譯失敗,而不是回退到通用模型。 |
apiVersion | string | Translator REST API 版本。 預設為3.0。 |
maxRetries | integer | 暫時性 HTTP 回應的最大重試嘗試次數 (408, 425, 429, 500, 502, 503, 504)。 預設為5。 每個請求的 HTTP 呼叫總數為 1 + maxRetries。 |
retryBackoffMs | integer | 任何一次退避睡眠嘅上限(毫秒)。 預設為30000。 Azure 的 Retry-After 標頭在存在時會被準確地接受; 否則會使用抖動指數退避,上限為此值。 |
protectPlaceholders | boolean | 預設為true。 當打開時,{{name}}、${var}、{0}、{0:N2}、%s、%1$s 和 HTML 實體等標記會在翻譯前被 sentinel 標記取代,並在翻譯後恢復。 只有當來源故意包含佔位符形狀的文字時才禁用。 |
customPlaceholderPatterns | string[] | 額外嘅正則表達式模式(無分隔符)加入到預設佔位符集中,例如自訂標記語法嘅<<.+?>>。 無效的正則表達式將被忽略。 |
noTranslatePatterns | string[] | Glob 模式與解析器級鍵(JSON 虛線路徑、RESX name、PO msgid、XLIFF 單位id、INI/restext 鍵)匹配。 匹配的鍵會從請求中刪除並通過,並保留其源值。 |
裝貨令
- 該操作從工作流程中讀取明確的輸入。
- 它從
configPath載入 YAML 配置。 - 對於每一個共享字段,輸入就會獲勝; 否則會使用YAML值。
- 合併後嘅數值會得到驗證。 無效的枚舉(例如
profanityAction: Mask)會導致操作快速失敗,並顯示清晰的訊息。
語氣同工業,簡單嚟講
Azure AI Translator v3 API 沒有單一音調旋鈕。 兩個設定組合起來,就可以得到大部分相同嘅控制:
- 行業/領域: 用
categoryId指向一個根據你自己嘅語料庫訓練嘅 Azure Custom Translator類別 -- 法律、技術、醫療、市場營銷,或者其他任何嘢。 呢個係語氣,品牌聲音同詞彙嘅最有力嘅槓桿。 - 表面文字: 用呢個詞彙表逐字鎖定品牌名稱同產品術語,同時用
profanityAction去刪除粗俗嘅詞語,同時針對年輕受眾進行本地化。