fix(gui): load server strings into correct namespaces
This commit is contained in:
parent
539d0febce
commit
a0dfc060da
|
@ -223,7 +223,9 @@ export interface ApiClient {
|
||||||
/**
|
/**
|
||||||
* Load extra strings from the server.
|
* Load extra strings from the server.
|
||||||
*/
|
*/
|
||||||
strings(): Promise<Record<string, unknown>>;
|
strings(): Promise<Record<string, {
|
||||||
|
translation: Record<string, string>;
|
||||||
|
}>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a txt2img pipeline.
|
* Start a txt2img pipeline.
|
||||||
|
@ -394,10 +396,14 @@ export function makeClient(root: string, f = fetch): ApiClient {
|
||||||
const res = await f(path);
|
const res = await f(path);
|
||||||
return await res.json() as Array<string>;
|
return await res.json() as Array<string>;
|
||||||
},
|
},
|
||||||
async strings(): Promise<Record<string, unknown>> {
|
async strings(): Promise<Record<string, {
|
||||||
|
translation: Record<string, string>;
|
||||||
|
}>> {
|
||||||
const path = makeApiUrl(root, 'settings', 'strings');
|
const path = makeApiUrl(root, 'settings', 'strings');
|
||||||
const res = await f(path);
|
const res = await f(path);
|
||||||
return await res.json() as Record<string, unknown>;
|
return await res.json() as Record<string, {
|
||||||
|
translation: Record<string, string>;
|
||||||
|
}>;
|
||||||
},
|
},
|
||||||
async img2img(model: ModelParams, params: Img2ImgParams, upscale?: UpscaleParams): Promise<ImageResponse> {
|
async img2img(model: ModelParams, params: Img2ImgParams, upscale?: UpscaleParams): Promise<ImageResponse> {
|
||||||
const url = makeImageURL(root, 'img2img', params);
|
const url = makeImageURL(root, 'img2img', params);
|
||||||
|
|
|
@ -65,8 +65,11 @@ export async function main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const strings = await client.strings();
|
const strings = await client.strings();
|
||||||
for (const [lang, data] of Object.entries(strings)) {
|
for (const [lang, translation] of Object.entries(strings)) {
|
||||||
i18n.addResourceBundle(lang, 'translation', data, true);
|
console.log('adding strings', lang, translation);
|
||||||
|
for (const [namespace, data] of Object.entries(translation)) {
|
||||||
|
i18n.addResourceBundle(lang, namespace, data, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prep zustand with a slice for each tab, using local storage
|
// prep zustand with a slice for each tab, using local storage
|
||||||
|
|
Loading…
Reference in New Issue