refactor(i18n): unify engine dynamic metadata localization with global i18n#548
Open
Changdw wants to merge 1 commit into
Open
refactor(i18n): unify engine dynamic metadata localization with global i18n#548Changdw wants to merge 1 commit into
Changdw wants to merge 1 commit into
Conversation
Contributor
Author
flowchart TD
classDef static fill:#eef7ff,stroke:#5b8def,color:#16355f;
classDef dynamic fill:#fff7e8,stroke:#d48806,color:#5b3b00;
classDef runtime fill:#eefcf1,stroke:#52c41a,color:#1f4d1a;
classDef note fill:#fafafa,stroke:#999,color:#444,stroke-dasharray: 5 5;
subgraph S["1. 资源来源"]
S1["CLI 静态 i18n 资源\nstatic/i18n/{en|zh}/*.json"]:::static
S2["Engine i18n 资源\npackages/engine/editor/i18n/{lang}/*.js\n例如 localization.js / assets.js / modules/*.js"]:::dynamic
S3["平台/插件 i18n 资源\npackages/platforms/*/i18n/{lang}.json\n或插件目录 i18n/*.json"]:::dynamic
S4["Engine 动态元数据源\nengineRoot/editor/engine-features/render-config.json\nengineRoot/cocos/core/platform/macro.ts"]:::dynamic
end
subgraph M["2. 唯一翻译机制(CLI 全局 i18next)"]
M1["src/i18n/index.ts\n模块加载时初始化 i18next\n先装入 CLI 静态 JSON"]:::runtime
M2["src/core/base/i18n.ts\nsetLanguage()\ntransI18nName()\nregisterLanguagePatch()"]:::runtime
M1 --> M2
end
subgraph T["3. 初始化与时序"]
T1["CLI 启动 / 首次 import i18n"]:::runtime
T2["把 CLI 静态 JSON 放进全局 i18next"]:::runtime
T3["Engine.init(enginePath)"]:::runtime
T4["src/core/engine/index.ts::_loadEngineI18n()"]:::runtime
T5["把 packages/engine 的 JS 文案(zh/en)\n注册到全局 i18next\n前缀: ENGINE.*"]:::runtime
T6["resolveDefaultConfig()"]:::runtime
T7["getEngineDynamicConfigContribution()"]:::runtime
T8["读取 render-config.json / macro.ts\n生成默认值和动态 schema"]:::runtime
T9["动态 feature / flag 文案\n例如 i18n:ENGINE.features.*\n通过 CLI 全局 i18n 立即翻译成最终字符串"]:::runtime
T10["createEngineMetadataNodes() / createNode()"]:::runtime
T11["静态配置文案\n例如 i18n:configuration.* / i18n:builder.*\n通过 CLI 全局 i18n 翻译"]:::runtime
T12["pluginManager.register(platform)"]:::runtime
T13["把平台/插件 JSON 文案(zh/en)\n注册到全局 i18next\n前缀: 平台名或包名.*"]:::runtime
T1 --> T2 --> T3 --> T4 --> T5 --> T6 --> T7 --> T8 --> T9 --> T10 --> T11
T1 --> T12 --> T13
end
subgraph U["4. 运行期效果"]
U1["我们平时实际调用的都是同一套入口\ntransI18nName() / translateMetadataText()"]:::runtime
U2["setLanguage('zh' | 'en')\n切换当前语言"]:::runtime
U3["最终可翻译的 key 来源分三类\nCLI 自己的 key\nENGINE.* key\n平台/插件 key"]:::runtime
U4["当前设计约束\n dynamic-metadata 不再直接读取\n packages/engine 的 localization.js\n而是依赖 Engine.init() 先完成注册"]:::note
U2 --> U1
U3 --> U1
U4 --> U1
end
S1 --> T2
S2 --> T5
S3 --> T13
S4 --> T8
M2 --> T5
M2 --> T9
M2 --> T11
M2 --> T13
T9 --> U1
T11 --> U1
T13 --> U1
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor(i18n): 统一 engine 动态 metadata 的翻译路径并补充时序文档