Skip to content

Plan: move dictionary configuration and export to liblcm - #1259

Draft
jasonleenaylor wants to merge 2 commits into
mainfrom
dictionary-config-to-liblcm
Draft

jasonleenaylor wants to merge 2 commits into
mainfrom
dictionary-config-to-liblcm

Conversation

@jasonleenaylor

@jasonleenaylor jasonleenaylor commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Adds the plan for moving dictionary configuration and export out of FieldWorks: Docs/dictionary-configuration-to-liblcm-plan.md. This PR contains only the plan. No code changes yet.

What the plan covers

The dictionary configuration model, its parsing and migration, ConfiguredLcmGenerator, and the XHTML, CSS, and Word writers move into a new liblcm project, SIL.LCModel.DictionaryConfiguration. Lexbox is the first consumer outside FieldWorks: Webonary 2.0 (XHTML and CSS) first, Word later. The JSON writer, the preview and paging code, and the configuration dialogs stay in FieldWorks.

  • Phase 0: extract the FieldWorks-specific dependencies (PropertyTable, RecordClerk, STA threads, WPF, System.Web) inside FieldWorks, with no liblcm changes.
  • Phase 1: move the code and its tests into liblcm and publish a beta package.
  • Phase 2: switch FieldWorks over to the package and delete the moved code.

Notes for reviewers

  • The plan does only what the move requires, plus what the export needs to run on Linux in Lexbox. One behavior change is planned: Word export stops copying media files next to the .docx.
  • Line numbers in the plan refer to FieldWorks 412ee26b8 and liblcm da7140f0.
  • The document is temporary. The last step of the plan (2.E) deletes it.

🤖 Generated with Claude Code


This change is Reviewable

Add Docs/dictionary-configuration-to-liblcm-plan.md. It plans the
move of the dictionary configuration model, its parsing and
migration, ConfiguredLcmGenerator, and the XHTML, CSS, and Word
writers into a new liblcm project,
SIL.LCModel.DictionaryConfiguration.

The plan has three phases: extract the FieldWorks-specific
dependencies inside FieldWorks, move the code into liblcm, then
switch FieldWorks over to the package.

The document is temporary. The last step of the plan deletes it.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

NUnit Tests

    1 files  ±  0      1 suites  ±0   14m 50s ⏱️ -34s
7 420 tests +110  7 341 ✅ +110  79 💤 ±0  0 ❌ ±0 
7 429 runs  +110  7 350 ✅ +110  79 💤 ±0  0 ❌ ±0 

Results for commit f33c6db. ± Comparison against base commit d6b31fd.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.92%. Comparing base (d6b31fd) to head (f33c6db).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1259      +/-   ##
==========================================
+ Coverage   40.41%   40.92%   +0.50%     
==========================================
  Files        1597     1602       +5     
  Lines      360490   360800     +310     
  Branches    42176    42245      +69     
==========================================
+ Hits       145696   147660    +1964     
+ Misses     185105   183644    -1461     
+ Partials    29689    29496     -193     

see 80 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mark-sil

Copy link
Copy Markdown
Contributor

Word export tests before the Word writer changes

The plan relies on the existing Word tests in several places. They are the done-criterion for 0.L, 0.O-1 and 0.O-2 ("LcmWordGeneratorTests pass and Word output is unchanged"), and after the move they are what proves the Word writer on Linux (1.D). That coverage is light for the job:

  • Only two tests in LcmWordGeneratorTests call SavePublishedDocx, and both produce files for manual inspection. Nothing asserts on a complete document: sections, headers, the styles part, numbering.
  • No test covers right-to-left: paragraph and section direction, right-to-left runs, or the complex-script font, size, bold and italic properties. That code took a series of fixes to get right (LT-21633, LT-21673, LT-22006, LT-22112), and 0.L step 3 and 0.O-2 rewrite it.

Suggestion: add a Word test item at the start of Phase 0 and make it a dependency of 0.L, 0.O-1, 0.O-2 and 0.O-3. Items that don't touch the Word writer need not wait for it.

  • Write the tests at the document level: call SavePublishedDocx on small fixture projects and assert on the XML parts of the .docx. Tests at that level survive the Phase 0 refactoring and move to liblcm unchanged, where they also run on Linux.
  • Include right-to-left fixtures: a right-to-left vernacular with a right-to-left entry style, a left-to-right dictionary with a right-to-left analysis language, and a reversal index.
  • Add a right-to-left project to the 0.P smoke list, because XML assertions do not show how Word renders the result.

