-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: i18n; better bootstrap; redux persist
- Loading branch information
1 parent
239abae
commit e7e7f9f
Showing
21 changed files
with
207 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"action": { | ||
"scan": "Scan" | ||
}, | ||
"welcome": "Welcome to the Lynx-Scanner" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"page": "Welcome to Lynx!", | ||
"description": "Please scan the QR Code for configuration", | ||
"dark": "Dark Mode", | ||
"light": "Light Mode", | ||
"valantine": "Valantine Mode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,47 @@ | ||
import i18n from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import LanguageDetector from 'i18next-browser-languagedetector'; | ||
import enJSon from './i18n/en.json'; | ||
import deJSon from './i18n/de.json'; | ||
import ChainedBackend, { ChainedBackendOptions } from 'i18next-chained-backend'; | ||
import LocalStorageBackend, { | ||
LocalStorageBackendOptions, | ||
} from 'i18next-localstorage-backend'; | ||
import HttpApi, { HttpBackendOptions } from 'i18next-http-backend'; | ||
import axios from 'axios'; | ||
|
||
i18n | ||
.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.init({ | ||
fallbackLng: 'en', | ||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
resources: { | ||
en: { | ||
translation: enJSon, | ||
const axiosInstance = axios.create(); | ||
|
||
export async function i18nFn() { | ||
await i18n | ||
.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.use(ChainedBackend) | ||
.init<ChainedBackendOptions>({ | ||
fallbackLng: 'en', | ||
ns: ['common'], | ||
defaultNS: ['common'], | ||
supportedLngs: ['en', 'de', 'fr'], | ||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
de: { | ||
translation: deJSon, | ||
backend: { | ||
backends: [LocalStorageBackend, HttpApi], | ||
backendOptions: [ | ||
{ | ||
expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days | ||
} as LocalStorageBackendOptions, | ||
{ | ||
loadPath: '/i18n/{{lng}}/{{ns}}.json', | ||
request: async (_, url, __, callback) => { | ||
try { | ||
const { data, status } = await axiosInstance.get(url); | ||
callback(null, { status, data }); | ||
} catch (error) { | ||
callback(error, { status: 500, data: {} }); | ||
} | ||
}, | ||
} as HttpBackendOptions, | ||
], | ||
}, | ||
}, | ||
}); | ||
|
||
export default i18n; | ||
}); | ||
return i18n; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
import './index.scss'; | ||
import { isElectron, setupLogging } from '@shared'; | ||
import { bootstrap } from '@shared/app.tsx'; | ||
|
||
if (isElectron) { | ||
setupLogging().then(() => { | ||
bootstrap(); | ||
}); | ||
} else { | ||
bootstrap(); | ||
import * as Sentry from '@sentry/react'; | ||
import { i18nFn } from '@i18n'; | ||
import ReactDOM from 'react-dom/client'; | ||
import React from 'react'; | ||
import { I18nextProvider } from 'react-i18next'; | ||
import { Provider } from 'react-redux'; | ||
import { persistor, store } from '@store'; | ||
import { App } from './app.tsx'; | ||
import { PersistGate } from 'redux-persist/integration/react'; | ||
|
||
async function main() { | ||
if (isElectron) { | ||
await setupLogging(); | ||
} | ||
|
||
const sentryDSN = import.meta.env.VITE_SENTRY_DSN; | ||
if (sentryDSN) { | ||
Sentry.init({ | ||
dsn: sentryDSN, | ||
integrations: [ | ||
Sentry.browserTracingIntegration(), | ||
Sentry.replayIntegration(), | ||
], | ||
// Performance Monitoring | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled | ||
tracePropagationTargets: ['localhost', /^https:\/\/localhost:\d+\/api/], | ||
// Session Replay | ||
replaysSessionSampleRate: 0.1, | ||
replaysOnErrorSampleRate: 1.0, | ||
}); | ||
} | ||
|
||
const i18n = await i18nFn(); | ||
|
||
const rootElement = document.getElementById('root') as HTMLElement; | ||
const root = ReactDOM.createRoot(rootElement); | ||
root.render( | ||
<React.StrictMode> | ||
<I18nextProvider i18n={i18n}> | ||
<Provider store={store}> | ||
<PersistGate loading={null} persistor={persistor}> | ||
<App /> | ||
</PersistGate> | ||
</Provider> | ||
</I18nextProvider> | ||
</React.StrictMode> | ||
); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { useCallback } from 'react'; | ||
import { fetchConfigUrl } from './thunks'; | ||
import { useAppDispatch } from './types'; | ||
import { useAppDispatch, useAppSelector } from './types'; | ||
import { selectConfigUrl } from '@store/selectors.ts'; | ||
|
||
export function useFetchConfigUrl() { | ||
const dispatch = useAppDispatch(); | ||
return useCallback(() => { | ||
dispatch(fetchConfigUrl()); | ||
}, [dispatch]); | ||
} | ||
|
||
export function useConfigData() { | ||
return useAppSelector(selectConfigUrl); | ||
} |
Oops, something went wrong.