Skip to content

Commit

Permalink
hope locale works :)
Browse files Browse the repository at this point in the history
  • Loading branch information
SecurityQQ committed Jun 23, 2024
1 parent 3272d05 commit 7849fc9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Roboto, Roboto_Mono } from 'next/font/google';
import Head from 'next/head';
import { IntlProvider } from 'next-intl';
import { useEffect, useState } from 'react';
import { Toaster, toast } from 'sonner';
import { Toaster } from 'sonner';

import { ModalProvider } from '../contexts/ModalContext';
import { UserProvider } from '../contexts/UserContext';
Expand All @@ -25,6 +25,8 @@ const ROBOTO_MONO_TTF = Roboto_Mono({
subsets: ['latin'], // Specify the subset(s) you need
});

const allowedLocales = ['en', 'ru'];

function MyApp({ Component, pageProps }: AppProps) {
const [isHashValid, setIsHashValid] = useState(false);
const [locale, setLocale] = useState('en'); // Default to 'en' if not set
Expand Down Expand Up @@ -54,7 +56,8 @@ function MyApp({ Component, pageProps }: AppProps) {
const userParam = params.get('user');
if (userParam) {
const userObj = JSON.parse(decodeURIComponent(userParam));
setLocale(userObj.language_code || 'en');
const userLocale = userObj.language_code || 'en';
setLocale(allowedLocales.includes(userLocale) ? userLocale : 'en');
} else {
setLocale('en');
setErrorCode(`No userParam in params: "${params}"`);
Expand Down Expand Up @@ -100,9 +103,6 @@ function MyApp({ Component, pageProps }: AppProps) {
<UserProvider>
<ModalProvider>
<Toaster />
<p>{`LC: ${locale}`}</p>
<p>{`Error Code: ${errorCode}`}</p>
<p>{`Data: ${window.Telegram.WebApp.initData}`}</p>
<Component {...pageProps} />
</ModalProvider>
</UserProvider>
Expand Down

0 comments on commit 7849fc9

Please sign in to comment.