Skip to content

Commit

Permalink
fix: type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sriramveeraghanta committed Dec 30, 2024
1 parent 0ef2aee commit 0ae0832
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/i18n/src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { createContext, useEffect } from "react";
import { observer } from "mobx-react";
import { TranslationStore } from "./store";
import React, { createContext, useEffect } from "react";
import { Language, languages } from "../config";
import { TranslationStore } from "./store";

// Create the store instance
const translationStore = new TranslationStore();

// Create Context
export const TranslationContext = createContext<TranslationStore>(translationStore);

export const TranslationProvider = observer(({ children }: any) => {
export const TranslationProvider = observer(({ children }: { children: React.ReactNode }) => {
// Handle storage events for cross-tab synchronization
useEffect(() => {
const handleStorageChange = (event: StorageEvent) => {
Expand Down
8 changes: 6 additions & 2 deletions packages/i18n/src/components/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ export class TranslationStore {
}

setLanguage(lng: Language) {
localStorage.setItem("userLanguage", lng);
this.currentLocale = lng;
try {
localStorage.setItem("userLanguage", lng);
this.currentLocale = lng;
} catch (error) {
console.error(error);
}
}

initializeLanguage() {
Expand Down

0 comments on commit 0ae0832

Please sign in to comment.