let a shortcode fragment speak the reader's language
Three fragments added this session needed a word the author did not write: an untitled :::warn told the reader nothing about being a warning, an untitled panel fell back to whatever the browser calls <details>, and the contents list had no label at all — an accessibility gap as much as an untranslated one. None of them could be fixed, because `t` needs a language and Fragment had none, so those words could only ever have been English on a site that serves Bengali. Fragment gains Lang, captured on each call at parse time — a node renderer never receives the parse context, the same constraint that put pictures and headings on the node. Five phrase keys follow, and a Bengali page now reads সূচিপত্র, সতর্কতা and বিস্তারিত where an English one reads Contents, Warning and Details. The demo's own list.html was the better example of the problem and now shows the answer: a site's own sentences are not in the engine's phrase table, so a template needing its own words branches on the language it was given. That is what theme-contract.md has always told a theme to do, demonstrated rather than asserted, and a case proves the Bengali listing carries no English. Two files crossed the size advisory on the way. render.go shed the contract types to view.go, where state.md already claimed they lived and where the file's own header said they belonged; shortcodes_test.go split to mirror its sources, which the one-file-per-source convention already asked for. Both are pure moves.
This commit is contained in:
@@ -102,6 +102,8 @@ var exampleFeatures = []featureCase{
|
||||
expect: []string{`href="/bn/posts/first-light/" hreflang="bn"`, `hreflang="bn" href="http://localhost:8080/bn/`}},
|
||||
{what: "a Bengali variant localises chrome", path: "/bn/posts/first-light/", code: 200,
|
||||
expect: []string{`lang="bn"`, "প্রথম আলো"}},
|
||||
{what: "a site's own template supplies its own words in each language", path: "/bn/posts/", code: 200,
|
||||
expect: []string{"সাইটের নিজের টেমপ্লেট", "পুরোনো"}, absent: []string{"rendered by the site's own template"}},
|
||||
{what: "a missing variant falls back and says which it served", path: "/bn/posts/only-english/", code: 200,
|
||||
expect: []string{"Only in English", `rel="canonical" href="http://localhost:8080/posts/only-english/"`}},
|
||||
{what: "a bundle that exists only in Bengali is still served", path: "/pages/bengali-only/", code: 200,
|
||||
@@ -143,7 +145,7 @@ var exampleFeatures = []featureCase{
|
||||
expect: []string{`<aside class="admonition warn">`, `<p class="admonition-title">Calibration</p>`, "<em>emphasis</em>"},
|
||||
absent: []string{":::"}},
|
||||
{what: "a table of contents links the page's own headings", path: "/writing/notes-on-water/", code: 200,
|
||||
expect: []string{`<nav class="toc">`, `<a href="#gauge-readings">Readings</a>`, `class="toc-2"`}},
|
||||
expect: []string{`<nav class="toc"`, `<a href="#gauge-readings">Readings</a>`, `class="toc-2"`}},
|
||||
{what: "a merging bundle has one footnote list, numbered straight through", path: "/writing/notes-on-water/", code: 200,
|
||||
expect: []string{`id="fn:1"`, `id="fn:2"`}, absent: []string{"_method-fn:", `class="footnotes"><hr><ol><li id="fn:2"`}},
|
||||
{what: "a heading may declare an anchor that outlives its wording", path: "/writing/notes-on-water/", code: 200,
|
||||
|
||||
Reference in New Issue
Block a user