Skip to content

Commit d9daf5f

Browse files
committed
fix: normalize action ID for translation lookup in SignIn and SignUp components
1 parent 93ef5c5 commit d9daf5f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/react/src/components/presentation/SignIn/component-driven/transformer.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,19 @@ const convertActionToComponent = (
117117
action: {type: string; id: string},
118118
t: UseTranslation['t'],
119119
): EmbeddedFlowComponent => {
120+
// Normalize action ID for translation lookup (e.g., "google_auth" -> "google")
121+
const normalizedId: string = action.id.replace(/_auth$/, '');
122+
120123
// Use i18n key for button text, fallback to capitalized id
121-
const i18nKey = `elements.buttons.${action.id}`;
122-
let text = t(i18nKey);
124+
const i18nKey: string = `elements.buttons.${normalizedId}`;
125+
let text: string = t(i18nKey);
126+
123127
if (!text || text === i18nKey) {
128+
// Fallback: format the original action ID
124129
text = action.id.replace(/_/g, ' ');
125130
text = text.charAt(0).toUpperCase() + text.slice(1);
126131
}
132+
127133
return {
128134
id: generateId('action'),
129135
type: EmbeddedFlowComponentType.Button,

packages/react/src/components/presentation/SignUp/transformer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,15 @@ const convertActionToComponent = (
129129
action: {type: string; id: string},
130130
t: UseTranslation['t'],
131131
): EmbeddedFlowComponent => {
132-
const i18nKey: string = `elements.buttons.${action.id}`;
132+
// Normalize action ID for translation lookup (e.g., "google_auth" -> "google")
133+
const normalizedId: string = action.id.replace(/_auth$/, '');
134+
135+
// Use i18n key for button text, fallback to capitalized id
136+
const i18nKey: string = `elements.buttons.${normalizedId}`;
133137
let text: string = t(i18nKey);
134138

135139
if (!text || text === i18nKey) {
140+
// Fallback: format the original action ID
136141
text = action.id.replace(/_/g, ' ');
137142
text = text.charAt(0).toUpperCase() + text.slice(1);
138143
}

0 commit comments

Comments
 (0)