Skip to content

Commit

Permalink
Merge branch 'main' into deutsch-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmoro authored Nov 4, 2024
2 parents 325fcaa + 0040343 commit c882632
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/modules/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getTime } from '../utils';
import { Translations } from '../types';
import { store } from '../store';

const DOMINANT_LOCALES: Record<string, Locale> = {
export const DOMINANT_LOCALES: Record<string, Locale> = {
en: 'en-US',
es: 'es-ES',
fr: 'fr-FR',
Expand Down
7 changes: 6 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolveLocale } from '../modules/locales';
import { resolveLocale, DOMINANT_LOCALES } from '../modules/locales';
import { Locale, ResolvedQuote } from '../types';

interface Stateful {
Expand Down Expand Up @@ -77,6 +77,11 @@ export class Store {
// Merge: URL > localStorage > defaultState
this.state = { ...defaultState, ...stateFromLocalStorage, ...stateFromUrl };

if (!Object.keys(DOMINANT_LOCALES).includes(this.state.locale.substring(2)) || !this.state.locale.includes('-')) {
this.state.locale = resolveLocale(navigator.language);
this.syncToUrl('locale', this.state.locale);
}

Object.entries(this.state).forEach(([key, value]) => {
if (typeof value === 'boolean') {
updateBooleanSettingStatus(key, value);
Expand Down

0 comments on commit c882632

Please sign in to comment.