Skip to content

Commit

Permalink
catch
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Oct 26, 2024
1 parent 8c3096b commit db0f6a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 7 additions & 3 deletions src/i18nPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit db0f6a2

Please sign in to comment.