Skip to content

move loc build tooling to ui-core#2

Merged
humanapp merged 2 commits into
mainfrom
humanapp/text-entry-loc
Jul 23, 2026
Merged

move loc build tooling to ui-core#2
humanapp merged 2 commits into
mainfrom
humanapp/text-entry-loc

Conversation

@humanapp

Copy link
Copy Markdown
Collaborator

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 on
this stack get catalog merging, glyph validation, string extraction, and
per-language loc.g.ts/hex generation without reimplementing it.

  • loc-tools/runLocGen/runCoverageMode API + loc-strings/loc-gen
    bins. Layer discovery walks pxt.json deps (deps-first, app last). App-specific
    steps (tooltip inventory, tagline rule, web snapshots, hex naming) are hooks.
  • Generic charset emission — any locale layer may ship locales/charsets.json
    ({lang: {field: string}}); the tool merges, hard-validates (paired lengths,
    no dup code points, glyph coverage), and emits _loc.<field> = "...". The declaring
    library owns each field's meaning.
  • Single extractor implementation (deletes the three copies); scripts/locstrings.mjs removed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/loc API 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.json across 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

  • unquote currently only handles \n, \t, and \r escapes. 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.

Comment thread loc-tools/gen.mjs
Comment thread loc-tools/fonts.mjs
Comment thread loc-tools/README.md
Comment thread package.json
@humanapp
humanapp merged commit 10c1c7b into main Jul 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants