next-multilingual
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -118,2 +118,3 @@ "use strict"; | ||
__2.log.warn(`unable to format key with identifier \`${key}\` in \`${this.sourceFilePath}\` because it was not found in messages file \`${this.messagesFilePath}\``); | ||
return ''; | ||
} | ||
@@ -120,0 +121,0 @@ return message.format(values); |
{ | ||
"name": "next-multilingual", | ||
"description": "An opinionated end-to-end multilingual solution for Next.js.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
@@ -525,2 +525,32 @@ # ![next-multilingual](./assets/next-multilingual-banner.svg) | ||
### Custom Error Pages | ||
Like most site, you will want to leverage Next.js' [custom your error pages](https://nextjs.org/docs/advanced-features/custom-error-page) capability. With `useMessages()`, it's just as easy as creating any other pages. For example, for a `404` error, you can create your `404.tsx`: | ||
```tsx | ||
import { useMessages } from 'next-multilingual/messages'; | ||
import { MulLink } from 'next-multilingual/link'; | ||
import type { ReactElement } from 'react'; | ||
import Layout from '@/layout'; | ||
export default function Custom400(): ReactElement { | ||
const messages = useMessages(); | ||
return ( | ||
<Layout title={messages.format('pageTitle')}> | ||
<h1>{messages.format('pageTitle')}</h1> | ||
<MulLink href="/"> | ||
<a>{messages.format('goBack')}</a> | ||
</MulLink> | ||
</Layout> | ||
); | ||
} | ||
``` | ||
And of course, your messages, for example `404.en-US.properties`: | ||
```ini | ||
exampleApp.pageNotFoundError.pageTitle = 404 - Page Not Found | ||
exampleApp.pageNotFoundError.goBack = Go back home | ||
``` | ||
## Translation process 🈺 | ||
@@ -527,0 +557,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126539
2048
572