Skip to content

Add locale-aware config and localized framework UI defaults#2054

Open
khashashin wants to merge 1 commit intoobservablehq:mainfrom
khashashin:khash/framework-i18n-config-ui
Open

Add locale-aware config and localized framework UI defaults#2054
khashashin wants to merge 1 commit intoobservablehq:mainfrom
khashashin:khash/framework-i18n-config-ui

Conversation

@khashashin
Copy link

This PR adds project- and page-level locale support to Framework and localizes Framework-owned UI defaults.

Changes:

  • add locale, lang, and dir to Framework config
  • add front matter overrides for locale, lang, and dir
  • set root HTML lang / dir during render
  • localize Framework-owned default UI strings, including:
    • home
    • contents / table of contents label
    • untitled page fallback
    • search placeholder
    • sidebar toggle title
    • pager labels
    • default footer text and date formatting
  • update docs and tests

This intentionally keeps translation catalogs and fallback policy out of Framework core; those remain user-land concerns.

This is the Framework-side companion to the Plot locale work, keeping translation catalogs and fallback logic out of Framework core.

@Fil
Copy link
Contributor

Fil commented Mar 26, 2026

Is it global, or is it possible to have a multilingual project? Where some articles would be in English and other in Arabic?

@khashashin
Copy link
Author

@Fil yes, page-level overrides are supported, so you can have a multilingual project where different pages use different language/locale settings.

This is handled via front matter support here: https://github.com/observablehq/framework/pull/2054/changes#diff-77b3519370ff48f6caf7c316f0ece966f2f0871c40e9381d451d2c5b1c76b40fR113

For example:

---
lang: ar
dir: rtl
locale: ar-EG
---

So you can have one page in English and another in Arabic within the same project.

One current limitation is that some config-derived defaults remain project-level unless explicitly overridden, such as the default home label and default TOC label. If that should also become page-localized, that could be a follow-up.

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