Skip to content

Let the host application supply TableView's strings - #456

Open
SolidRockProgrammer wants to merge 3 commits into
w-ahmad:mainfrom
Datgel:feat/host-string-resolver
Open

SolidRockProgrammer wants to merge 3 commits into
w-ahmad:mainfrom
Datgel:feat/host-string-resolver

Conversation

@SolidRockProgrammer

Copy link
Copy Markdown

Builds on #449 (its two commits are the base of this branch; only the last commit is new here).

Adds TableViewLocalization.StringResolver, a public Func<string, string?> an application can set to answer any TableView string by its resource key (the names in WinUI.TableView.resw; TableViewLocalization.Keys lists them):

  • for a language the library does not ship (the app already has its own translation packs), or
  • for its own wording, e.g. the UI Automation control types and row names a screen reader announces.

Behaviour:

  • asked on every read, so an app that changes language at run time is followed;
  • a null or empty answer keeps the library's own value; a resolver that throws is treated as null (these strings are read inside UI Automation calls);
  • a host RowNumber that is not a valid composite format falls back to the library's;
  • Keys does not load the resource set (it would throw outside a running app).

Each TableViewLocalizedStrings property becomes get => Resolve(nameof(X), field); nothing else changes for an app that sets no resolver.

Tested: shipped in Datgel Hub (via our fork) and verified there with unit tests and a UI Automation run. On this branch, the full suite on hosted Windows via vstest.console + the .appxrecipe (ci-build.yml's Run Tests step does not actually invoke vstest, see #449): 383/383, including nine new TableViewLocalizationTests. On our fork's branch, ignoring the resolver turned exactly the five tests that need the host's answer red.

claude and others added 3 commits October 1, 2026 12:36
The automation peers returned English literals for their localized
control types ("table view", "column header", "row header", "cell")
and composed row names as "Row {n}", so a screen reader on a German,
Japanese or Chinese UI announced those in English while every other
TableView string already went through TableViewLocalizedStrings.

Move them to the .resw files in every shipped language, with
FormatRowNumber composing "Row {0}" through the current culture.
The tests swap each resource for a sentinel, so they fail on a peer
that returns a literal even under en-US.
The FormatRowNumber test proved the formatter reads RowNumber, but not that
the three peers call it: restoring their English literals left every test
green. Each new test realizes a row in a loaded TableView, swaps RowNumber
for a sentinel and reads the peer's name.
TableViewLocalization.StringResolver lets an application answer any
TableView string by its resource key - for a language the library does
not ship, or for its own wording of the automation control types and row
names. It is read on every access, so a language change at run time is
followed. A null or empty answer, or a resolver that throws, keeps the
library's own value; a malformed RowNumber format falls back to the
library's. TableViewLocalization.Keys lists the keys without loading the
resources.

This branch has not been deployed

No deployments
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