The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat localized legal links (#25991)
Bulat1f3e5133b4b1
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/components/FooterNote.tsx b/packages/twenty-front/src/modules/auth/sign-in-up/components/FooterNote.tsxindex 94bd5d1677b..2ce1100b80c 100644--- a/packages/twenty-front/src/modules/auth/sign-in-up/components/FooterNote.tsx+++ b/packages/twenty-front/src/modules/auth/sign-in-up/components/FooterNote.tsx@@ -1,7 +1,8 @@import { styled } from '@linaria/react';-import { Trans } from '@lingui/react/macro';+import { Trans, useLingui } from '@lingui/react/macro';import { useWorkspaceBypass } from '@/auth/sign-in-up/hooks/useWorkspaceBypass';+import { getTwentyWebsiteUrl } from '@/auth/utils/getTwentyWebsiteUrl';import { useIsCurrentLocationOnAWorkspace } from '@/domain-manager/hooks/useIsCurrentLocationOnAWorkspace';import { ONBOARDING_CONTENT_BLOCK_WIDTH } from '@/onboarding/constants/OnboardingContentBlockWidth';import { themeCssVariables } from 'twenty-ui/theme-constants';@@ -64,6 +65,7 @@ export const FooterNote = ({secondaryAgreement = 'privacyPolicy',}: FooterNoteProps) => {const { isOnAWorkspace } = useIsCurrentLocationOnAWorkspace();+ const { i18n } = useLingui();const { shouldOfferBypass, shouldUseBypass, enableBypass } =useWorkspaceBypass();@@ -73,7 +75,7 @@ export const FooterNote = ({<StyledCopyContainer><Trans>By using Twenty, you agree to the</Trans>{' '}<a- href="https://twenty.com/legal/terms"+ href={getTwentyWebsiteUrl(i18n.locale, 'terms')}target="_blank"rel="noopener noreferrer">@@ -90,7 +92,7 @@ export const FooterNote = ({</a>) : (<a- href="https://twenty.com/legal/privacy"+ href={getTwentyWebsiteUrl(i18n.locale, 'privacy-policy')}target="_blank"rel="noopener noreferrer">@@ -113,7 +115,7 @@ export const FooterNote = ({</>)}<a- href="https://twenty.com/legal/privacy"+ href={getTwentyWebsiteUrl(i18n.locale, 'privacy-policy')}target="_blank"rel="noopener noreferrer">@@ -121,7 +123,7 @@ export const FooterNote = ({</a><StyledSeparator>•</StyledSeparator><a- href="https://twenty.com/legal/terms"+ href={getTwentyWebsiteUrl(i18n.locale, 'terms')}target="_blank"rel="noopener noreferrer">diff --git a/packages/twenty-front/src/modules/auth/utils/__tests__/getTwentyWebsiteUrl.test.ts b/packages/twenty-front/src/modules/auth/utils/__tests__/getTwentyWebsiteUrl.test.tsnew file mode 100644index 00000000000..2a3e32fbdd6--- /dev/null+++ b/packages/twenty-front/src/modules/auth/utils/__tests__/getTwentyWebsiteUrl.test.ts@@ -0,0 +1,35 @@+import { getTwentyWebsiteUrl } from '@/auth/utils/getTwentyWebsiteUrl';++describe('getTwentyWebsiteUrl', () => {+ it.each([+ ['ar-SA', 'ar'],+ ['cs-CZ', 'cs'],+ ['de-DE', 'de'],+ ['es-ES', 'es'],+ ['fr-FR', 'fr'],+ ['it-IT', 'it'],+ ['ja-JP', 'ja'],+ ['ko-KR', 'ko'],+ ['pt-BR', 'pt'],+ ['pt-PT', 'pt'],+ ['ro-RO', 'ro'],+ ['ru-RU', 'ru'],+ ['tr-TR', 'tr'],+ ['zh-CN', 'zh'],+ ['zh-TW', 'zh'],+ ])('uses the localized Twenty website path for %s', (locale, language) => {+ expect(getTwentyWebsiteUrl(locale, 'privacy-policy')).toBe(+ `https://twenty.com/${language}/privacy-policy`,+ );+ });++ it('uses the default Twenty website path for English', () => {+ expect(getTwentyWebsiteUrl('en', 'terms')).toBe('https://twenty.com/terms');+ });++ it('uses English for the pseudo locale', () => {+ expect(getTwentyWebsiteUrl('pseudo-en', 'terms')).toBe(+ 'https://twenty.com/terms',+ );+ });+});diff --git a/packages/twenty-front/src/modules/auth/utils/getTwentyWebsiteUrl.ts b/packages/twenty-front/src/modules/auth/utils/getTwentyWebsiteUrl.tsnew file mode 100644index 00000000000..f950fd5f7e8--- /dev/null+++ b/packages/twenty-front/src/modules/auth/utils/getTwentyWebsiteUrl.ts@@ -0,0 +1,30 @@+import {+ DOCUMENTATION_DEFAULT_LANGUAGE,+ DOCUMENTATION_SUPPORTED_LANGUAGES,+ type DocumentationSupportedLanguage,+} from 'twenty-shared/constants';++const TWENTY_WEBSITE_HREF = 'https://twenty.com';++type TwentyWebsitePage = 'terms' | 'privacy-policy';++export const getTwentyWebsiteUrl = (+ locale: string,+ page: TwentyWebsitePage,+): string => {+ const language = new Intl.Locale(locale).language;++ const isLocalizedWebsitePath =+ language !== DOCUMENTATION_DEFAULT_LANGUAGE &&+ DOCUMENTATION_SUPPORTED_LANGUAGES.some(+ (supportedLanguage: DocumentationSupportedLanguage) =>+ supportedLanguage === language,+ );++ const url = new URL(+ isLocalizedWebsitePath ? `/${language}/${page}` : `/${page}`,+ TWENTY_WEBSITE_HREF,+ );++ return url.toString();+};