diff --git a/backend/config.ts b/backend/config.ts new file mode 100644 index 00000000..8fd8ec3f --- /dev/null +++ b/backend/config.ts @@ -0,0 +1,10 @@ +// Can be placed in dotenv but found it redundant + +// Import dotenv from "dotenv"; + +// Load .env file +// Dotenv.config(); + +export const DWENGO_API_BASE = 'https://dwengo.org/backend/api'; + +export const FALLBACK_LANG = 'nl'; diff --git a/backend/src/util/translationHelper.ts b/backend/src/util/translationHelper.ts index 8bc4d7ca..f4443531 100644 --- a/backend/src/util/translationHelper.ts +++ b/backend/src/util/translationHelper.ts @@ -1,6 +1,7 @@ import fs from 'fs'; import path from 'path'; import yaml from 'js-yaml'; +import {FALLBACK_LANG} from "../../config"; export function loadTranslations(language: string): T { try { @@ -12,7 +13,7 @@ export function loadTranslations(language: string): T { `Cannot load translation for ${language}, fallen back to dutch` ); console.error(error); - const fallbackPath = path.join(process.cwd(), '_i18n', 'nl.yml'); + const fallbackPath = path.join(process.cwd(), '_i18n', `${FALLBACK_LANG}.yml`); return yaml.load(fs.readFileSync(fallbackPath, 'utf8')) as T; } }