This commit is contained in:
syuilo
2020-12-26 10:01:32 +09:00
parent 4fce5d8066
commit 9d81d06853
26 changed files with 844 additions and 174 deletions

View File

@@ -1,15 +0,0 @@
import { clientDb, clear, bulkSet } from '../db';
import { deepEntries, delimitEntry } from 'deep-entries';
export function setI18nContexts(lang: string, version: string, cleardb = false) {
return Promise.all([
cleardb ? clear(clientDb.i18n) : Promise.resolve(),
fetch(`/assets/locales/${lang}.${version}.json`)
])
.then(([, response]) => response.json())
.then(locale => {
const flatLocaleEntries = deepEntries(locale, delimitEntry) as [string, string][];
bulkSet(flatLocaleEntries, clientDb.i18n);
return Object.fromEntries(flatLocaleEntries);
});
}