Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat (i18n) : go back i18n loading json files

Restrayc39cb42601ba
diff --git a/src/lib/translations.ts b/src/lib/translations.ts
index 56e1cb5ff2..dcda99dcb3 100644
--- a/src/lib/translations.ts
+++ b/src/lib/translations.ts
@@ -1,34 +1,26 @@
import i18n from 'sveltekit-i18n';
import lang from './lang.json';
-import * as fs from 'fs';
-
-// Get all translations files
-const loaders = [];
-const translations = {};
-fs.readdir('src/lib/locales/', (err, files) => {
- files.forEach((file) => {
- if (file.endsWith('.json')) {
- const lang_iso = file.replace('.json', '');
-
- loaders.push({
- locale: file.replace('.json', ''),
- key: '',
- /* @vite-ignore */
- loader: async () => (await import(`./locales/${lang_iso}.json`)).default
- });
-
- translations[lang_iso] = { lang };
- }
- });
-});
/** @type {import('sveltekit-i18n').Config} */
-const config = {
+export const config = {
fallbackLocale: 'en',
- translations: translations,
- loaders: loaders
+ translations: {
+ en: { lang },
+ fr: { lang }
+ },
+ loaders: [
+ {
+ locale: 'en',
+ key: '',
+ loader: async () => (await import('./locales/en.json')).default
+ },
+ {
+ locale: 'fr',
+ key: '',
+ loader: async () => (await import('./locales/fr.json')).default
+ }
+ ]
};
export const { t, loading, locales, locale, loadTranslations } = new i18n(config);
-
-loading.subscribe(($loading) => $loading);
+loading.subscribe(($loading) => $loading && console.log('Loading translations...'));