mirror of
https://github.com/misskey-dev/misskey
synced 2024-12-26 04:28:28 +09:00
3963ed8ff7
* wip * tabun ok * better msg * oops * fix lint * Update gulpfile.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * Update src/client/scripts/set-i18n-contexts.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * refactor Co-authored-by: acid-chicken <root@acid-chicken.com> * ✨ * wip * fix lint * たぶんおk * fix flush * Translate Notification * remove console.log * fix * add notifications * remove san * wip * ok * ✌️ * Update src/prelude/array.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * wip * i18n refactor * Update init.ts * ✌️ Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
19 lines
703 B
TypeScript
19 lines
703 B
TypeScript
import VueI18n from 'vue-i18n';
|
|
import { clientDb, clear, bulkSet } from '../db';
|
|
import { deepEntries, delimitEntry } from 'deep-entries';
|
|
import { fromEntries } from '../../prelude/array';
|
|
|
|
export function setI18nContexts(lang: string, version: string, i18n: VueI18n, 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);
|
|
i18n.locale = lang;
|
|
i18n.setLocaleMessage(lang, fromEntries(flatLocaleEntries));
|
|
});
|
|
}
|