Refactor join page and update packages

The join page's redirect functionality has been replaced with permanentRedirect. Adjustments were also made for handling conditional authentication and user account verification. Package upgrades were performed and the i18n client now checks if an instance is already initialized. The process tends to deliver performance benefits and enhancing the code readability.
This commit is contained in:
giancarlo
2024-04-14 13:48:50 +08:00
parent fd890ea09d
commit 91bee99857
13 changed files with 446 additions and 422 deletions

View File

@@ -3,6 +3,8 @@ import LanguageDetector from 'i18next-browser-languagedetector';
import resourcesToBackend from 'i18next-resources-to-backend';
import { initReactI18next } from 'react-i18next';
let clientInstance: i18n | null = null;
/**
* Initialize the i18n instance on the client.
* @param settings - the i18n settings
@@ -12,6 +14,10 @@ export function initializeI18nClient(
settings: InitOptions,
resolver: (lang: string, namespace: string) => Promise<object>,
): Promise<i18n> {
if (clientInstance?.isInitialized) {
return Promise.resolve(clientInstance);
}
return new Promise<i18n>((resolve, reject) => {
void i18next
.use(initReactI18next)
@@ -40,7 +46,9 @@ export function initializeI18nClient(
return reject(err);
}
resolve(i18next);
clientInstance = i18next;
resolve(clientInstance);
},
);
});

View File

@@ -14,6 +14,10 @@ export async function initializeServerI18n(
) {
const i18nInstance = createInstance();
if (i18nInstance.isInitialized) {
return i18nInstance;
}
await i18nInstance
.use(initReactI18next)
.use(