Skip to content

check lokalize generated translation sources into the tree#1827

Draft
VishnuSanal wants to merge 1 commit into
openwallet-foundation:mainfrom
VishnuSanal:lokalize
Draft

check lokalize generated translation sources into the tree#1827
VishnuSanal wants to merge 1 commit into
openwallet-foundation:mainfrom
VishnuSanal:lokalize

Conversation

@VishnuSanal

Copy link
Copy Markdown
Member

Fixes #1811

  • Tests pass
  • Appropriate changes to README are included in PR

Translation sources rendered by the lokalize plugin from values*/strings.json
are now checked into the tree instead of generated into build/ on every
compile. This fixes two things:

  1. Non-Gradle downstreams can compile the source tree as-is. Previously the
    generated Kotlin (GeneratedTranslations, Strings_*, GeneratedStringKeys)
    only existed after a Gradle build, so a plain source checkout didn't compile.
  2. Removes the configuration-time build lag: the old
    configureEach block realized every task in the project just to wire the
    generator onto the compile path. With generation off the compile path, it's
    gone.

What changed

Checked-in modules (multipaz-doctypes, multipaz-utopia)

  • Rendered Kotlin is committed under src/commonMain/generated/.
  • generateMultipazStrings writes there on demand (run it after editing strings); compiling no longer regenerates.
  • lokalizeCheckGenerated renders in memory and fails the build if the committed sources drift from strings.json, printing the exact regen command. It's wired into check, so ./gradlew build enforces it — including CI (unit-test.yml runs build).

Plugin

  • Legacy build/-generation mode and its configureEach block deleted (zero users remain once both JSON modules are checked in).
  • generatedSourceDir demoted from a mode toggle to a convention-defaulted override (src/commonMain/generated).
  • outputDir routes XML modules to a throwaway build/ path so a skipped run never touches src/.

multipaz-compose (unchanged behavior)

  • It's an XML module — strings resolve via Compose Resources at runtime, no Kotlin is generated, so generateMultipazStrings skips.
  • Removed the dead androidReleaseSourcesJar dependsOn generateMultipazStrings hack.

.gitattributes

  • Marks */src/commonMain/generated/** linguist-generated=true so it collapses in diffs and signals it's never hand-edited.

How the safety net works

strings.json (source of truth, committed) → generateMultipazStringssrc/commonMain/generated/*.kt (committed). lokalizeCheckGenerated (in check) guarantees the two never diverge on a merged PR.

Testing

  • ./gradlew :multipaz-doctypes:lokalizeCheckGenerated :multipaz-utopia:lokalizeCheckGenerated
    — both pass (✓ Generated strings are up to date (23 languages)).
  • Editing a strings.json makes the drift check fail with the fix command; regenerating restores green.
  • Clean from-scratch builds of all three modules (build/ wiped); KSP (kspCommonMainKotlinMetadata) and jvmTest pass; build/generated/kmp never reappears for the JSON modules.
  • Dry-run task graphs confirm generateMultipazStrings is off every compile and sourcesJar path.
  • multipaz-compose source tree stays pristine — the skipped generator writes nothing under src/.

- multipaz-doctypes and multipaz-utopia now commit their rendered sourcesunder src/commonMain/generated/ (GeneratedTranslations, per language Strings_*, and GeneratedStringKeys). Compiling reads them directly and no longer regenerates.
- generateMultipazStrings now writes into that committed directory on demand rather than into build/ on every compile. Run it after editing strings.
- lokalizeCheckGenerated renders in memory and fails the build (with the fix command) if the committed sources drift from strings.json. It is wired into check, so ./gradlew build enforces it — including in CI (unit-test.yml).
- Remove the legacy build/-generation mode and its configureEach block; with both JSON modules checked in there are no users left, which eliminates the configuration-time lag. generatedSourceDir is demoted from a mode toggle to a convention-defaulted override (src/commonMain/generated).
- multipaz-compose is unchanged in behavior: it is an XML module that resolves strings through Compose Resources at runtime and generates no Kotlin, so generateMultipazStrings skips for it. Its dead androidReleaseSourcesJar dependsOn hack is removed too.
- .gitattributes marks the generated tree linguist-generated so it collapses in diffs and is never hand-edited.

Signed-off-by: VishnuSanal <vishnusanalt@gmail.com>
@hanluOMH

Copy link
Copy Markdown
Contributor

Looks good to me

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.

Keep generated translation files checked in.

2 participants