Skip to content

fix(build): wire resolved --lang to <html lang> attribute - #472

Merged
dubadub merged 1 commit into
cooklang:mainfrom
sripwoud:470
Aug 31, 2026
Merged

dubadub merged 1 commit into
cooklang:mainfrom
sripwoud:470

Conversation

@sripwoud

Copy link
Copy Markdown
Contributor

cook build --lang fr-FR renders French UI (Recettes, Rechercher) and a /fr/ sitemap, but every page shipped lang="en" on <html> — screen readers picked the wrong voice and search engines got a contradictory language signal.

Fix

templates/base.html now binds <html lang="{{ tr.lang_string() }}"> to the Tr locale already threaded through every template — the same LanguageIdentifier --lang resolves.

Tr::lang_string was #[cfg(feature = "server")]; ungated so the static-site build (no server feature) reads it too. The server build already used it in preferences.html.

Verify

cook build web dist --lang fr-FR
grep -o '<html[^>]*lang="[^"]*"' dist/index.html dist/recipe/Risotto.html
# → lang="fr-FR" on both (was lang="en")

Test plan

  • Added build_lang_arg_sets_html_lang_attribute — asserts lang="fr-FR" on index + recipe pages, absence of hardcoded lang="en"
  • Full suite green (cargo test), cargo clippy clean, cargo fmt

Closes #470

base.html hardcoded lang="en", contradicting French/German content and
the /fr/ sitemap: screen readers picked the wrong voice and search
engines got a conflicting language signal.

Bind <html lang> to the Tr locale already threaded through every
template. Ungate Tr::lang_string so the static-site build (no server
feature) can read it; the server build already used it in
preferences.html.

Closes cooklang#470
@dubadub
dubadub merged commit a3a6971 into cooklang:main Aug 31, 2026
6 checks passed
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.

fix(build): static site hardcodes <html lang="en"> ignoring --lang

2 participants