wip
This commit is contained in:
parent
4fce5d8066
commit
9d81d06853
26 changed files with 844 additions and 174 deletions
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue