Skip to content

translations to-spreadsheet: --program-id/--data-set-id filters and short locale references - #106

Open
tokland wants to merge 7 commits into
developmentfrom
feature/translations-generation
Open

tokland wants to merge 7 commits into
developmentfrom
feature/translations-generation

Conversation

@tokland

@tokland tokland commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closes https://app.clickup.com/t/4528615/869dc4guz?comment=90120236273934

Follow-up to #101, adding scoping and locale-matching capabilities to translations to-spreadsheet.

Changes

  • --program-id / --data-set-id filters (mutually exclusive). When set, objects are taken from that program's or data set's metadata dependency export (/api/programs/{id}/metadata, /api/dataSets/{id}/metadata) instead of the whole instance, so each generated spreadsheet is scoped to a single program or data set. Only the requested --models are kept from the export.
  • Short locale references. --locales now matches by exact base name first, then by substring, so Sotho resolves to Southern Sotho (Lesotho). A reference matching more than one locale is ambiguous and errors; no match warns and is skipped (as before).
  • Suffix-stripped column headers. The resolved locale's (...) qualifier is dropped from the column header (formName: Southern Sotho instead of formName: Southern Sotho (Lesotho)). This also fixes the round-trip: from-spreadsheet matches headers against suffix-stripped DB names, so previously any locale with a (country) suffix would not re-import.
  • Name column added after UID in every sheet, for readability.
  • Both options are documented in the README (To spreadsheet).

Test plan

  • Unit tests added/updated in ExportTranslationsUseCase.spec.ts (short/substring match, ambiguity error, stripped header, program-scoped fetch, data-set-scoped fetch, program/data-set exclusivity). yarn test green (91 tests); tsc --noEmit clean.
  • Verified end-to-end against live instances:
    • program-scoped export produces one program's objects; SothoSouthern Sotho header; a from-spreadsheet --post round-trip added a st_LS translation while preserving existing ones.
    • data-set-scoped export (--data-set-id kQRnZsbyV40 --models 'dataSets[name,shortName,description],sections[name],dataElements[name,shortName,formName,description]' --locales French,Spanish) produces 1 dataSet / 4 sections / 12 dataElements; every cell (165) compared against the API matched.

tokland and others added 7 commits July 6, 2026 12:37
Add a --program-id option to `translations to-spreadsheet`. When set, objects
are taken from that program's metadata dependency export
(/api/programs/{id}/metadata) instead of the whole instance, so each generated
spreadsheet is scoped to a single program.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…aders

Locale references passed to `translations to-spreadsheet --locales` now match by
exact base name first, then by substring, so "Sotho" resolves to
"Southern Sotho (Lesotho)". A reference matching more than one locale is
ambiguous and errors; no match warns and is skipped (as before).

The resolved locale's " (...)" suffix is stripped from the column header, so
headers are shorter and round-trip with `from-spreadsheet`, which matches
headers against suffix-stripped DB names.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`buildObject` returned the internal MetadataObject verbatim, leaking the
`model` bookkeeping field (used only for grouping) into the posted
payload as `"model": "dataElements"`. Omit it when building the D2 object.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The export sheet now includes a dedicated Name (object.name) column after
UID. Update the spec expectations (header, row values, autofilter refs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Scope the export to a data set's metadata dependency export
(/api/dataSets/{id}/metadata), mirroring --program-id. Both options share the
same code path (getDependencyMetadataObjects) and are mutually exclusive.

Document --program-id/--data-set-id in the README.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tokland

tokland commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@tokland tokland changed the title translations to-spreadsheet: --program-id filter and short locale references translations to-spreadsheet: --program-id/--data-set-id filters and short locale references Sep 15, 2026
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.

1 participant