One related point: 1.D adds an OpenXmlValidator check on a full .docx. It would be worth running that against today's output early in Phase 0. If it reports errors, fixing them changes Word output, and that is better done before the move than during it.

@mark-sil

Copy link
Copy Markdown
Contributor

Why does the JSON writer stay in FieldWorks?

Decision 1 moves the XHTML, CSS and Word writers and keeps JSON, but the plan gives a reason only for the three that move. Could it say why JSON stays? I assume it is because JSON is used only by the Webonary upload, which Lexbox does not need.

I ask because keeping it has costs that Decision 1's own reasoning argues against:

  • Decision 1 moves the writers together so that interface changes never cross repositories. LcmJsonGenerator would implement liblcm's ILcmContentGenerator from FieldWorks, so every change to that interface does cross, and FieldWorks has to change in step at each SilLcmVersion bump.
  • 0.M adds a public CSS-string method to CssGenerator only because the JSON writer calls into it from outside the assembly.
  • LcmJsonGeneratorTests stays behind and is one of the fixtures that needs the published test-helper package.

Its FieldWorks dependencies look like the ones Phase 0 already removes from the other writers: PropertyTable, RecordClerk, the collator and lead-character lookup, thread spawning, progress strings and HorizontalAlign. The one addition is Newtonsoft.Json, which would become a dependency of the new package.

If there is a reason to keep it, a sentence in Decision 1 would settle it. If not, moving it with the others looks simpler.

@mark-sil

Copy link
Copy Markdown
Contributor

2.B: the localization harvest also reads the default configuration files

2.B removes DistFiles/Language Explorer/DefaultConfigurations/** from source control and regenerates the files at build time, before installer harvesting. There is one more consumer of those files that the plan does not list.

XmlToPo harvests the configuration node labels for Crowdin from that folder (Build/Src/FwBuildTasks/Localization/XmlToPo.cs:194), and it skips silently when the folder is missing. The uploadUpdatesForTranslation target that runs it (Build/Localize.targets:74) does not depend on a build. Once the files are generated and gitignored, an upload from a clean checkout would drop every dictionary configuration label from messages.pot, and their translations with them. Nothing in the build or the tests would report it; the first sign would be English labels in the Dictionary Configuration dialog of a localized release.

Suggestion:

  • In 2.B, name XmlToPo as a consumer, and either make the extraction step a dependency of the upload target or have XmlToPo fail when the folder is missing.
  • In 2.D, add a check that messages.pot still contains the configuration labels. The localization checks there cover only the two resx strings.

Related: ConfigurableDictionaryNode.StringTable is an FwUtils type that DisplayLabel uses to show those translated labels, and it is not in the appendix of FieldWorks dependencies. Its replacement is a public-API decision for the model.

@mark-sil

Copy link
Copy Markdown
Contributor

0.E and 0.I treat MakeSafeFilePath as part of the copy code, but it also NFC-normalizes the paths that are not copied (ConfiguredLcmGenerator.cs:1034, :1056: the absolute path Word uses and the preview's file URI), so the normalization should stay in the engine's locate step; otherwise media with non-ASCII file names stop resolving, and no existing test would catch it.

Add item 0.O-0, Word export tests, ahead of the items that change
the Word writer (0.L, 0.O-1, 0.O-2, 0.O-3). It adds document-level
tests of SavePublishedDocx, right-to-left fixtures, and an
OpenXmlValidator run against the unchanged writer.

Keep MakeSafeFilePath in the engine (0.E, 0.I). It converts media
paths to NFC on the paths that are never copied, so it is part of
locating the file.

Replace ConfigurableDictionaryNode.StringTable, an FwUtils type,
with a LabelLocalizer delegate (0.I).

Name XmlToPo as a consumer of the default configuration files and
keep the configuration labels in messages.pot (2.B, 2.D).

Record why the JSON writer stays in FieldWorks: it supports only
the current Webonary upload and will be dropped.

Record the status of the SIL.ExCSS retarget (0.N).

Co-Authored-By: Claude <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.

3 participants