mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: localize game assets
This commit is contained in:
1 parent
d8459d373c
commit
ef9778ea96
90 files changed
+336
-251
No files matched your search
@@ -1,12 +1,12 @@
|
||||
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@blitzkit/core/src/blitzkit';
|
||||
import { merge } from 'lodash-es';
|
||||
import type en from '../strings/en.json';
|
||||
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from './supportedLocales';
|
||||
|
||||
export type TranslationTree = { [key: string]: TranslationNode };
|
||||
|
||||
export type TranslationNode = string | TranslationTree;
|
||||
|
||||
const files = import.meta.glob('../../lang/*.json', { eager: true });
|
||||
const files = import.meta.glob('../strings/*.json', { eager: true });
|
||||
export const localizedStrings: Record<string, typeof en> = {};
|
||||
|
||||
function nuke(object: TranslationTree) {
|
||||
@@ -21,8 +21,8 @@ function nuke(object: TranslationTree) {
|
||||
}
|
||||
|
||||
SUPPORTED_LOCALES.forEach((locale) => {
|
||||
const defaultStrings = files[`../../lang/${DEFAULT_LOCALE}.json`];
|
||||
const strings = files[`../../lang/${locale}.json`];
|
||||
const defaultStrings = files[`../strings/${DEFAULT_LOCALE}.json`];
|
||||
const strings = files[`../strings/${locale}.json`];
|
||||
const mergedStrings = merge({}, defaultStrings, strings);
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user