mirror of
https://github.com/rajnandan1/kener.git
synced 2026-06-23 04:10:22 +00:00
bug fix
This commit is contained in:
@@ -164,6 +164,9 @@ COPY --chown=node:node --from=builder /app/src/lib/server/db/seedMonitorData.ts
|
||||
COPY --chown=node:node --from=builder /app/src/lib/server/db/seedPagesData.ts ./src/lib/server/db/seedPagesData.ts
|
||||
COPY --chown=node:node --from=builder /app/src/lib/server/templates/general ./src/lib/server/templates/general
|
||||
|
||||
# Locale JSON files (read at runtime by server-side i18n)
|
||||
COPY --chown=node:node --from=builder /app/src/lib/locales ./src/lib/locales
|
||||
|
||||
# Build output (SvelteKit client/server + esbuild main.js) — changes most often
|
||||
COPY --chown=node:node --from=builder /app/build ./build
|
||||
|
||||
|
||||
+17
-5
@@ -1,12 +1,24 @@
|
||||
/**
|
||||
* Server-side i18n helper for translating strings outside of Svelte components.
|
||||
* Reads locale JSON files eagerly via Vite's import.meta.glob.
|
||||
* Reads locale JSON files from disk using Node.js fs (compatible with both
|
||||
* Vite dev server and esbuild production bundle).
|
||||
*/
|
||||
|
||||
const localeModules = import.meta.glob("/src/lib/locales/*.json", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
}) as Record<string, { name: string; mappings: Record<string, string> }>;
|
||||
import { readdirSync, readFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
const localeModules: Record<string, { name: string; mappings: Record<string, string> }> = {};
|
||||
|
||||
const localesDir = join(process.cwd(), "src", "lib", "locales");
|
||||
try {
|
||||
const files = readdirSync(localesDir).filter((f) => f.endsWith(".json"));
|
||||
for (const file of files) {
|
||||
const key = `/src/lib/locales/${file}`;
|
||||
localeModules[key] = JSON.parse(readFileSync(join(localesDir, file), "utf-8"));
|
||||
}
|
||||
} catch {
|
||||
console.warn("Could not load locale files from", localesDir);
|
||||
}
|
||||
|
||||
const localeCache = new Map<string, Record<string, string>>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user