summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiDeoo2024-11-01 13:31:03 +0100
committerGitHub2024-11-01 13:31:03 +0100
commitbf42300e76241a2df888dc458c59a7478a8b2d61 (patch)
tree20f446139d1692aa429ed1139319c648376f5c73
parent91e1dd731a06657890a68b2d474199455df2756f (diff)
downloadIT.starlight-bf42300e76241a2df888dc458c59a7478a8b2d61.tar.gz
IT.starlight-bf42300e76241a2df888dc458c59a7478a8b2d61.tar.bz2
IT.starlight-bf42300e76241a2df888dc458c59a7478a8b2d61.zip
Stop silencing i18n content collection related errors (#2546)
-rw-r--r--.changeset/big-ducks-rhyme.md5
-rw-r--r--packages/starlight/utils/translations.ts12
2 files changed, 9 insertions, 8 deletions
diff --git a/.changeset/big-ducks-rhyme.md b/.changeset/big-ducks-rhyme.md
new file mode 100644
index 00000000..f73e10c0
--- /dev/null
+++ b/.changeset/big-ducks-rhyme.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/starlight': patch
+---
+
+Fixes an issue where i18n content collection related errors, e.g. malformed JSON or YAML, would not be reported.
diff --git a/packages/starlight/utils/translations.ts b/packages/starlight/utils/translations.ts
index 3c9827c9..468cd724 100644
--- a/packages/starlight/utils/translations.ts
+++ b/packages/starlight/utils/translations.ts
@@ -14,17 +14,13 @@ export type UserI18nKeys = keyof RemoveIndexSignature<UserI18nSchema>;
/** Get all translation data from the i18n collection, keyed by `id`, which matches locale. */
async function loadTranslations() {
- let userTranslations: Record<string, UserI18nSchema> = {};
// Briefly override `console.warn()` to silence logging when a project has no i18n collection.
const warn = console.warn;
console.warn = () => {};
- try {
- // Load the user’s i18n collection and ignore the error if it doesn’t exist.
- userTranslations = Object.fromEntries(
- // @ts-ignore — may be an error in projects without an i18n collection
- (await getCollection('i18n')).map(({ id, data }) => [id, data] as const)
- );
- } catch {}
+ const userTranslations: Record<string, UserI18nSchema> = Object.fromEntries(
+ // @ts-ignore — may be a type error in projects without an i18n collection
+ (await getCollection('i18n')).map(({ id, data }) => [id, data] as const)
+ );
// Restore the original warn implementation.
console.warn = warn;
return userTranslations;