feat: client side game strings

This commit is contained in:
TrèsAbhi committed 2026-01-13 13:30:09 -06:00
1 parent 2d282a3261
commit f5f3f70e35
7 files changed
+60 -13

No files matched your search

@@ -6,4 +6,27 @@ export class ClientAPI extends AbstractAPI {
protected _avatars() {
return fetchPB("/api/avatars/all.pb", Avatars);
}
protected _gameStrings(): Promise<Record<string, string>> {
throw new Error("Cannot fetch full game strings on client");
}
protected async _groupedGameStrings(
locale: string,
group: string,
prefix: boolean
) {
const response = await fetch(`/api/game-strings/${locale}/${group}.json`);
const json = (await response.json()) as Record<string, string>;
if (!prefix) return json;
const strings: Record<string, string> = {};
for (const key in json) {
strings[`${group}__${key}`] = json[key];
}
return strings;
}
}