Skip to content

Translations from-spreadsheet: default locale and version bump - #107

Open
tokland wants to merge 10 commits into
developmentfrom
feature/translations-import-default-locale
Open

tokland wants to merge 10 commits into
developmentfrom
feature/translations-import-default-locale

Conversation

@tokland

@tokland tokland commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Required by https://app.clickup.com/t/4528615/869f24nhh

Three additions to translations from-spreadsheet: the first is the default behaviour, the other two opt-in.

"global" fields (like name/shortName/description/...) are now also posted

Until now, only columns field: language were posted. Bare field columns (the layout to-spreadsheet generates) now write the field itself, as users take the translation as an opportunity to improve/fix the default values themselves.

--default-locale (not default)

Columns of the default (DB) locale now also update the object field itself (formName: English writes formName), on top of writing the translation. Keeping both means the field and its translation stay in sync and the sheet round-trips through to-spreadsheet, which fills the locale columns from the translations.

--bump-versions (not default)

The Capture apps cache the metadata of each data set/program and refresh it only when its version changes, so imported translations keep showing as the old values. This increments the version of the data sets and programs using a data element whose translations changed.

tokland and others added 10 commits August 3, 2026 10:29
Columns of the default (DB) locale now also yield the value of the object
field itself, on top of the translation, so both stay in sync and the sheet
round-trips through 'to-spreadsheet' (which reads locale columns from the
translations).

Locales are matched by language part, so "en" also matches a column mapped
to "en_GB", and the field name comes from the column prefix ("Left side
description" -> leftSideDescription).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Apply the default-locale values on the posted objects and warn about columns
that would not do what the operator expects:

- Fields the instance does not declare as translatable in /api/schemas: DHIS2
  ignores unknown properties, so such a column posts fine but changes nothing.
- Default-locale columns writing a unique field (name, shortName), where a
  duplicated value makes the whole payload fail to validate.

Both are warnings (one per model/field, not per row), reviewed in the dry run
that is still the default without --post.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Capability spec for the whole 'translations from-spreadsheet' command, not
just the default-locale addition: spreadsheet format, object matching,
translation merging, schema validation warnings and the dry-run default.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Capture apps cache the metadata of each data set/program and refresh it
only when its version changes, so the version has to be readable and writable
to invalidate that cache.

ProgramsRepository had no save. The new one merges the changed fields over the
stored :owner object instead of posting the entity as it is: the entity is a
partial view of the D2 model and the metadata import uses mergeMode=REPLACE,
which would drop every field missing from the payload (in particular turning
the nested programStages into partial objects). Same approach as
MetadataD2Repository.mergeWithExistingObjects.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Increment the version of the data sets and programs using a data element whose
translations changed, so the Capture apps refresh their cached metadata instead
of keeping showing the old values.

Opt-in, as it writes objects the operator never listed in the spreadsheet. The
scope is data elements only: translating an option set or a tracked entity
attribute does not bump anything, even though those are cached too. Bumps are
posted apart from the translations payload, so --save-payload does not show
them, and a dry run only logs them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…dsheet'

A column named as a translatable field with no locale (name, shortName,
formName...) now writes the object field itself, matching the layout that
'to-spreadsheet' generates. The name column is written only when the row
also has an id/code, otherwise it stays a lookup key. Columns that are not
a translatable field of the model are ignored with a warning, and the run
logs a per-model summary of the fields updated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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