Skip to content

Commit

Permalink
[i18n] Fix #108
Browse files Browse the repository at this point in the history
  • Loading branch information
sim51 committed Jul 11, 2023
1 parent f4e3c2b commit da3a9e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/preferences/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { parse, stringify } from "../utils/json";
import { i18n } from "../../locales/provider";
import { Preferences } from "./types";

export function getEmptyPreferences(): Preferences {
return {
recentRemoteFiles: [],
layoutsParameters: {},
metrics: {},
locale: "en",
// default is the local detected by i18n
locale: i18n.language,
};
}

export function getCurrentPreferences(): Preferences {
try {
const rawPreferences = localStorage.getItem("preferences");
const preferences = rawPreferences ? parsePreferences(rawPreferences) : null;
return { ...preferences, ...getEmptyPreferences() };
return { ...getEmptyPreferences(), ...preferences };
} catch (e) {
return getEmptyPreferences();
}
Expand Down

0 comments on commit da3a9e3

Please sign in to comment.