Don't reload i18n when cached (#2973)
This commit is contained in:
parent
4c3d3b4675
commit
bd1cf8888f
@ -33,10 +33,19 @@ type Progress = [[number, number, number], Record<string, [number, number, numbe
|
||||
type Strings = Record<string, string>;
|
||||
type StringsMod = Record<string, Strings>;
|
||||
|
||||
async function retrieveJson (url: string): Promise<any> {
|
||||
const response = await fetch(`locales/${url}`);
|
||||
const cache = new Map<string, unknown>();
|
||||
|
||||
return response.json();
|
||||
async function retrieveJson (url: string): Promise<any> {
|
||||
if (cache.has(url)) {
|
||||
return cache.get(url);
|
||||
}
|
||||
|
||||
const response = await fetch(`locales/${url}`);
|
||||
const json = await response.json() as unknown;
|
||||
|
||||
cache.set(url, json);
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
async function retrieveEnglish (): Promise<StringsMod> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user