Skip to content

Commit 904a760

Browse files
committed
fix: use fs.existsSync instead of loadMessages to reduce serverless bundle size
1 parent 062036b commit 904a760

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/i18n/translationStatus.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { DEFAULT_LOCALE } from "@/lib/constants"
1+
import { existsSync } from "fs"
2+
import { join } from "path"
23

3-
import { loadMessages } from "@/lib/i18n/loadMessages"
4+
import { DEFAULT_LOCALE } from "@/lib/constants"
45

56
/**
67
* Determine whether all required i18n namespaces exist for a given locale.
@@ -12,8 +13,9 @@ export async function areNamespacesTranslated(
1213
): Promise<boolean> {
1314
if (locale === DEFAULT_LOCALE) return true
1415

15-
const localeMessages = await loadMessages(locale)
16+
const intlPath = join(process.cwd(), "src/intl")
17+
1618
return namespaces.every((ns) =>
17-
Object.prototype.hasOwnProperty.call(localeMessages, ns)
19+
existsSync(join(intlPath, locale, `${ns}.json`))
1820
)
1921
}

0 commit comments

Comments
 (0)