morningman opened a new pull request, #4286: URL: https://github.com/apache/doris-website/pull/4286
## Summary Adding a language to this site means editing code today. The locale list, the label and `htmlLang`, the opt-in flag, the bare-docs redirect, the status-plugin gate, the localization directory, the search analyzer, the search labels, the search cache key and every manifest name were written as Japanese. A second language could only be added by copying that code. `config/i18n.js` becomes the single registry. Each locale declares its code, label, `htmlLang` and whether it is still opt-in, and `docusaurus.config.js` derives the locale list, the locale configs, the bare-docs redirect and the status plugin from it. **A new locale is one line of configuration.** An introduced locale stays behind `DORIS_ENABLE_LOCALES` (CI enables exactly the locales a change can reach) or its own `DORIS_ENABLE_<LANG>` flag, so the existing `DORIS_ENABLE_JA` and every publishing workflow keep working unchanged. The render path follows the registry: - **docs adapter** — resolves its managed locales from `translations/config.json` and iterates them instead of a hardcoded constant. Reports carry the locale they belong to, and repository-wide findings (`unsupported_source_route`) are reported once rather than once per locale. The `japaneseDoc`/`contexts.ja`/`versions.ja` property access becomes generic. - **search plugin** — takes its locale, analyzer language, route bases, cache key and summary name from the configuration. The Japanese context labels move into `searchContextLabels` in `translations/config.json`, byte-for-byte the strings they replaced, and the summary artifact becomes `<locale>-search-summary.json` so a second locale cannot overwrite the first. - **status plugin** — writes one manifest per locale. The browser route groups are still built from **every** managed locale's pages, which is what lets an English page advertise its localized alternate; filtering that set by the current locale dropped `hreflang` from the English pages, and `scripts/i18n/verify-fixture.cjs` caught it. - **build scope** — stops naming a locale. It reports `enabled_locales` for CI, and a dictionary or state change only forces a render build for a locale that actually has translation state. ## Validation - `node --test scripts/i18n/__tests__/*.test.cjs scripts/__tests__/build-locales.test.cjs`: all pass. New `locale-registry.test.cjs` covers the registry's opt-in gating (both env forms), `managedLocales` intersection, and the route-group/manifest split that the fixture regression exercised. - **Byte-identical output for the single managed locale.** A real Japanese build at `5fda1b3f19` produces `.i18n-build/manifests/ja.json` with SHA-256 `3fb55bbd91d49c616ea1733f89e4a64ab1ff70f0ff5bff345639e6df6608fb2b`, exactly the hash the pre-change code produced from the same commit. 1,779 pages, 0 differing entries. - The four search index files hold the same document sets (3,028 / 3,018 / 10 / 0). Their internal ordering differs, but two **pre-change** builds into different directories differ from each other the same way, so that is pre-existing build non-determinism, not this change. - `node scripts/i18n/verify-fixture.cjs` passes: the real three-language fixture covers stale SQL, unknown changes, approved prose, manual edits, source deletion, Chinese-only sources, separate versions and plugins, links and source timestamps. - `verify-static --partial` on the rebuilt Japanese site reports the same `verified: 1778, skipped: 696` and the same status counts as before. - `config/i18n.js` and `build-check.yml` parse; the build plan is unchanged with `DORIS_ENABLE_JA=true` and drops `ja` without it. ## Overlap with #4284 Both this PR and #4284 touch `scripts/i18n/build-scope.cjs` and `.github/workflows/build-check.yml`. This one renames the scope output `enable_ja` to `enabled_locales`; #4284 adds `partial_build` and `locale_csv` alongside it. They are independent, but whichever lands second needs a small rebase in that one return statement. ## Not covered `src/**` still holds 22 Japanese-specific UI helpers and components, and the translation pipeline (prompts, bot identity, branch names, per-locale state paths) still names Japanese. Those follow in separate PRs; this one makes the build and render path locale-generic. `verify-search.cjs` keeps its hardcoded Japanese queries and UI assertions — they are that scenario's test data, not locale logic — and only its summary artifact reference was updated. ## Versions - [x] dev - [x] 4.x - [x] 3.x - [x] 2.1 or older (build tooling only, no content) ## Languages - [x] Chinese - [x] English - [x] Japanese (build and render path only, no content change) ## Docs Checklist - [x] Checked by AI - [x] Test Cases Built - [x] Updated required version and language counterparts, or explained why not - [x] If only one language changed, confirmed whether source/translation counterparts need sync 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
