Looking for a way to streamline collaboration with designers & product managers on content? Tired of making PRs to fix typos in JSON files? Checkout Recontent.app to ship localized content faster.
git clone [email protected]:recontentapp/example-nextjs-i18n.git
cd example-nextjs-i18n
yarn
yarn start
Translations are stored in JSON files in the public/locales
folder. Each piece of content needs to be referenced in all supported locales.
The t
function is typed to prevent using unknown paths within a locale file. The en/default.json
file is used as a reference of available paths.
- Update the
locales
array in thenext-i18next.config.js
config file - Add a new JSON file in the
public/locales
folder which matches the added locale name - You can now switch your app in that locale
You can find an example of such test in __tests__/index.spec.tsx
.
As i18next
is not set up in the test environment, make sure to update mocks declared src/setupTests.ts
if you rely on new functions/logic from i18next
or react-i18next
.
Translations files tend to grow exponentially as you add new features to your app.
Instead of relying on a single i18next
namespace which contains all your translations, you can split them in smaller files based on routes (eg. Dashboard) or areas of your app (eg. Admin panel, Public view).