CloudCannon / pagefind

Static low-bandwidth search at scale
https://pagefind.app
MIT License
3.22k stars 97 forks source link

Pagefind UI: Option to set UI language #593

Open marchof opened 3 months ago

marchof commented 3 months ago

First of thanks for providing this fantastic tool! We use it for an internal knowledge base project. Integration into the publishing process via GitHub actions just works and the usability for the users is great.

We have a minor enhancement request (not a blocker at all for us):

Scenario

The project hast content in different languages which is all indexed in english (force_language). So you can easily search across all languages (or use filters to select pages of a specific language). Beside the actual content rendered pages have several site tools (including search). The UI of those tools is always in english (regardless of the page content).

Current Behavior

The pagefind UI automatically adjust its UI language to the language of the page as given in the HTML header.

Enhancement Request

Specify a configuration option to set the UI language to a specific language

Possible Workarounds

bglw commented 2 months ago

Nice suggestion! It's an easy addition so I'll make sure to sweep it in whenever the next release is going out :)

bglw commented 2 months ago

Another workaround for now if it helps:

Pagefind doesn't watch this attribute at all, so you can quickly change it out while initializing the PagefindUI:

let actualLang = document.documentElement.lang;
document.documentElement.lang = "en";
new PagefindUI({ /* ...options */ });
document.documentElement.lang = actualLang;