move loc build tooling to ui-core#2
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request extracts localization build tooling into ui-core as a reusable Node-side package (@microbit-apps/ui-core/loc), providing shared layer discovery, catalog merging, glyph/charset validation, and per-language loc.g.ts/hex generation for apps in the microbit-apps stack.
Changes:
- Adds a public
@microbit-apps/ui-core/locAPI surface and two CLI binaries (loc-strings,loc-gen). - Introduces orchestration for per-language builds and coverage reporting, including translation-table emission and hex output.
- Adds generic charset resolution/validation/emit support via
locales/charsets.jsonacross discovered layers.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Declares package subpath export for /loc and exposes loc-strings/loc-gen bins. |
| loc-tools/README.md | Documents the new localization tooling package layout, usage, and configuration. |
| loc-tools/index.mjs | Exposes the public API entrypoint intended for @microbit-apps/ui-core/loc. |
| loc-tools/gen.mjs | Implements the per-language build/coverage orchestrator (merge, validate, emit, build, copy hex). |
| loc-tools/fonts.mjs | Adds font glyph-coverage parsing and a cached coverage provider. |
| loc-tools/extract.mjs | Refactors source-string extraction into reusable functions + a runLocStrings entrypoint. |
| loc-tools/emit.mjs | Implements loc.g.ts emission and default-state restore helpers. |
| loc-tools/charsets.mjs | Implements charset layer resolution and hard validation against font coverage. |
| loc-tools/catalogs.mjs | Implements dependency-based locales layer discovery and per-language merge. |
| loc-tools/bin/loc-strings.mjs | Adds CLI wrapper for regenerating locales/<srcLang>.json from sources. |
| loc-tools/bin/loc-gen.mjs | Adds CLI wrapper for simple consumers to run loc builds/coverage with optional config. |
Comments suppressed due to low confidence (1)
loc-tools/extract.mjs:102
unquotecurrently only handles\n,\t, and\rescapes. Other valid JS/TS escapes (notably\uXXXX,\xXX,\b,\f,\v, and\u{...}) will be decoded incorrectly, which can corrupt extracted catalog keys/values and make localization builds inconsistent with runtime strings. Consider expanding the escape handling to cover standard JS string escapes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
extract loc build tooling into a reusable package
Follow-up refinement to the earlier loc update.
Moves the localization build machinery from microcode-v2
into ui-core as
@microbit-apps/ui-core/loc, so that apps built onthis stack get catalog merging, glyph validation, string extraction, and
per-language
loc.g.ts/hex generation without reimplementing it.loc-tools/—runLocGen/runCoverageModeAPI +loc-strings/loc-genbins. Layer discovery walks pxt.json deps (deps-first, app last). App-specific
steps (tooltip inventory, tagline rule, web snapshots, hex naming) are hooks.
locales/charsets.json(
{lang: {field: string}}); the tool merges, hard-validates (paired lengths,no dup code points, glyph coverage), and emits
_loc.<field> = "...". The declaringlibrary owns each field's meaning.
scripts/locstrings.mjsremoved.