From c7c1cabc602641a2c55dd86530c04c0447330f2c Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Tue, 11 Jun 2024 16:40:19 -0700 Subject: [PATCH 1/2] Check if running in a static generation context --- plugins/fetch-translations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fetch-translations.js b/plugins/fetch-translations.js index 685df33..f8bd233 100644 --- a/plugins/fetch-translations.js +++ b/plugins/fetch-translations.js @@ -9,7 +9,7 @@ export default async function({ i18n, $craft, $config }, localeCode) { // If JSON files are generated and this is being invoked on the client, use // those JSON files. - if ($config.cloak.i18n.generateJson && process.client) { + if ($config.cloak.i18n.generateJson && process.client && process.static) { try { const generateDir = $config._app.basePath || "/"; const response = await fetch(`${generateDir}i18n/${localeCode}.json`); From bf69240a296e67b7588da3f45642dd847c0eb436 Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Tue, 11 Jun 2024 16:40:41 -0700 Subject: [PATCH 2/2] Add better error log hint --- plugins/fetch-translations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/fetch-translations.js b/plugins/fetch-translations.js index f8bd233..b9ac5b6 100644 --- a/plugins/fetch-translations.js +++ b/plugins/fetch-translations.js @@ -18,7 +18,7 @@ export default async function({ i18n, $craft, $config }, localeCode) { // If not found, fallback to the CMS } catch (e) { - console.error(e); + console.error("Couldn't load translations", e); } }