Skip to content

Commit

Permalink
Move plugin to next-translate-plugin package (#975)
Browse files Browse the repository at this point in the history
* Move webpack plugin to package

* Add migration guide + add some improvements

* Fix tsc package.json script

* Update docs
  • Loading branch information
aralroca authored Jan 23, 2023
1 parent f134a17 commit 1382b03
Show file tree
Hide file tree
Showing 32 changed files with 257 additions and 3,790 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

[![npm version](https://badge.fury.io/js/next-translate.svg)](https://badge.fury.io/js/next-translate)
[![PRs Welcome][badge-prwelcome]][prwelcome]
<a href="https://github.com/vinissimus/next-translate/actions?query=workflow%3ACI" alt="Tests status">
<img src="https://github.com/vinissimus/next-translate/workflows/CI/badge.svg" /></a>
<a href="https://github.com/aralroca/next-translate/actions?query=workflow%3ACI" alt="Tests status">
<img src="https://github.com/aralroca/next-translate/workflows/CI/badge.svg" /></a>
<a href="https://twitter.com/intent/follow?screen_name=aralroca">
<img src="https://img.shields.io/twitter/follow/aralroca?style=social&logo=twitter"
alt="follow on Twitter"></a>
Expand Down Expand Up @@ -118,18 +118,22 @@ If for some reason you use a `getInitialProps` in your `_app.js` file, then the

### Add next-translate plugin

The `next-translate-plugin` is a tool that allows developers to efficiently handle translations on a page-by-page basis during the build process. It is distinct from the `next-translate` package, which allows developers to access the translations in the code where it is needed. The plugin works by parsing all pages, searching for the translations and rewriting the page file adding the translations to it. This makes the plugin a more efficient and flexible solution for handling translations within a Next.js application. It is recommended to install the plugin as a devDependency.

- `yarn add next-translate-plugin -D`

In your **next.config.js** file:

```js
const nextTranslate = require('next-translate')
const nextTranslate = require('next-translate-plugin')

module.exports = nextTranslate()
```

Or if you already have **next.config.js** file and want to keep the changes in it, pass the config object to the `nextTranslate()`. For example for webpack you could do it like this:

```js
const nextTranslate = require('next-translate')
const nextTranslate = require('next-translate-plugin')

module.exports = nextTranslate({
webpack: (config, { isServer, webpack }) => {
Expand Down Expand Up @@ -914,7 +918,7 @@ yarn create next-app --example with-next-translate with-next-translate-app
This demo is in this repository:
- `git clone git@github.com:vinissimus/next-translate.git`
- `git clone git@github.com:aralroca/next-translate.git`
- `cd next-translate`
- `yarn && yarn example:basic`
Expand All @@ -924,7 +928,7 @@ Similar than the basic demo but with some extras: TypeScript, Webpack 5, MDX, wi
This demo is in this repository:
- `git clone git@github.com:vinissimus/next-translate.git`
- `git clone git@github.com:aralroca/next-translate.git`
- `cd next-translate`
- `yarn && yarn example:complex`
Expand All @@ -936,7 +940,7 @@ Similar than the basic example but loading the page namespaces manually deactiva
This demo is in this repository:
- `git clone git@github.com:vinissimus/next-translate.git`
- `git clone git@github.com:aralroca/next-translate.git`
- `cd next-translate`
- `yarn && yarn example:without-loader`
Expand Down
Loading

0 comments on commit 1382b03

Please sign in to comment.