تجاوز المسار باستخدام مدخل 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).
categoryIdAzure Custom Translator فئة — مقبض الصناعة/المجال (القانوني، الطبي، التسويق، إلخ). تم إرسالها ?category=....
textTypeالافتراضي على plain. استخدم html فقط إذا كانت قيم الموارد تحتوي على شظايا HTML حقيقية.
profanityActionكيفية التعامل مع المصطلحات البذيئة في المخرجات المترجمة.
profanityMarkerلا معنى له إلا عندما يكون profanityAction "Marked".
allowFallbackقم بتعيين false لفشل الترجمة عندما لا يكون لدى categoryId نشر لموقع هدف بدلا من العودة إلى النموذج العام.
apiVersionنسخة API المترجمة 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) في أي نوم ارتكاف واحد. الافتراضي على 30000. رأس Retry-After لأزور يحترم بالضبط عند وجوده؛ وإلا يستخدم ارتداد أسي متقطع، مع حد أقصى لهذه القيمة.
protectPlaceholdersالافتراضي على true. عند تشغيلها، يتم استبدال رموز مثل {{name}} و ${var} و {0} و {0:N2} و %s و %1$s وHTML برموز سنتينل قبل الترجمة وتستعاد بعد ذلك. قم بتعطيله فقط عندما يحتوي المصدر عمدا على حروف مؤقتة.
customPlaceholderPatternsتمت إضافة أنماط regex إضافية (بدون فاصلات) إلى مجموعة الرموز المؤقتة الافتراضية، مثل <<.+?>> لصياغة الرموز المخصصة. يتم تجاهل القواعد غير الصالحة.
noTranslatePatternsأنماط الغلوب تطابق مع مفاتيح على مستوى المحلل (مسار JSON المنقط، name RESX، msgid PO، وحدة XLIFF 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 لا تحتوي على مقبض نغمة واحد. يجمع إعدادان ليمنحوك معظم عناصر التحكم نفسها:
- الصناعة / المجال: استخدم
categoryIdللإشارة إلى فئة Azure Custom Translator المدربة على مجموعتك الخاصة — سواء القانونية أو التقنية أو الطبية أو التسويق أو أي شيء آخر. هذه هي أقوى رافعة للنبرة، وصوت العلامة التجارية، والمفردات. - نص سطحي: استخدم القاموس لتحديد أسماء العلامات التجارية ومصطلحات المنتجات حرفيا، واستخدم
profanityActionلإزالة المصطلحات النابية عند استهداف التوطين للجمهور الأصغر سنا.