Skip to content

Commit

Permalink
Merge pull request #944 from MuckRock/allanlasser/issue936
Browse files Browse the repository at this point in the history
Guard against localStorage access errors
  • Loading branch information
allanlasser authored Dec 4, 2024
2 parents 6eee860 + b787a31 commit e7f7c75
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export const trailingSlash = "always";

export async function load() {
if (browser) {
const lang = localStorage.getItem("dc-locale") || window.navigator.language;
let lang: string;
try {
lang = localStorage.getItem("dc-locale") || window.navigator.language;
} catch {
lang = window.navigator.language;
}

// use en.json for en-US and such
const language = getLanguage(lang, "en");
Expand Down

0 comments on commit e7f7c75

Please sign in to comment.