Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions packages/decap-cms-core/src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,26 @@ export async function getI18nEntry(
if (structure === I18N_STRUCTURE.SINGLE_FILE) {
entryValue = mergeSingleFileValue(await getEntryValue(path), defaultLocale, locales);
} else {
const entryValues = await Promise.all(
const entryValuesResults = await Promise.allSettled(
locales.map(async locale => {
const entryPath = getFilePath(structure, extension, path, slug, locale);
const value = await getEntryValue(entryPath).catch(() => null);
const value = await getEntryValue(entryPath);
return { value, locale };
}),
);

const nonNullValues = entryValues.filter(e => e.value !== null) as {
value: EntryValue;
locale: string;
}[];
const nonNullValues = entryValuesResults
.map(e => (e.status === 'fulfilled' ? e.value : undefined))
.filter((e): e is { value: EntryValue; locale: string } => e !== undefined);

if (nonNullValues.length === 0) {
// mergeValues will throw on an empty list, and show the error messages.
const [error = new Error('No entry values found for any locale')] = entryValuesResults
.map(e => (e.status === 'rejected' ? e.reason : undefined))
.filter(e => e !== undefined);

throw error;
}

entryValue = mergeValues(collection, structure, defaultLocale, nonNullValues);
}
Expand Down
Loading