Replace react-intl with next-intl and consolidate lang files.

Migrate i18n from react-intl to next-intl, eliminating the formatjs
compilation pipeline. Translation files now live as nested JSON in
public/intl/messages/ (single source of truth), removing the duplicated
src/lang/ directory and the copy/compile build steps. The useMessages()
hook API is preserved so all 195+ consumer components are unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mike Cao 2026-02-07 01:48:32 -08:00
parent fed8d4c71a
commit a1890e9261
118 changed files with 18151 additions and 136657 deletions

View file

@ -1,11 +1,11 @@
/* eslint-disable no-console */
import https from 'node:https';
import path from 'node:path';
import chalk from 'chalk';
import fs from 'fs-extra';
import https from 'https';
const src = path.resolve(process.cwd(), 'src/lang');
const src = path.resolve(process.cwd(), 'public/intl/messages');
const dest = path.resolve(process.cwd(), 'public/intl/country');
const files = fs.readdirSync(src);

View file

@ -1,11 +1,11 @@
/* eslint-disable no-console */
import https from 'node:https';
import path from 'node:path';
import chalk from 'chalk';
import fs from 'fs-extra';
import https from 'https';
const src = path.resolve(process.cwd(), 'src/lang');
const src = path.resolve(process.cwd(), 'public/intl/messages');
const dest = path.resolve(process.cwd(), 'public/intl/language');
const files = fs.readdirSync(src);

View file

@ -1,35 +0,0 @@
import path from 'node:path';
import del from 'del';
import fs from 'fs-extra';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const src = path.resolve(process.cwd(), 'src/lang');
const dest = path.resolve(process.cwd(), 'build/messages');
const files = fs.readdirSync(src);
del.sync([path.join(dest)]);
/*
This script takes the files from the `lang` folder and formats them into
the format that format-js expects.
*/
async function run() {
await fs.ensureDir(dest);
files.forEach(file => {
const lang = require(path.resolve(process.cwd(), `src/lang/${file}`));
const keys = Object.keys(lang).sort();
const formatted = keys.reduce((obj, key) => {
obj[key] = { defaultMessage: lang[key] };
return obj;
}, {});
const json = JSON.stringify(formatted, null, 2);
fs.writeFileSync(path.resolve(dest, file), json);
});
}
run();

View file

@ -1,43 +0,0 @@
/* eslint-disable no-console */
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'module';
import prettier from 'prettier';
const require = createRequire(import.meta.url);
const messages = require('../build/extracted-messages.json');
const dest = path.resolve(process.cwd(), 'src/lang');
const files = fs.readdirSync(dest);
const keys = Object.keys(messages).sort();
/*
This script takes extracted messages and merges them
with the existing files under `lang`. Any newly added
keys will be printed to the console.
*/
files.forEach(file => {
const lang = require(path.resolve(process.cwd(), `src/lang/${file}`));
console.log(`Merging ${file}`);
const merged = keys.reduce((obj, key) => {
const message = lang[key];
if (file === 'en-US.json') {
obj[key] = messages[key].defaultMessage;
} else {
obj[key] = message || messages[key].defaultMessage;
}
if (!message) {
console.log(`* Added key ${key}`);
}
return obj;
}, {});
const json = prettier.format(JSON.stringify(merged), { parser: 'json' });
fs.writeFileSync(path.resolve(dest, file), json);
});