Skip to content

Commit

Permalink
docs: Link to new example, more details on i18n.ts, avoid hardcoded l…
Browse files Browse the repository at this point in the history
…abels in linting, remove register button in without i18n routing example
  • Loading branch information
amannn committed Jun 25, 2024
1 parent c8badae commit a00c44e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 2 additions & 0 deletions docs/pages/docs/usage/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export default getRequestConfig(async () => {

The configuration object is created once for each request by internally using React's [`cache`](https://react.dev/reference/react/cache). The first component to use internationalization will call the function defined with `getRequestConfig`.

Since this function is executed during the Server Components render pass, you can call functions like [`cookies()`](https://nextjs.org/docs/app/api-reference/functions/cookies) and [`headers()`](https://nextjs.org/docs/app/api-reference/functions/headers) to return configuration that is request-specific.

### `NextIntlClientProvider`

`NextIntlClientProvider` can be used to provide configuration for **Client Components**.
Expand Down
17 changes: 16 additions & 1 deletion docs/pages/docs/workflows/linting.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Linting

To ensure the correct usage of `next-intl`, you can use ESLint to enforce certain rules.
To ensure correct usage of `next-intl`, you can use ESLint to enforce certain rules.

## Avoid hardcoded labels in component markup

The [`react/jsx-no-literals`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md) rule from [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react) can be helpful with spotting hardcoded labels in component markup. This can be especially helpful when migrating a project to `next-intl`, if you want to make sure that all labels have been extracted.

```javascript filename="eslint.config.js"
// ...

rules: {
// Avoid hardcoded labels
'react/jsx-no-literals': 'error'
}
```

Be careful though that this doesn't catch hardcoded attributes (e.g. `aria-label="Open menu"`).

## Consistent usage of navigation APIs

Expand Down
1 change: 1 addition & 0 deletions docs/pages/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ These examples can provide inspiration for your project, showcasing different se
name="App Router without i18n routing"
hash="app-router-without-i18n-routing"
description="Demonstrates usage of next-intl without i18n routing, a typical setup for apps behind an auth layer. The app manages the locale via a cookie that can be updated via a Server Action."
demoLink="https://next-intl-example-app-router-without-i18n-routing.vercel.app"
sourceLink="https://github.com/amannn/next-intl/tree/main/examples/example-app-router-without-i18n-routing"
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
"invalidPassword": "Bitte geben Sie ein Passwort ein.",
"login": "Anmelden",
"password": "Passwort",
"register": {
"action": "Registrieren",
"description": "Noch kein Konto?"
},
"title": "Willkommen zurück"
},
"ProfilePage": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
"invalidPassword": "Please enter a password.",
"login": "Sign in",
"password": "Password",
"register": {
"action": "Sign up",
"description": "No account yet?"
},
"title": "Welcome back"
},
"ProfilePage": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {UsersIcon} from '@heroicons/react/24/outline';
import {isEqual} from 'lodash';
import Link from 'next/link';
import {redirect} from 'next/navigation';
import {useLocale, useTranslations} from 'next-intl';
import {getTranslations} from 'next-intl/server';
Expand Down Expand Up @@ -107,15 +106,6 @@ export default function LoginPage() {
submit={
<div>
<Button type="submit">{t('login')}</Button>
<p className="mt-4 text-center text-sm text-slate-700">
{t('register.description')}{' '}
<Link
className="font-semibold underline transition-colors hover:text-slate-900"
href="#"
>
{t('register.action')}
</Link>
</p>
<p className="mt-4 text-center text-sm text-slate-700">
{t('credentials')}
</p>
Expand Down

0 comments on commit a00c44e

Please sign in to comment.