Skip to content

Commit 22fbe6f

Browse files
committed
chore: Add pirate locale to react example
1 parent 573e638 commit 22fbe6f

File tree

5 files changed

+130
-67
lines changed

5 files changed

+130
-67
lines changed

examples/react/src/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { routes } from "./routes";
1919
import { useUser } from "./firebase/hooks";
2020
import { auth } from "./firebase/firebase";
2121
import { multiFactor, sendEmailVerification, signOut } from "firebase/auth";
22-
import { useUI } from "@invertase/firebaseui-react";
22+
import { MultiFactorAuthAssertionScreen, useUI } from "@invertase/firebaseui-react";
2323

2424
function App() {
2525
const user = useUser();
@@ -35,9 +35,9 @@ function UnauthenticatedApp() {
3535
const ui = useUI();
3636

3737
// This can trigger if the user is not on a screen already, and gets an MFA challenge - e.g. on One-Tap sign in.
38-
// if (ui.multiFactorResolver) {
39-
// return <MultiFactorAuthAssertionScreen />;
40-
// }
38+
if (ui.multiFactorResolver) {
39+
return <MultiFactorAuthAssertionScreen />;
40+
}
4141

4242
return (
4343
<div className="max-w-sm mx-auto pt-36 space-y-6 pb-36">

examples/react/src/components/header.tsx

Lines changed: 0 additions & 55 deletions
This file was deleted.

examples/react/src/firebase/config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616

1717
export const firebaseConfig = {
18-
apiKey: "AIzaSyA7xdkFMs7iUC6XWFYjjSxf_XbVV4F1mX4",
19-
authDomain: "fir-ui-2025.firebaseapp.com",
20-
projectId: "fir-ui-2025",
21-
storageBucket: "fir-ui-2025.firebasestorage.app",
22-
messagingSenderId: "616577669988",
23-
appId: "1:616577669988:web:7e67401f952fa9288df871",
18+
apiKey: "AIzaSyCvMftIUCD9lUQ3BzIrimfSfBbCUQYZf-I",
19+
authDomain: "fir-ui-rework.firebaseapp.com",
20+
projectId: "fir-ui-rework",
21+
storageBucket: "fir-ui-rework.firebasestorage.app",
22+
messagingSenderId: "200312857118",
23+
appId: "1:200312857118:web:94e3f69b0e0a4a863f040f",
2424
};

examples/react/src/main.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
import { BrowserRouter, Routes, Route, Outlet, NavLink } from "react-router";
1818

1919
import ReactDOM from "react-dom/client";
20-
import { FirebaseUIProvider } from "@invertase/firebaseui-react";
20+
import { FirebaseUIProvider, useUI } from "@invertase/firebaseui-react";
2121
import { ui, auth } from "./firebase/firebase";
2222
import App from "./App";
2323
import { hiddenRoutes, routes } from "./routes";
24+
import { enUs } from "@invertase/firebaseui-translations";
25+
import { pirate } from "./pirate";
2426

2527
const root = document.getElementById("root")!;
2628

@@ -38,6 +40,7 @@ auth.authStateReady().then(() => {
3840
}}
3941
>
4042
<ThemeToggle />
43+
<PirateToggle />
4144
<Routes>
4245
<Route path="/" element={<App />} />
4346
<Route element={<ScreenRoute />}>
@@ -70,7 +73,7 @@ function ScreenRoute() {
7073
function ThemeToggle() {
7174
return (
7275
<button
73-
className="fixed z-10 top-8 right-8 border border-gray-300 dark:border-gray-700 rounded-md p-2 group/toggle extend-touch-target"
76+
className="fixed z-10 size-10 top-8 right-8 border border-gray-300 dark:border-gray-700 rounded-md p-2 group/toggle extend-touch-target"
7477
onClick={() => {
7578
document.documentElement.classList.toggle("dark", !document.documentElement.classList.contains("dark"));
7679
localStorage.theme = document.documentElement.classList.contains("dark") ? "dark" : "light";
@@ -100,3 +103,23 @@ function ThemeToggle() {
100103
</button>
101104
);
102105
}
106+
107+
function PirateToggle() {
108+
const ui = useUI();
109+
const isPirate = ui.locale.locale === "pirate";
110+
111+
return (
112+
<button
113+
className="fixed z-10 size-10 top-8 right-20 border border-gray-300 dark:border-gray-700 rounded-md p-2 group/toggle extend-touch-target"
114+
onClick={() => {
115+
if (isPirate) {
116+
ui.setLocale(enUs);
117+
} else {
118+
ui.setLocale(pirate);
119+
}
120+
}}
121+
>
122+
{isPirate ? "🇺🇸" : "🏴‍☠️"}
123+
</button>
124+
);
125+
}

examples/react/src/pirate.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { registerLocale } from "@invertase/firebaseui-translations";
2+
3+
export const pirate = registerLocale("pirate", {
4+
errors: {
5+
userNotFound: "Arrr! No account found with this email address, matey",
6+
wrongPassword: "Arrr! Incorrect password, ye scallywag",
7+
invalidEmail: "Avast! Enter a valid email address, ye bilge rat",
8+
userDisabled: "This account has been marooned, arrr!",
9+
networkRequestFailed: "Can't connect to the server, ye land lubber! Check yer internet connection",
10+
tooManyRequests: "Too many failed attempts, ye scurvy dog! Try again later",
11+
missingVerificationCode: "Enter the verification code, ye scallywag",
12+
emailAlreadyInUse: "An account already exists with this email, arrr!",
13+
invalidCredential: "The credentials ye provided be invalid, matey",
14+
weakPassword: "Ye password ain't long enough! It should be at least 8 characters",
15+
unverifiedEmail: "Verify yer email address to continue, ye scallywag",
16+
operationNotAllowed: "This operation ain't allowed, arrr! Contact support, matey",
17+
invalidPhoneNumber: "The phone number be invalid, ye bilge rat",
18+
missingPhoneNumber: "Provide a phone number, ye scallywag",
19+
quotaExceeded: "SMS quota exceeded, arrr! Try again later, matey",
20+
codeExpired: "The verification code has expired, ye scurvy dog",
21+
captchaCheckFailed: "reCAPTCHA verification failed, arrr! Try again, matey",
22+
missingVerificationId: "Complete the reCAPTCHA verification first, ye scallywag",
23+
missingEmail: "Provide an email address, ye bilge rat",
24+
invalidActionCode: "The password reset link be invalid or has expired, arrr!",
25+
credentialAlreadyInUse: "An account already exists with this email, arrr! Sign in with that account, matey",
26+
requiresRecentLogin: "This operation requires a recent login, ye scallywag! Sign in again",
27+
providerAlreadyLinked: "This phone number be already linked to another account, arrr!",
28+
invalidVerificationCode: "Invalid verification code, ye scurvy dog! Try again",
29+
unknownError: "An unexpected error occurred, arrr!",
30+
popupClosed: "The sign-in popup was closed, ye scallywag! Try again",
31+
accountExistsWithDifferentCredential:
32+
"An account already exists with this email, arrr! Sign in with the original provider, matey",
33+
displayNameRequired: "Provide a display name, ye bilge rat",
34+
secondFactorAlreadyInUse: "This phone number be already enrolled with this account, arrr!",
35+
},
36+
messages: {
37+
passwordResetEmailSent: "Password reset email sent successfully, arrr!",
38+
signInLinkSent: "Sign-in link sent successfully, matey!",
39+
verificationCodeFirst: "Request a verification code first, ye scallywag",
40+
checkEmailForReset: "Check yer email for password reset instructions, ye bilge rat",
41+
dividerOr: "or",
42+
termsAndPrivacy: "By continuing, ye agree to our {tos} and {privacy}, arrr!",
43+
mfaSmsAssertionPrompt:
44+
"A verification code will be sent to {phoneNumber} to complete the authentication process, matey.",
45+
},
46+
labels: {
47+
emailAddress: "Email Address, ye bilge rat",
48+
password: "Password, ye scallywag",
49+
displayName: "Display Name, ye bilge rat",
50+
forgotPassword: "Forgot Password, ye scallywag?",
51+
signUp: "Sign Up, Matey",
52+
signIn: "Sign In, Matey",
53+
resetPassword: "Reset Password, ye scallywag",
54+
createAccount: "Create Account, ye bilge rat",
55+
backToSignIn: "Back to Sign In, ye scallywag",
56+
signInWithPhone: "Sign in with Phone, ye scallywag",
57+
phoneNumber: "Phone Number, ye bilge rat",
58+
verificationCode: "Verification Code, ye scallywag",
59+
sendCode: "Send Code, ye scallywag",
60+
verifyCode: "Verify Code, ye scallywag",
61+
signInWithGoogle: "Sign in with ye Google Account",
62+
signInWithFacebook: "Sign in with ye Facebook Account",
63+
signInWithApple: "Sign in with ye Apple Account",
64+
signInWithMicrosoft: "Sign in with ye Microsoft Account",
65+
signInWithGitHub: "Sign in with ye GitHub Account",
66+
signInWithTwitter: "Sign in with ye X Account",
67+
signInWithEmailLink: "Sign in with Email Link",
68+
sendSignInLink: "Send Sign-in Link",
69+
termsOfService: "Terms of Service",
70+
privacyPolicy: "Privacy Policy",
71+
resendCode: "Resend ye Code",
72+
sending: "Firing...",
73+
multiFactorEnrollment: "Multi-factor Enrrrrrrollment!",
74+
multiFactorAssertion: "Multi-factor Authentication, arrr!",
75+
mfaTotpVerification: "TOTP Verification, arrr!",
76+
mfaSmsVerification: "SMS Verification, arrr!",
77+
generateQrCode: "Generate ye QR Code",
78+
},
79+
prompts: {
80+
noAccount: "Don't have an account, ye scallywag?",
81+
haveAccount: "Already have an account, matey?",
82+
enterEmailToReset: "Enter yer email address to reset yer password, ye bilge rat",
83+
signInToAccount: "Sign in to yer account, matey",
84+
smsVerificationPrompt: "Enter the verification code sent to yer phone number, ye scallywag",
85+
enterDetailsToCreate: "Enter yer details to create a new account, ye bilge rat",
86+
enterPhoneNumber: "Enter yer phone number, matey",
87+
enterVerificationCode: "Enter the verification code, ye scallywag",
88+
enterEmailForLink: "Enter yer email to receive a sign-in link, ye bilge rat",
89+
mfaEnrollmentPrompt: "Select a new multi-factor enrollment method, arrr!",
90+
mfaAssertionPrompt: "Complete the multi-factor authentication process, ye scallywag",
91+
mfaAssertionFactorPrompt: "Choose a multi-factor authentication method, matey",
92+
mfaTotpQrCodePrompt: "Scan this QR code with yer authenticator app, ye bilge rat",
93+
mfaTotpEnrollmentVerificationPrompt: "Add the code generated by yer authenticator app, arrr!",
94+
},
95+
});

0 commit comments

Comments
 (0)