Skip to content

Commit

Permalink
Edit firebase error message translation
Browse files Browse the repository at this point in the history
  • Loading branch information
w3labkr committed Dec 19, 2023
1 parent 7368911 commit 50a7b5d
Show file tree
Hide file tree
Showing 10 changed files with 504 additions and 376 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ firebase emulators:start
Set the expiration of a preview channel

```shell
firebase hosting:channel:deploy preview --expires 1d
firebase hosting:channel:deploy preview --expires 1h
```

Start firebase deployment.
Expand Down
3 changes: 1 addition & 2 deletions app/[lng]/(auth)/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export default function Page({ params: { lng } }: { params: { lng: string } }):
})
.catch((error: AuthError) => {
// An error happened.
console.log(error.code);
setError('password', { message: error.code });
setError('password', { message: t(`firebase:${error.code}`) });
});
};

Expand Down
4 changes: 3 additions & 1 deletion app/[lng]/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function Page({ params: { lng } }: { params: { lng: string } }):
register,
handleSubmit,
getFieldState,
setError,
reset,
formState: { errors, isSubmitting },
} = useForm<FormTypes>({
Expand All @@ -79,7 +80,8 @@ export default function Page({ params: { lng } }: { params: { lng: string } }):
})
.catch((error: AuthError) => {
// An error happened.
console.log(error.code);
console.log(t(`firebase:${error.code}`));
setError('email', { message: t(`firebase:${error.code}`) });
});
};

Expand Down
208 changes: 119 additions & 89 deletions app/i18n/locales/en/firebase.json

Large diffs are not rendered by default.

206 changes: 118 additions & 88 deletions app/i18n/locales/ko/firebase.json

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions docs/Firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ firebase init hosting
firebase deploy
```

## Error Handling

- [Admin Authentication API Errors](https://firebase.google.com/docs/auth/admin/errors)
- [Handle errors for Cloud Storage on Web](https://firebase.google.com/docs/storage/web/handle-errors)
- [FirebaseFirestoreException.Code](https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FirebaseFirestoreException.Code)

## Reference

Get started with Firebase
Expand All @@ -99,3 +93,11 @@ Get started with Firebase
Manage your Firebase projects

- [Select locations for your project](https://firebase.google.com/docs/projects/locations?authuser=0)

Error Code

- [AuthErrorCodes](https://firebase.google.com/docs/reference/js/auth#autherrorcodes)
- [StorageErrorCode](https://firebase.google.com/docs/reference/js/storage#storageerrorcode)
- [FirestoreErrorCode](https://firebase.google.com/docs/reference/js/firestore_.md#firestoreerrorcode)
- [Admin Authentication API Errors](https://firebase.google.com/docs/auth/admin/errors)
- [Handle Error Messages](https://firebase.google.com/docs/storage/web/handle-errors)
208 changes: 119 additions & 89 deletions lib/firebase/locale/en.json

Large diffs are not rendered by default.

206 changes: 118 additions & 88 deletions lib/firebase/locale/ko.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function middleware(request: NextRequest) {
pathname.startsWith(`/${locale}${slug}`) || pathname.startsWith(`${slug}`);

// Redirect the user to another URL
// if (pathnameHasSlug('/home')) {
// if (pathnameHasSlug('/about')) {
// return NextResponse.redirect(new URL(`/${locale}`, request.url));
// }

Expand All @@ -53,5 +53,5 @@ export const config = {
* - favicon.ico (favicon file)
* - etc
*/
matcher: ['/((?!api|_next/static|_next/image|assets|favicon.ico|sw.js|manifest.webmanifest).*)'],
matcher: ['/', '/((?!api|_next/static|_next/image|assets|favicon.ico|sw.js|manifest.webmanifest).*)'],
};
25 changes: 15 additions & 10 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ module.exports = {
reactStrictMode: isProd,

// Redirects allow you to redirect an incoming request path to a different destination path.
async redirects() {
return [
// {
// source: '/',
// destination: '/about',
// permanent: true,
// },
];
},
// async redirects() {
// return [
// {
// source: '/',
// destination: '/about',
// permanent: true,
// },
// ];
// },

// Rewrites allow you to map an incoming request path to a different destination path.
// async rewrites() {
// return [];
// return [
// {
// source: '/',
// destination: '/about',
// },
// ];
// },
};

0 comments on commit 50a7b5d

Please sign in to comment.