1
0
Fork 0

fix(gui): load server strings into correct namespaces

This commit is contained in:
Sean Sube 2023-03-04 23:15:34 -06:00
parent 539d0febce
commit a0dfc060da
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 14 additions and 5 deletions

View File

@ -223,7 +223,9 @@ export interface ApiClient {
/**
* Load extra strings from the server.
*/
strings(): Promise<Record<string, unknown>>;
strings(): Promise<Record<string, {
translation: Record<string, string>;
}>>;
/**
* Start a txt2img pipeline.
@ -394,10 +396,14 @@ export function makeClient(root: string, f = fetch): ApiClient {
const res = await f(path);
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 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> {
const url = makeImageURL(root, 'img2img', params);

View File

@ -65,8 +65,11 @@ export async function main() {
});
const strings = await client.strings();
for (const [lang, data] of Object.entries(strings)) {
i18n.addResourceBundle(lang, 'translation', data, true);
for (const [lang, translation] of Object.entries(strings)) {
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