mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 12:24:55 +01:00
Compare commits
4
Commits
7cb3df3da2
...
03b8ffe7e5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03b8ffe7e5 | ||
|
|
c70fae8162 | ||
|
|
d79e0ddb5d | ||
|
|
448e36492d |
No files matched your search
@@ -112,6 +112,9 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
const { existsSync } = await import("fs");
|
||||||
|
const { readFile, writeFile, mkdir } = await import("fs/promises");
|
||||||
|
|
||||||
console.log("Initializing virtual file system...");
|
console.log("Initializing virtual file system...");
|
||||||
|
|
||||||
const path = await import("node:path");
|
const path = await import("node:path");
|
||||||
@@ -160,31 +163,39 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
|
|||||||
|
|
||||||
console.log("Fetching game localizations...");
|
console.log("Fetching game localizations...");
|
||||||
|
|
||||||
if (import.meta.env.DEV) {
|
|
||||||
locales.supported = [locales.supported[0]];
|
|
||||||
}
|
|
||||||
|
|
||||||
let fetchedLocalizations = 0;
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
locales.supported.map(async (locale) => {
|
locales.supported.map(async ({ locale }) => {
|
||||||
const blitzLocale = locale.variant_blitz_cdn ?? locale.locale;
|
const root = "../../temp/game-strings";
|
||||||
const cache = await fetch(
|
const cachePath = `${root}/${locale}.json`;
|
||||||
|
|
||||||
|
if (existsSync(cachePath)) {
|
||||||
|
console.log(` Cache hit for ${locale}`);
|
||||||
|
|
||||||
|
const content = await readFile(cachePath, "utf-8");
|
||||||
|
this.stringsI18n[locale] = JSON.parse(content) as BlitzStrings;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(` Cache miss for ${locale} (this will take a while...)`);
|
||||||
|
|
||||||
|
const blitzLocale = locales.supported.find(
|
||||||
|
(l) => l.locale === locale,
|
||||||
|
)!.variant_blitz_local;
|
||||||
|
const networkStrings = (await fetch(
|
||||||
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`,
|
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`,
|
||||||
)
|
)
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((string) => parseYaml(string) as BlitzStrings);
|
.then(parseYaml)) as BlitzStrings;
|
||||||
const preInstalled = await this.vfs.yaml<BlitzStrings>(
|
const localStrings = await this.vfs.yaml<BlitzStrings>(
|
||||||
`Data/Strings/${blitzLocale}.yaml`,
|
`Data/Strings/${blitzLocale}.yaml`,
|
||||||
);
|
);
|
||||||
|
const combined = { ...networkStrings, ...localStrings };
|
||||||
|
|
||||||
this.stringsI18n[locale.locale] = {
|
await mkdir(root, { recursive: true });
|
||||||
...cache,
|
await writeFile(cachePath, JSON.stringify(combined));
|
||||||
...preInstalled,
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(
|
this.stringsI18n[locale] = combined;
|
||||||
`Fetched localizations for ${locale} (${++fetchedLocalizations}/${locales.supported.length})`,
|
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
img {
|
img {
|
||||||
width: 1em;
|
width: 1em;
|
||||||
height: 1em;
|
height: 1em;
|
||||||
|
|
||||||
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-light-text="true"] {
|
&[data-light-text="true"] {
|
||||||
|
|||||||
Reference in new issue
Block a user