Skip to content

Negotiate labels over ordered language preferences ($ac:langs)#89

Open
namedgraph wants to merge 5 commits into
masterfrom
fix-lang-negotiation
Open

Negotiate labels over ordered language preferences ($ac:langs)#89
namedgraph wants to merge 5 commits into
masterfrom
fix-lang-negotiation

Conversation

@namedgraph

Copy link
Copy Markdown
Member

Summary

  • Adds $ac:langs — an ordered language preference list (negotiation input), distinct from $ldt:lang which carries the negotiated Content-Language (output). Declared in imports/default.xsl with a product-agnostic default derived from $ldt:lang; consumers override it: XSLTWriterBase passes the request's q-sorted Accept-Language primary subtags (new AC.langs term), and client-side stylesheets (e.g. LinkedDataHub's client.xsl) override it with the browser's navigator.languages.
  • Migrates the per-vocab ac:label/ac:description template pairs (rdfs, dc, dct, skos, sioc, foaf, doap, schema) from single-language $ldt:lang filtering to ordered negotiation: first preferred language with a match wins; fallback is untagged-else-first — always exactly one literal. Fixes labels disappearing (or all languages being emitted by downstream overrides) when the client's top preference has no match.
  • Label selection is no longer capped by the server's supported-language config: a @lt literal wins for an lt-preferring user even though Content-Language negotiates to en/es.
  • Web-Client stays strictly SSR: no ixsl/browser references remain. The ac:uuid() stub drops its SaxonJS branch (client-side implementations override by import precedence; server-side the registered UUID extension function wins as before).

Test plan

  • Verified via LinkedDataHub (AtomGraph/LinkedDataHub companion PR) against Accept-Language: es,lt;q=0.9,en-US;q=0.8,en;q=0.7, lt,en-US;q=0.9,en;q=0.8, and en-US,en;q=0.9: UI chrome and data labels each resolve to the first available preferred language, single literal, SSR/CSR consistent.

🤖 Generated with Claude Code

namedgraph and others added 4 commits July 21, 2026 14:45
- Add dual-sourced $ac:langs param in imports/default.xsl: navigator.languages
  primary subtags client-side (SaxonJS), Accept-Language server-side (SAXON),
  plus $ac:lang for collation/formatting
- Per-vocab ac:label/ac:description templates negotiate over the ordered
  preference list; fallback is untagged-else-first — always a single literal
- Drop per-file $ldt:lang params; $ldt:lang remains the negotiated
  Content-Language carrier, declared in imports/default.xsl
- Add AC.langs term; XSLTWriterBase passes the request's q-sorted
  Accept-Language primary subtags as the ac:langs stylesheet param

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SaxonJS 3 converts the JS array to a sequence of xs:untypedAtomic, so the
JS-style length/index read threw XPTY0004 and $ac:langs evaluated empty —
suppressing every language-tagged property value client-side.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
No SaxonJS/browser knowledge in Web-Client — the ixsl-sourced declaration
moves to LinkedDataHub's client.xsl, which overrides this default by
import precedence. Drops the use-when pair and the ixsl namespace.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ranch

Web-Client is strictly SSR. The stub now just terminates if invoked as
XSLT: server-side the registered UUID extension function overrides it,
client-side stylesheets override it by import precedence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The writer no longer passes the negotiated Content-Language as a
stylesheet param — Accept-Language (ac:langs) is the single input, and
$ac:lang = ($ac:langs[1], 'en')[1] is derived, not passed. <html lang>,
format-date/format-dateTime, sort collations and the TableDataCell
language filters all use $ac:lang; the remaining dual use-when sort
pairs are collapsed. $ldt:lang survives only in commented-out templates.

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