fix(webui): localize the component gallery
This commit is contained in:
1 parent
282839cc65
commit
ae5cb64e9e
54 files changed
+11120
-719
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import i18n, { initializeI18n } from "@/i18n";
|
||||
import { supportedLocales } from "@/i18n/config";
|
||||
|
||||
const bundles = import.meta.glob<{ default: Record<string, unknown> }>(
|
||||
"./locales/*/*.json",
|
||||
{ eager: true },
|
||||
);
|
||||
|
||||
// Gallery copy is a development-only namespace; the application keeps its own bundles.
|
||||
export async function initializeGalleryI18n(): Promise<void> {
|
||||
await initializeI18n();
|
||||
for (const { code } of supportedLocales) {
|
||||
for (const [path, bundle] of Object.entries(bundles)) {
|
||||
const match = path.match(/^\.\/locales\/([^/]+)\/([^/]+)\.json$/);
|
||||
if (match?.[2] === code) {
|
||||
i18n.addResourceBundle(code, "gallery", { [match[1]]: bundle.default }, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function useGalleryTranslation() {
|
||||
return useTranslation("gallery");
|
||||
}
|
||||
Reference in new issue
Block a user