Normalize Japanese language code jp to ISO 639-1 ja - #56
Closed
ronaldtse wants to merge 1 commit into
Closed
Conversation
IEC CDD source data uses "jp" for Japanese, but the browser's CSS visibility rules and the ISO 639-1 standard use "ja". This mismatch made all Japanese translations invisible: the data generated <span class="ml-jp"> spans, but the CSS only had body[data-lang="ja"] rules, and the LanguageSwitcher didn't list Japanese at all. Fix at the closest point to the data — the loadDictionary() function in data.ts, where raw JSON is parsed into EntityNode objects. A new normalizeLanguageCodes() function walks every *_ml field on each entity and renames the "jp" key to "ja" (preserving an existing "ja" key if both are present). The LANG_ALIASES map is extensible for future non-standard codes. Also add "ja" to KNOWN_LANGS in LanguageSwitcher.vue so the Japanese button appears in the language toggle. Verified: iec62683 entity ACE061 now renders <span class="ml-ja"> with the correct Japanese text in built output. Zero ml-jp spans remain. All 5 languages (de, en, fr, ja, zh) render and respond to the language switcher.
ronaldtse
force-pushed
the
fix/normalize-jp-to-ja
branch
from
August 7, 2026 06:16
3764768 to
5d2a5d9
Compare
Contributor
Author
|
Closing in favor of opencdd/opencdd-ruby#23 — the normalization belongs in the Ruby gem at the XLS ingestion point, not in the browser pipeline. |
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.
Summary
IEC CDD source data uses
jpfor Japanese, but the browser's CSS visibility rules and the ISO 639-1 standard useja. This mismatch made all Japanese translations invisible.Fix: normalize at the data import boundary
Added a
normalizeLanguageCodes()pipeline stage insrc/lib/build/stages.tsthat runs duringnpm run fetch-data, right after data is acquired intosrc/content/data/. The stage:database.jsonunderdataTarget*_mlfieldjpkey toja(preserving an existingjakey if both are present)Idempotent and extensible via the
LANG_ALIASESmap ({"jp": "ja"}— add more if other non-standard codes surface).Also adds
jatoKNOWN_LANGSinLanguageSwitcher.vue.Why at import, not at build-time load
The normalization happens once when data enters our ecosystem (during
fetch-data), not every timeloadDictionary()reads the JSON at build time. The committed/fetched data is clean; downstream consumers don't need defensive checks.Verified on real data
After normalization: 0
jpkeys remaining, 80jakeys present across all dictionaries. Built output confirmsml-jaspans (notml-jp) on multilingual entity pages.Multilingual data coverage (from
../data-private/)Test plan
npm run check— 0 errorsnpm run build— 25,476 pages builtnpm run fetch-data— "renamed 80 key(s) across 8 dict(s)"jpkeys, 80jakeys in committed dataml-jaspans present on iec62683/p/ACE061