feat: language in header

This commit is contained in:
Julien Calixte
2026-03-01 18:58:55 +01:00
parent 557aff2329
commit 7ca922e0a6
3 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
export const displayLanguage = (langCode?: string): string | null => {
if (!langCode) {
return null
}
try {
const locale = navigator.language ?? langCode
const display = new Intl.DisplayNames([locale], {
type: "language",
})
return display.of(langCode) ?? null
} catch (err) {
console.warn("error", err)
return null
}
}