Skip to content

Commit

Permalink
fix: generate empty crm messages file when no database is available
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviareichl committed Sep 30, 2024
1 parent 50ac400 commit 91b4e07
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/generate-crm-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ const customDictionary: Record<
},
};

async function writeCrmMessages(obj: object, locale: string) {
const content = JSON.stringify(obj, null, "\t");

const folderPath = join(process.cwd(), "messages", locale);
await mkdir(folderPath, { recursive: true });
await writeFile(join(folderPath, `crm.json`), content, {
encoding: "utf-8",
});
}
/**
* Generates CRM messages for the specified locale.
* @param locale - The locale for which to generate CRM messages. Defaults to `defaultLocale` if not provided.
Expand All @@ -132,6 +141,7 @@ async function generate(locale = defaultLocale) {
const isDatabaseEnabled = result.output.NUXT_PUBLIC_DATABASE === "enabled";

if (!isDatabaseEnabled) {
await writeCrmMessages({}, locale);
return false;
}

Expand Down Expand Up @@ -166,13 +176,7 @@ async function generate(locale = defaultLocale) {
obj[key] = typeTranslations;
}

const content = JSON.stringify(obj, null, "\t");

const folderPath = join(process.cwd(), "messages", locale);
await mkdir(folderPath, { recursive: true });
await writeFile(join(folderPath, `crm.json`), content, {
encoding: "utf-8",
});
await writeCrmMessages(obj, locale);

return true;
}
Expand Down

0 comments on commit 91b4e07

Please sign in to comment.