Skip to content

Commit

Permalink
Apply more suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 22, 2020
1 parent 85f2728 commit ba0247c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
12 changes: 7 additions & 5 deletions docs/advanced-features/i18n-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ul>
</details>

Next.js has built-in support for internationalized (i18n) routing since `v9.5.7`. You can provide a list of locales, the default locale, and domain-specific locales and Next.js will automatically handle the routing.
Next.js has built-in support for internationalized ([i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization#Naming)) routing since `v9.5.7`. You can provide a list of locales, the default locale, and domain-specific locales and Next.js will automatically handle the routing.

The i18n routing support is currently meant to complement existing i18n library solutions like react-intl, react-i18next, lingui, rosetta, and others by streamlining the routes and locale parsing.

Expand Down Expand Up @@ -59,13 +59,15 @@ If we did not have the `example.fr` domain configured, then the user would inste

## Accessing the locale information

The detected locale information is provided in multiple places to ensure it's available where it might be needed.
On the `next/router` instance available via the [`useRouter()`](https://nextjs.org/docs/api-reference/next/router#userouter) hook. It has the following fields:

On the `next/router` instance available via the [`useRouter()`](https://nextjs.org/docs/api-reference/next/router#userouter) hook, we expose the active locale under `router.locale`, all of the supported locales under `router.locales`, and the current default locale under `router.defaultLocale`.
- `locale` contains the active locale.
- `locales` contains all supported locales.
- `defaultLocale` contains the current default locale.

When prerendering pages with `getStaticProps`, the locale information is provided in [the context](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation) provided to the function as `locale` for the active locale and `locales` for all supported locales.
When [prerendering](/docs/basic-features/pages#static-generation-recommended) pages with `getStaticProps`, the locale information is provided in [the context](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation) provided to the function.

When leveraging `getStaticPaths`, the supported locales are also provided in the context provided to the function under `locales`.
When leveraging `getStaticPaths`, the supported locales are provided in the context provided to the function under `locales`.

## Transition between locales

Expand Down
7 changes: 6 additions & 1 deletion docs/api-reference/next/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ The following is the definition of the `router` object returned by both [`useRou

- `pathname`: `String` - Current route. That is the path of the page in `/pages`
- `query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching.md). Defaults to `{}`
- `asPath`: `String` - Actual path (including the query) shown in the browser
- `asPath`: `String` - Actual path (including the query) shown in the browser.
- `isFallback`: `boolean` - Whether the current page is in [fallback mode](/docs/basic-features/data-fetching#fallback-pages).
- `basePath`: `String` - The active [basePath](/docs/api-reference/next.config.js/basepath) (if enabled).
- `locale`: `String` - The active locale (if enabled).
- `locales`: `String[]` - All supported locales (if enabled).
- `defaultLocale`: `String` - The current default locale (if enabled).

Additionally, the following methods are also included inside `router`:

Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The `context` parameter is an object containing the following keys:

- `props` - A **required** object with the props that will be received by the page component. It should be a [serializable object](https://en.wikipedia.org/wiki/Serialization)
- `revalidate` - An **optional** amount in seconds after which a page re-generation can occur. More on [Incremental Static Regeneration](#incremental-static-regeneration)
- `notFound` - An **optional** boolean value specifying the page should handle as the 404 page returning the 404 status. More on [Incremental Static Regeneration](#incremental-static-regeneration)
- `notFound` - An **optional** boolean value specifying the page should render the 404 page with a 404 status code. More on [Incremental Static Regeneration](#incremental-static-regeneration)

> **Note**: You can import modules in top-level scope for use in `getStaticProps`.
> Imports used in `getStaticProps` will [not be bundled for the client-side](#write-server-side-code-directly).
Expand Down

0 comments on commit ba0247c

Please sign in to comment.