עקף את הנתיב עם קלט configPath אם אתה צריך מיקום לא ברירת מחדל.
סכימה
# .github/resource-translator.ymlsourceLocale: en
# Provider config can be nested. Keep secrets in workflow inputs; use repo# config for non-secret defaults like region, model, formality, or category.provider: azure: categoryId: my-custom-translator-category apiVersion: "3.0" allowFallback: true
toLocales: - fr - de - esinclude: - "src/**/*.en.json" - "apps/**/*.en.resx"exclude: - "**/__tests__/**"glossary: Acme: Contoso Octocat: Octocat # keep brand names verbatim
# Translator request shape — most users can ignore these.textType: plain # plain | htmlprofanityAction: NoAction # NoAction | Marked | DeletedprofanityMarker: Asterisk # Asterisk | Tag (only when profanityAction == Marked)
# 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.*"התייחסות לשדה
providerEither a provider string or a nested provider block (provider.azure, provider.aws, or provider.google). Prefer nested blocks for provider-specific settings; keep secrets in workflow inputs rather than committed config.
sourceLocaleהוא חוזר לקלט sourceLocale אם לא מוגדר. גם הועברתי למתרגם from=<locale> כך שמחרוזות קצרות לא יתגלו אוטומטית.
toLocalesאו מערך או מחרוזת מופרדת בפסיק.
include / excludeדפוסי גלוב הוערכו מול מסלולים אבסולוטיים ויחסיים למרחבי עבודה.
glossaryמונחים לאחר התרגום עוקפים. מודע לגבולות מילים (מטפל ב-C++, .NET).
categoryIdקטגוריית Azure Custom Translator — הידית שלך בתעשייה/דומיין (משפטי, רפואי, שיווקי וכו'). נשלח כ-?category=....
textTypeברירת המחדל היא plain. השתמש html רק אם ערכי המשאבים שלך מכילים פרגמנטים אמיתיים של HTML.
profanityActionאיך להתייחס למונחים גסים בתוצרים מתורגמים.
profanityMarkerרק כש profanityAction "Marked".
allowFallbackהגדר false להיכשל בתרגום כשאין categoryId שלך פריסה למיקום יעד במקום לחזור למודל הכללי.
apiVersionגרסת API של REST למתרגם (REST). ברירת המחדל היא 3.0.
awsFormalityAWS Translate formality setting for supported target languages.
awsBrevitySet to true to enable AWS Translate brevity mode for supported language pairs.
awsTerminologyNames / awsParallelDataNamesAWS Translate custom terminology and parallel data resource names. Either an array or comma-separated string.
googleModelGoogle Cloud Translation model, e.g. nmt or base.
googleApiEndpointOptional Google Cloud Translation API endpoint override.
googleAutoRetryOptional Google Cloud Translation automatic retry toggle. Leave unset to use the Google client default.
maxRetriesניסיונות ניסיון חוזרים מרביים על תגובות HTTP חולפות (408, 425, 429, 500, 502, 503, 504). ברירת המחדל היא 5. סך כל קריאות HTTP לכל בקשה הוא 1 + maxRetries.
retryBackoffMsקאפ (ms) בכל שינת Backoff בודדת. ברירת המחדל היא 30000. הכותרת Retry-After של אזור מכובדת בדיוק כשהיא נוכחת; אחרת משתמשים בחזרה מעריכית רועדת, שמוגבלת לערך זה.
protectPlaceholdersברירת המחדל היא true. כאשר פועלים, טוקנים כמו {{name}}, ${var}, {0}, {0:N2}, %s, %1$s ו-HTML מוחלפים בטוקנים של סנטינל לפני התרגום ומשוחזרים לאחר מכן. בטל רק כאשר המקור מכיל בכוונה מילוליים בצורת משאבים זמניים.
customPlaceholderPatternsתבניות regex נוספות (ללא מגבילים) נוספו לסט הזמני ברירת המחדל, למשל <<.+?>> לתחביר טוקנים מותאם אישית. רגקסים לא תקפים מתעלמים מהם.
noTranslatePatternsתבניות גלוב התאימו למפתחות ברמת המנתח (JSON dotted path, RESX name, PO msgid, XLIFF unit id, מפתח INI/restext). מפתחות תואמים נשלטים מהבקשה ומועברים עם ערך המקור שלהם נשמר.
changeDetectionDefaults to smart. Uses the committed state manifest to translate only changed or missing parser keys. Set to disabled or false to preserve the legacy always-translate behavior.
statePathPath to the deterministic smart change-detection state manifest. Defaults to .github/resource-translator-state.json.
סדר הטעינה
- הפעולה קוראת קלטים מפורשים מתהליך העבודה.
- הוא טוען את קונפיגורציית ה-YAML מ-
configPath. - על כל שדה משותף, הקלט מנצח; אחרת משתמשים בערך YAML.
- הערכים הממוזגים מאומתים. אנומים לא תקינים (למשל
profanityAction: Mask) גורמים לפעולה להיכשל במהירות עם הודעה ברורה.
טון ותעשייה, במונחים פשוטים
ל-Azure AI Translator v3 API אין כפתור טון יחיד. שתי הגדרות משתלבות כדי לתת לך את רוב השליטה:
- תעשייה / תחום: השתמש
categoryIdכדי להצביע על קטגוריית Azure Custom Translator שמאומנת על קורפוס משלך — משפטי, טכני, רפואי, שיווקי או כל דבר אחר. זהו המנוף החזק ביותר לטון, קול מותג ואוצר מילים. - טקסט שטחי: השתמשו מילון מונחים כדי לנעול שמות מותגים ומונחי מוצר במילה, והשתמשו
profanityActionכדי למחוק מונחים גסים כאשר מכוונים ללוקליזציה לקהלים צעירים.