mirror of
https://github.com/luanslimadev/Wand-Enhancer.git
synced 2026-08-28 17:01:05 +00:00
a0b3968d33
Reorganize the panel around product capabilities and integrate the remote i18n feature from origin/master into the new structure. - Restructure src into capability features (app, trainer, library, remote-session, appearance, shared); move the bridge to bridge/src. - Add lingui-based UI localization and wrap remaining user-facing strings (Trans / msg macros); fix the 'END В·' mojibake. - Port WeMod cheat-metadata i18n: capture the access token from the snapshot's renderer in the bridge and fetch localized trainer_meta in remote-session.i18n; guarantee snapshot sync on token failure. - Wire vitest to the app's lingui/preact pipeline (mergeConfig).
27 lines
741 B
TypeScript
27 lines
741 B
TypeScript
import { i18n } from '@lingui/core';
|
|
|
|
export const DEFAULT_LOCALE = 'en';
|
|
|
|
type CatalogModule = {
|
|
default?: { messages: Record<string, string> };
|
|
messages?: Record<string, string>;
|
|
};
|
|
|
|
const catalogs = import.meta.glob<CatalogModule>('../locales/*/messages.js');
|
|
|
|
export async function activateLocale(locale: string): Promise<void> {
|
|
const loadCatalog = catalogs[`../locales/${locale}/messages.js`];
|
|
if (!loadCatalog) {
|
|
throw new Error(`Locale catalog not found: ${locale}`);
|
|
}
|
|
|
|
const catalog = await loadCatalog();
|
|
const messages = catalog.messages ?? catalog.default?.messages;
|
|
if (!messages) {
|
|
throw new Error(`Locale catalog is invalid: ${locale}`);
|
|
}
|
|
|
|
i18n.load(locale, messages);
|
|
i18n.activate(locale);
|
|
}
|