Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const OrganizationListPageList = (props: { onCreateOrganizationClick: () => void
/>
<Header.Subtitle
localizationKey={localizationKeys('organizationList.subtitle', {
applicationName: environment.displayConfig.applicationName,
applicationName: environment.displayConfig.applicationName || '',
})}
/>
</Header.Root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const LeaveOrganizationForm = (props: LeaveOrganizationFormProps) => {
messageLine2={localizationKeys('organizationProfile.profilePage.dangerSection.leaveOrganization.messageLine2')}
actionDescription={localizationKeys(
'organizationProfile.profilePage.dangerSection.leaveOrganization.actionDescription',
{ organizationName: organization?.name },
{ organizationName: organization?.name || '' },
)}
submitLabel={localizationKeys('organizationProfile.profilePage.dangerSection.leaveOrganization.title')}
successMessage={localizationKeys(
Expand Down Expand Up @@ -85,7 +85,7 @@ export const DeleteOrganizationForm = (props: DeleteOrganizationFormProps) => {
messageLine2={localizationKeys('organizationProfile.profilePage.dangerSection.deleteOrganization.messageLine2')}
actionDescription={localizationKeys(
'organizationProfile.profilePage.dangerSection.deleteOrganization.actionDescription',
{ organizationName: organization?.name },
{ organizationName: organization?.name || '' },
)}
submitLabel={localizationKeys('organizationProfile.profilePage.dangerSection.deleteOrganization.title')}
successMessage={localizationKeys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const RemoveDomainForm = (props: RemoveDomainFormProps) => {
<RemoveResourceForm
title={localizationKeys('organizationProfile.removeDomainPage.title')}
messageLine1={localizationKeys('organizationProfile.removeDomainPage.messageLine1', {
domain: ref.current?.name,
domain: ref.current?.name || '',
})}
messageLine2={localizationKeys('organizationProfile.removeDomainPage.messageLine2')}
deleteResource={() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ export const VerifiedDomainForm = withCardStateProvider((props: VerifiedDomainFo
}, [domain?.id]);

const title = localizationKeys('organizationProfile.verifiedDomainPage.title', {
domain: domain?.name,
domain: domain?.name || '',
});
const subtitle = localizationKeys('organizationProfile.verifiedDomainPage.subtitle', {
domain: domain?.name,
domain: domain?.name || '',
});

const calloutLabel = useCalloutLabel(domain, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const VerifyDomainForm = withCardStateProvider((props: VerifyDomainFormPr
const subtitleVerificationCodeScreen = localizationKeys(
'organizationProfile.verifyDomainPage.subtitleVerificationCodeScreen',
{
emailAddress: affiliationEmailAddressRef.current,
emailAddress: affiliationEmailAddressRef.current || '',
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const RemoveScreen = ({
})}
messageLine2={localizationKeys('userProfile.billingPage.paymentSourcesSection.removeResource.messageLine2')}
successMessage={localizationKeys('userProfile.billingPage.paymentSourcesSection.removeResource.successMessage', {
emailAddress: ref.current,
paymentSource: ref.current,
})}
deleteResource={removePaymentSource}
onSuccess={close}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ function Card(props: CardProps) {
<Text
elementDescriptor={descriptors.pricingTableCardFooterNotice}
variant={isCompact ? 'buttonSmall' : 'buttonLarge'}
localizationKey={localizationKeys('badge__startsAt', { date: subscription?.periodStart })}
localizationKey={localizationKeys('badge__startsAt', {
// TODO: Is it correct to be undefined ?
date: subscription?.periodStart || '',
})}
colorScheme='secondary'
sx={t => ({
paddingBlock: t.space.$1x5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SignInFactorOneAlternativePhoneCodeCard = (props: SignInFactorOneAl
<SignInFactorOneAlternativeChannelCodeForm
{...props}
cardTitle={localizationKeys('signIn.alternativePhoneCodeProvider.title', {
provider: getAlternativePhoneCodeProviderData(props.factor.channel)?.name,
provider: getAlternativePhoneCodeProviderData(props.factor.channel)?.name || '',
})}
cardSubtitle={localizationKeys('signIn.alternativePhoneCodeProvider.subtitle')}
inputLabel={localizationKeys('signIn.alternativePhoneCodeProvider.formTitle')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ export const SignUpPhoneCodeCard = withCardStateProvider(() => {

if (isAlternativePhoneCodeProvider) {
const provider = getAlternativePhoneCodeProviderData(channel)?.name;
cardTitleKey = localizationKeys('signUp.alternativePhoneCodeProvider.title', { provider });
cardSubtitleKey = localizationKeys('signUp.alternativePhoneCodeProvider.subtitle', { provider });
cardTitleKey = localizationKeys('signUp.alternativePhoneCodeProvider.title', { provider: provider || '' });
cardSubtitleKey = localizationKeys('signUp.alternativePhoneCodeProvider.subtitle', {
provider: provider || '',
});
resendButtonKey = localizationKeys('signUp.alternativePhoneCodeProvider.resendButton');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export const SignUpStartAlternativePhoneCodePhoneNumberCard = (props: SignUpForm
<Form.ControlRow elementId='phoneNumber'>
<Form.PhoneInput
{...formState.phoneNumber.props}
label={localizationKeys('signUp.start.alternativePhoneCodeProvider.label', { provider })}
label={localizationKeys('signUp.start.alternativePhoneCodeProvider.label', {
provider: provider || '',
})}
isRequired
isOptional={false}
actionLabel={undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const EmailForm = withCardStateProvider((props: EmailFormProps) => {
<FormContainer
headerTitle={localizationKeys('userProfile.emailAddressPage.verifyTitle')}
headerSubtitle={localizationKeys(`${translationKey}.formSubtitle`, {
identifier: emailAddressRef.current?.emailAddress,
identifier: emailAddressRef.current?.emailAddress || '',
})}
>
{strategy === 'email_link' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const MFAVerifyPhone = (props: MFAVerifyPhoneProps) => {
<FormContainer
headerTitle={title}
headerSubtitle={localizationKeys('userProfile.phoneNumberPage.verifySubtitle', {
identifier: resourceRef.current?.phoneNumber,
identifier: resourceRef.current?.phoneNumber || '',
})}
>
<VerifyWithCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const VerifyPhone = (props: VerifyPhoneProps) => {
<FormContainer
headerTitle={title}
headerSubtitle={localizationKeys('userProfile.phoneNumberPage.verifySubtitle', {
identifier: resourceRef.current?.phoneNumber,
identifier: resourceRef.current?.phoneNumber || '',
})}
>
<VerifyWithCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export const RemoveConnectedAccountForm = (props: ConnectedAccountFormProps) =>
<RemoveResourceForm
title={localizationKeys('userProfile.connectedAccountPage.removeResource.title')}
messageLine1={localizationKeys('userProfile.connectedAccountPage.removeResource.messageLine1', {
identifier: providerToDisplayData[ref.current]?.name,
identifier: providerToDisplayData[ref.current]?.name || '',
})}
messageLine2={localizationKeys('userProfile.connectedAccountPage.removeResource.messageLine2')}
successMessage={localizationKeys('userProfile.connectedAccountPage.removeResource.successMessage', {
connectedAccount: providerToDisplayData[ref.current]?.name,
connectedAccount: providerToDisplayData[ref.current]?.name || '',
})}
deleteResource={() => Promise.resolve(resource?.destroy())}
onSuccess={onSuccess}
Expand Down Expand Up @@ -212,7 +212,8 @@ export const RemovePasskeyForm = (props: RemovePasskeyFormProps) => {
<RemoveResourceForm
title={localizationKeys('userProfile.passkeyScreen.removeResource.title')}
messageLine1={localizationKeys('userProfile.passkeyScreen.removeResource.messageLine1', {
name: passkey.name,
// Is it possible for passkey.name to be null ?
name: passkey.name || '',
})}
deleteResource={passkey.delete}
onSuccess={onSuccess}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export const VerifyWithCode = (props: VerifyWithCodeProps) => {
<Form.OTPInput
{...otp}
label={localizationKeys('userProfile.emailAddressPage.emailCode.formTitle')}
description={localizationKeys('userProfile.emailAddressPage.emailCode.formSubtitle', { identifier })}
description={localizationKeys('userProfile.emailAddressPage.emailCode.formSubtitle', {
// TODO: Is it correct to be undefined ?
identifier: identifier || '',
})}
Comment thread
panteliselef marked this conversation as resolved.
resendButton={localizationKeys('userProfile.emailAddressPage.emailCode.resendButton')}
centerAlign={false}
/>
Expand Down
9 changes: 5 additions & 4 deletions packages/clerk-js/src/ui/elements/LegalConsentCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ const LegalCheckboxLabel = (props: { termsUrl?: string; privacyPolicyUrl?: strin

if (termsUrl && privacyPolicyUrl) {
localizationKey = localizationKeys('signUp.legalConsent.checkbox.label__termsOfServiceAndPrivacyPolicy', {
termsOfServiceLink: props.termsUrl,
privacyPolicyLink: props.privacyPolicyUrl,
// is this different than before ?
termsOfServiceLink: props.termsUrl || '',
privacyPolicyLink: props.privacyPolicyUrl || '',
});
} else if (termsUrl) {
localizationKey = localizationKeys('signUp.legalConsent.checkbox.label__onlyTermsOfService', {
termsOfServiceLink: props.termsUrl,
termsOfServiceLink: props.termsUrl || '',
});
} else if (privacyPolicyUrl) {
localizationKey = localizationKeys('signUp.legalConsent.checkbox.label__onlyPrivacyPolicy', {
privacyPolicyLink: props.privacyPolicyUrl,
privacyPolicyLink: props.privacyPolicyUrl || '',
});
}

Expand Down
13 changes: 9 additions & 4 deletions packages/clerk-js/src/ui/elements/SocialButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@ export const SocialButtons = React.memo((props: SocialButtonsRootProps) => {
const localizedText =
strategies.length === SOCIAL_BUTTON_PRE_TEXT_THRESHOLD
? localizationKeys('socialButtonsBlockButton', {
provider: strategyToDisplayData[strategy].name,
provider: strategyToDisplayData[strategy].name || '',
})
: localizationKeys('socialButtonsBlockButtonManyInView', {
provider: strategyToDisplayData[strategy].name,
});
: localizationKeys(
'socialButtonsBlockButtonManyInView',
// @ts-expect-error
{
// TODO: THIS IS A SPECIAL CASE HANDLE LATER
provider: strategyToDisplayData[strategy].name || '',
},
);
Comment thread
panteliselef marked this conversation as resolved.
Outdated

const imageOrInitial = strategyToDisplayData[strategy].iconUrl ? (
<Image
Expand Down
15 changes: 5 additions & 10 deletions packages/clerk-js/src/ui/localization/localizationKeys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { PathValue, RecordToPath } from '@clerk/types';

import type { defaultResource } from './defaultEnglishResource';
import type { __internal_LocalizationResource, PathValue, RecordToPath } from '@clerk/types';

type Value = string | number | boolean | Date;
type Whitespace = ' ' | '\t' | '\n' | '\r';
Expand Down Expand Up @@ -61,20 +59,17 @@ export type GetICUArgs<Text extends string, T extends RemovePipeUtils<Text>> = T
T extends readonly string[] ? TupleFindBlocks<T> : FindBlocks<T>
>;

type DefaultLocalizationKey = RecordToPath<typeof defaultResource>;
type LocalizationKeyToValue<P extends DefaultLocalizationKey> = PathValue<typeof defaultResource, P>;

// @ts-ignore
type LocalizationKeyToParams<P extends DefaultLocalizationKey> = GetICUArgs<LocalizationKeyToValue<P>>;
type DefaultLocalizationKey = RecordToPath<__internal_LocalizationResource>;
type LocalizationKeyToValue<P extends DefaultLocalizationKey> = PathValue<__internal_LocalizationResource, P>;

export type LocalizationKey = {
key: string;
params: Record<string, any> | undefined;
};

export const localizationKeys = <Key extends DefaultLocalizationKey, Params extends LocalizationKeyToParams<Key>>(
export const localizationKeys = <Key extends DefaultLocalizationKey, Value extends LocalizationKeyToValue<Key>>(
key: Key,
params?: keyof Params extends never ? never : Params,
params?: Value extends { __params: any } ? Value['__params'] : never,
): LocalizationKey => {
return { key, params } as LocalizationKey;
};
Comment thread
panteliselef marked this conversation as resolved.
Loading