Menu

Upgrade Guide

Upgrade from Nexty.dev pre-v1.1.7 internationalization features to the new structure.

File Structure Comparison

v1.1.7- File Structure

i18n/
├── messages/                # Translation files directory
│   ├── en.json              # English translations
│   ├── zh.json              # Chinese translations
│   └── ja.json              # Japanese translations
├── request.ts               # next-intl request configuration
└── routing.ts               # Routing and language configuration

v1.1.7+ File Structure

i18n/
├── messages/                # Translation files directory
│   ├── en/                  # English translations
│   │   └── common.json
│   ├── zh/                  # Chinese translations
│   │   └── common.json
│   └── ja/                  # Japanese translations
│       └── common.json
├── request.ts               # next-intl request configuration
└── routing.ts               # Routing and language configuration

Upgrade Steps

Step 1. Update Translation File Structure

According to the file structure comparison above, update the translation file structure to the new structure.

Then split according to your needs, for example, split Dashboard and Landing independently by creating separate Dashboard.json and Landing.json files.

Step 2. Update Request Configuration

Replace the request.ts file with the code below:

import { getRequestConfig } from 'next-intl/server';
import { routing } from './routing';
 
export default getRequestConfig(async ({ requestLocale }) => {
  let locale = await requestLocale;
 
  if (!locale || !routing.locales.includes(locale as any)) {
    locale = routing.defaultLocale;
  }
 
  const common = (await import(`./messages/${locale}/common.json`)).default;
  const Landing = (await import(`./messages/${locale}/Landing.json`)).default;
  const Dashboard = (await import(`./messages/${locale}/Dashboard.json`)).default;
 
  return {
    locale,
    messages: {
      Landing,
      Dashboard,
      ...common
    }
  };
});

Step 3. Update Language Detection Alert LanguageDetectionAlert

Change the following code

const messages = require(`@/i18n/messages/${currentLocale}.json`);
const alertMessages = messages.LanguageDetection;

to

const messages = require(`@/i18n/messages/${currentLocale}/common.json`);
const alertMessages = messages.LanguageDetection;

This completes the upgrade. In the future, whenever you add new translation files, you only need to add them in request.ts.