From db0f6a2601e7f941da501fda989de7a64ce1c6da Mon Sep 17 00:00:00 2001 From: KishiTheMechanic Date: Sun, 27 Oct 2024 00:18:36 +0200 Subject: [PATCH] catch --- deno.json | 2 +- src/i18nPlugin.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deno.json b/deno.json index b2af80d..4d00cca 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@elsoul/fresh-i18n", - "version": "0.9.3", + "version": "0.9.4", "description": "A simple and flexible internationalization (i18n) plugin for Deno's Fresh framework.", "runtimes": ["deno", "browser"], "exports": "./mod.ts", diff --git a/src/i18nPlugin.ts b/src/i18nPlugin.ts index 0963401..7563a37 100644 --- a/src/i18nPlugin.ts +++ b/src/i18nPlugin.ts @@ -72,9 +72,13 @@ export const i18nPlugin = ( */ const loadTranslation = async (namespace: string) => { const filePath = join(localesDir, lang, `${namespace}.json`) - const data = await readJsonFile(filePath) - if (Object.keys(data).length > 0) { - translationDataSSR[namespace] = data // Only add if data exists + try { + const data = await readJsonFile(filePath) + if (Object.keys(data).length > 0) { + translationDataSSR[namespace] = data // Only add if data exists + } + } catch { + // Ignore if the translation file does not exist or cannot be read } }