公司动态

Airflow翻译管理_airflow-translations

📅 2026/7/23 20:40:16
Airflow翻译管理_airflow-translations
以下为本文档的中文说明airflow-translations 是 Apache Airflow 项目的国际化翻译管理技能用于为 Apache Airflow 的用户界面添加或更新翻译。该技能提供了一套完整的翻译工作流程从设置新的语言环境、搭建翻译文件框架、按照语言特定规范进行翻译到最终验证翻译结果的正确性。翻译工作分为两种情况如果目标语言环境已存在则直接进入更新现有翻译的流程如果目标语言环境尚不存在则需先完成添加翻译的初始化配置。添加新翻译时需要先在指定目录下创建语言环境文件夹然后更新多个配置文件并在保持现有字母排序的前提下插入新语言条目。使用场景包括将 Airflow UI 翻译成新的语言以服务更多地区的用户对已有翻译进行校对和更新以修复错误或过时的内容在 Airflow 版本升级后同步更新翻译文件以覆盖新增的 UI 文本以及社区贡献者为自己的母语提交翻译改进。该技能的工作目录位于 airflow-core/src/airflow/ui/public/i18n/locales/ 下。核心特点包括结构化的翻译添加流程、自动化的配置文件更新指引、语言特定的翻译规范指导、以及翻译结果的验证机制。对于 Apache Airflow 这样一个全球使用的开源项目来说翻译工作的规范化管理对于提升全球用户体验和促进社区参与具有重要意义。Airflow TranslationsDetermining the TaskTranslation work falls into one of two categories depending on whether thetarget locale already exists. Check if a directory for the locale exists underairflow-core/src/airflow/ui/public/i18n/locales/locale/. If it does, skipahead toUpdating an Existing Translation. If not, start withAdding a Translationbelow.Adding a TranslationWhen adding a translation, some configuration files need to be updated before translation work can begin.Setting up the localeFirst, create the locale directory:mkdir -p airflow-core/src/airflow/ui/public/i18n/locales/locale/Then update the following configuration files, keeping the existing alphabeticalordering in each file:airflow-core/src/airflow/ui/src/i18n/config.ts: add the locale to thesupportedLanguagesarray:{code:locale,name:native name},dev/breeze/src/airflow_breeze/commands/ui_commands.py: add the pluralsuffixes for the language to thePLURAL_SUFFIXESdict. Check the i18nextplural rules for the language at https://jsfiddle.net/6bpxsgd4 to determinewhich suffixes are needed:locale: [suffixes],.github/boring-cyborg.yml: underlabelPRBasedOnFilePath, add:translation:locale:-airflow-core/src/airflow/ui/public/i18n/locales/locale/*Scaffolding the translation filesOnce the configuration is in place, run the breeze command to copy everyEnglish namespace file into the new locale directory. This populates each keywith aTODO: translate:stub:breeze ui check-translation-completeness--languagelocale--add-missingThe generated files will look like this:{allRuns:TODO: translate: All Runs,blockingDeps:{dependency:TODO: translate: Dependency,reason:TODO: translate: Reason}}TranslatingWith the scaffolded files in place, read the locale-specific guideline for thetarget language (see the table underLocale-Specific Guidelinesbelow). Ifone exists, it contains the glossary, tone rules, and formatting conventionsthat must be followed. If no locale-specific guideline exists yet, follow thetranslation rules described later in this document.Replace everyTODO: translate: English terminologyentry, including the prefix,with the translated string.After all entries are translated, continue toValidationbelow.Updating an Existing TranslationWhen a locale already exists and you need to fill translation gaps, reviseexisting translations, or remove stale keys, start by reading thelocale-specific guideline for the language (see the table underLocale-Specific Guidelinesbelow). This establishes the glossary andformatting rules to follow.Next, read the locale’s existing JSON files underairflow-core/src/airflow/ui/public/i18n/locales/locale/to learn theterminology already in use. Consistency with established translations iscritical. If a term has been translated a certain way, reuse that exacttranslation.Then check the current state of completeness:breeze ui check-translation-completeness--languagelocaleIf there aremissingkeys, scaffold them withTODO: translate:stubs:breeze ui check-translation-completeness--languagelocale--add-missingIf there areextrakeys (present in the locale but not in English), removethem:breeze ui check-translation-completeness--languagelocale--remove-extraNow translate theTODO: translate:entries following the locale-specificguideline, then continue toValidationbelow.ValidationAfter completing translations, run these checks:Check completeness. The output should show 0 missing, 0 extra, and 0 TODOs:breeze ui check-translation-completeness--languagelocaleRun pre-commit hooks to fix formatting, licenses, and linting issues:prek ru n --from-ref main --hook-stage pre-commitGeneral Translation RulesThe following rules apply globally. If the locale-specific guideline for alanguage states differently, follow the locale-specific guideline.Terms Kept in EnglishThe terms below should remain in English by default. Locale-specific guidelinesmay override individual entries where an established local convention exists:TermReasonAirflowProduct nameDag/DagsAirflow convention; alwaysDag, neverDAGXCom/XComsAirflow cross-communication mechanism nameProvider/ProvidersAirflow extension package nameREST APIStandard technical termJSONStandard technical format nameIDUniversal abbreviationPIDUnix process identifierUTCTime standardSchemaDatabase termVariables and PlaceholdersTranslation strings use{{variable}}interpolation (i18next format).Never translate or remove variable names inside{{…}}. Placeholders may bereordered as needed for natural word order, but the exact variable casing mustbe preserved (e.g.,{{dagDisplayName}}).Plural FormsAirflow uses i18next plural suffixes (_one,_other, and optionally_zero,_two,_few,_many). Provide translations for all plural suffixes that thelanguage requires — the locale-specific guideline specifies which ones. If nolocale guideline exists, check the i18next plural rules athttps://jsfiddle.net/6bpxsgd4 and provide at minimum_oneand_other.HotkeysHotkey values (e.g.,hotkey: e) are literal key bindings and shouldnotbe translated unless the locale-specific guideline says otherwise.Translation File StructureAll translation files are JSON files located at:airflow-core/src/airflow/ui/public/i18n/locales/locale-name/Each locale directory contains namespace JSON files that mirror the Englishlocale (en/). The English locale is thedefault localeand the primarysource for all translations. The current namespace files are:admin.json,assets.json,browse.json,common.json,components.json,dag.json,dags.json,dashboard.json,hitl.json,tasks.jsonLocale-Specific GuidelinesBefore translating, read the locale-specific guideline file for the targetlanguage. These contain glossaries, tone rules, and formatting conventionstailored to each language. If a locale-specific guideline states differentlyfrom a global rule in this document, follow the locale-specific guideline.Locale CodeLanguageGuideline FilearArabiclocales/ar.mdcaCatalanlocales/ca.mddeGermanlocales/de.mdelGreeklocales/el.mdesSpanishlocales/es.mdfrFrenchlocales/fr.mdheHebrewlocales/he.mdhiHindilocales/hi.mdhuHungarianlocales/hu.mditItalian[locales/it.md](locales/it.md)jaJapaneselocales/ja.mdkoKoreanlocales/ko.mdnlDutchlocales/nl.mdplPolishlocales/pl.mdptPortugueselocales/pt.mdthThailocales/th.mdtrTurkishlocales/tr.mdzh-CNSimplified Chineselocales/zh-CN.mdzh-TWTraditional Chineselocales/zh-TW.mdIf the target locale file does not yet exist, follow only the global rules inthis document.