From fcac61bb2d9e1ae040f94b49ccd39b9b13bf2b86 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Wed, 18 Jun 2025 16:32:44 +0100 Subject: [PATCH 1/3] fix(core): translation locales now de-duped when initialising --- packages/firebaseui-core/src/config.ts | 20 ++++++++------- .../tests/unit/translations.test.ts | 25 +++++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/firebaseui-core/src/config.ts b/packages/firebaseui-core/src/config.ts index 235abdfdd..af1b18024 100644 --- a/packages/firebaseui-core/src/config.ts +++ b/packages/firebaseui-core/src/config.ts @@ -59,15 +59,17 @@ export function initializeUI(config: FirebaseUIConfigurationOptions, name: strin config.translations ??= []; - // TODO: Is this right? - config.translations.push(english); - - const translations = config.translations?.reduce((acc, translation) => { - return { - ...acc, - [translation.locale]: translation.translations, - }; - }, {} as TranslationsConfig); + // Map the translations to a TranslationsConfig object. + // If no translations are provided, use the English translations as default. + const translations = config.translations?.reduce( + (acc, translation) => { + return { + ...acc, + [translation.locale]: translation.translations, + }; + }, + { [english.locale]: english.translations } as TranslationsConfig + ); $config.setKey( name, diff --git a/packages/firebaseui-core/tests/unit/translations.test.ts b/packages/firebaseui-core/tests/unit/translations.test.ts index d7e26ad41..803c73d04 100644 --- a/packages/firebaseui-core/tests/unit/translations.test.ts +++ b/packages/firebaseui-core/tests/unit/translations.test.ts @@ -142,4 +142,29 @@ describe('getTranslation', () => { const translation = getTranslation(mockUi as any, 'errors', 'userNotFound'); expect(translation).toBe('No account found with this email address'); }); + + it('should allow custom en-US translation to overwrite the default one', () => { + const customEnUs = { + locale: 'en-US', + translations: { + errors: { + userNotFound: 'Custom override message', + }, + }, + }; + + const config = { + translations: [customEnUs], + }; + + const result = config.translations.reduce( + (acc, t) => ({ + ...acc, + [t.locale]: t.translations, + }), + { [english.locale]: english.translations } + ); + + expect(result['en-US'].errors.userNotFound).toBe('Custom override message'); + }); }); From 6b32c67a364f68d2cad60f2a6f8fe29a558e48d2 Mon Sep 17 00:00:00 2001 From: Darren Ackers Date: Wed, 2 Jul 2025 17:46:51 +0100 Subject: [PATCH 2/3] chore(*): Add translation default comment. --- packages/firebaseui-core/src/config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/firebaseui-core/src/config.ts b/packages/firebaseui-core/src/config.ts index af1b18024..d9da7e1a6 100644 --- a/packages/firebaseui-core/src/config.ts +++ b/packages/firebaseui-core/src/config.ts @@ -68,6 +68,7 @@ export function initializeUI(config: FirebaseUIConfigurationOptions, name: strin [translation.locale]: translation.translations, }; }, + //TODO: Do we always want to include English here? { [english.locale]: english.translations } as TranslationsConfig ); From 98b7f6a0897c8542d59d864f8bb904a7ac221a23 Mon Sep 17 00:00:00 2001 From: oooooooo <60764+oooooooo@users.noreply.github.com> Date: Sun, 23 Nov 2025 20:06:29 +0900 Subject: [PATCH 3/3] docs(*): updated documentation to fix prop from config={ui} to ui={ui} --- README.md | 2 +- packages/firebaseui-react/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33afe5bed..de02545af 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ const ui = initializeUI({ app }); createRoot(document.getElementById("root")!).render( - + diff --git a/packages/firebaseui-react/README.md b/packages/firebaseui-react/README.md index 44188ed08..1a278eabe 100644 --- a/packages/firebaseui-react/README.md +++ b/packages/firebaseui-react/README.md @@ -56,7 +56,7 @@ import { ConfigProvider } from "@firebase-ui/react"; createRoot(document.getElementById("root")!).render( - +