The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Stop pruning published translations when a project has no locales folder (#25535)
Weiko65c6733f7b2e
diff --git a/packages/twenty-docs/developers/extend/apps/translations/overview.mdx b/packages/twenty-docs/developers/extend/apps/translations/overview.mdxindex 60083f9d031..2dfde4d5c7c 100644--- a/packages/twenty-docs/developers/extend/apps/translations/overview.mdx+++ b/packages/twenty-docs/developers/extend/apps/translations/overview.mdx@@ -132,6 +132,12 @@ syncing is enough to see the new text. Front component catalogs are baked intoeach component bundle at build time, so changing one of those still meansre-running `twenty dev:build` (and redeploying).+A project without a `locales/` folder says nothing about translations, so a+sync from it leaves whatever the app already published untouched. To remove+published translations on purpose, keep the folder and delete the locale files+inside it: a `locales/` folder that compiles to no locale is an explicit+declaration, and the sync prunes accordingly.+`Trans` text children may span multiple lines — whitespace is collapsed thesame way JSX collapses it, so both of these extract to the key `Welcome back`:diff --git a/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts b/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.tsindex e9dea5e3c6c..d6e8412c8ca 100644--- a/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts+++ b/packages/twenty-sdk/src/cli/__tests__/apps/minimal-app/__integration__/app-dev/expected-manifest.ts@@ -17,7 +17,6 @@ export const EXPECTED_MANIFEST: Manifest = {},permissionFlags: [],skills: [],- translations: {},agents: [],publicAssets: [],indexes: [],diff --git a/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts b/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.tsindex a0e235d27cb..f70c3997920 100644--- a/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts+++ b/packages/twenty-sdk/src/cli/__tests__/apps/rich-app/__integration__/app-dev/expected-manifest.ts@@ -83,7 +83,6 @@ export const EXPECTED_MANIFEST: Manifest = {},],skills: [],- translations: {},agents: [],application: {applicationVariables: {diff --git a/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts b/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.tsindex 8876577b80e..ec6b470c874 100644--- a/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts+++ b/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts@@ -159,9 +159,34 @@ describe('compileApplicationTranslations', () => {});});- it('returns no locales when there is no locales directory', async () => {+ it('declares nothing when there is no locales directory, so the sync leaves stored translations alone', async () => {const appPath = await mkdtemp(join(tmpdir(), 'twenty-translations-empty-'));+ expect(await compileApplicationTranslations(appPath)).toBeUndefined();+ });++ it('declares zero locales when the locales directory exists but holds none', async () => {+ const appPath = await mkdtemp(+ join(tmpdir(), 'twenty-translations-no-locale-'),+ );++ await mkdir(join(appPath, 'locales'), { recursive: true });++ expect(await compileApplicationTranslations(appPath)).toEqual({});+ });++ it('declares zero locales when only the source locale is present', async () => {+ const appPath = await mkdtemp(+ join(tmpdir(), 'twenty-translations-source-only-'),+ );+ const localesDir = join(appPath, 'locales');++ await mkdir(localesDir, { recursive: true });+ await writeFile(+ join(localesDir, 'en.json'),+ JSON.stringify({ Company: 'Company' }),+ );+expect(await compileApplicationTranslations(appPath)).toEqual({});});});diff --git a/packages/twenty-sdk/src/cli/utilities/translations/compile-application-translations.ts b/packages/twenty-sdk/src/cli/utilities/translations/compile-application-translations.tsindex 308bcb458c5..1b4aa999d56 100644--- a/packages/twenty-sdk/src/cli/utilities/translations/compile-application-translations.ts+++ b/packages/twenty-sdk/src/cli/utilities/translations/compile-application-translations.ts@@ -16,11 +16,11 @@ const isSupportedLocale = (locale: string): locale is AppLocale =>export const compileApplicationTranslations = async (appPath: string,-): Promise<TranslationsManifest> => {+): Promise<TranslationsManifest | undefined> => {const localesDir = path.join(appPath, LOCALES_DIR);if (!(await pathExists(localesDir))) {- return {};+ return undefined;}const localeFiles = (await readdir(localesDir)).filter((entry) =>