Simplify i18n: remove old react-intl artifacts, rename formatMessage to t, replace FormattedMessage with t.rich().

- Rewrite messages.ts to plain string key maps (remove MessageDescriptor)
- Rewrite useMessages hook to expose t from useTranslations() directly
- Rename formatMessage → t across 193 consumer files
- Replace custom FormattedMessage component with next-intl t.rich()
- Update 52 language files to use rich text tags (<b>, <a>)
- Remove all direct imports from @/components/messages in favor of useMessages()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mike CaoandClaude Opus 4.6 committed 2026-02-07 11:19:04 -08:00
1 parent 80cad6ea65
commit 50edb71687
247 files changed
+1660 -2194

No files matched your search

@@ -4,11 +4,11 @@ import { LockKeyhole } from '@/components/icons';
import { PasswordEditForm } from './PasswordEditForm';
export function PasswordChangeButton() {
const { formatMessage, labels, messages } = useMessages();
const { t, labels, messages } = useMessages();
const { toast } = useToast();
const handleSave = () => {
toast(formatMessage(messages.saved));
toast(t(messages.saved));
};
return (
@@ -17,10 +17,10 @@ export function PasswordChangeButton() {
<Icon>
<LockKeyhole />
</Icon>
<Text>{formatMessage(labels.changePassword)}</Text>
<Text>{t(labels.changePassword)}</Text>
</Button>
<Modal>
<Dialog title={formatMessage(labels.changePassword)} style={{ width: 400 }}>
<Dialog title={t(labels.changePassword)} style={{ width: 400 }}>
{({ close }) => <PasswordEditForm onSave={handleSave} onClose={close} />}
</Dialog>
</Modal>
@@ -9,7 +9,7 @@ import {
import { useMessages, useUpdateQuery } from '@/components/hooks';
export function PasswordEditForm({ onSave, onClose }) {
const { formatMessage, labels, messages, getErrorMessage } = useMessages();
const { t, labels, messages, getErrorMessage } = useMessages();
const { mutateAsync, error, isPending } = useUpdateQuery('/me/password');
const handleSubmit = async (data: any) => {
@@ -23,7 +23,7 @@ export function PasswordEditForm({ onSave, onClose }) {
const samePassword = (value: string, values: Record<string, any>) => {
if (value !== values.newPassword) {
return formatMessage(messages.noMatchPassword);
return t(messages.noMatchPassword);
}
return true;
};
@@ -31,7 +31,7 @@ export function PasswordEditForm({ onSave, onClose }) {
return (
<Form onSubmit={handleSubmit} error={getErrorMessage(error)}>
<FormField
label={formatMessage(labels.currentPassword)}
label={t(labels.currentPassword)}
name="currentPassword"
rules={{ required: 'Required' }}
>
@@ -39,28 +39,28 @@ export function PasswordEditForm({ onSave, onClose }) {
</FormField>
<FormField
name="newPassword"
label={formatMessage(labels.newPassword)}
label={t(labels.newPassword)}
rules={{
required: 'Required',
minLength: { value: 8, message: formatMessage(messages.minPasswordLength, { n: '8' }) },
minLength: { value: 8, message: t(messages.minPasswordLength, { n: '8' }) },
}}
>
<PasswordField autoComplete="new-password" />
</FormField>
<FormField
name="confirmPassword"
label={formatMessage(labels.confirmPassword)}
label={t(labels.confirmPassword)}
rules={{
required: formatMessage(labels.required),
minLength: { value: 8, message: formatMessage(messages.minPasswordLength, { n: '8' }) },
required: t(labels.required),
minLength: { value: 8, message: t(messages.minPasswordLength, { n: '8' }) },
validate: samePassword,
}}
>
<PasswordField autoComplete="confirm-password" />
</FormField>
<FormButtons>
<Button onPress={onClose}>{formatMessage(labels.cancel)}</Button>
<FormSubmitButton isDisabled={isPending}>{formatMessage(labels.save)}</FormSubmitButton>
<Button onPress={onClose}>{t(labels.cancel)}</Button>
<FormSubmitButton isDisabled={isPending}>{t(labels.save)}</FormSubmitButton>
</FormButtons>
</Form>
);
@@ -2,7 +2,7 @@ import { SectionHeader } from '@/components/common/SectionHeader';
import { useMessages } from '@/components/hooks';
export function ProfileHeader() {
const { formatMessage, labels } = useMessages();
const { t, labels } = useMessages();
return <SectionHeader title={formatMessage(labels.profile)}></SectionHeader>;
return <SectionHeader title={t(labels.profile)}></SectionHeader>;
}
@@ -7,12 +7,12 @@ import { useMessages } from '@/components/hooks';
import { ProfileSettings } from './ProfileSettings';
export function ProfilePage() {
const { formatMessage, labels } = useMessages();
const { t, labels } = useMessages();
return (
<PageBody>
<Column gap="6">
<PageHeader title={formatMessage(labels.profile)} />
<PageHeader title={t(labels.profile)} />
<Panel>
<ProfileSettings />
</Panel>
@@ -5,7 +5,7 @@ import { PasswordChangeButton } from './PasswordChangeButton';
export function ProfileSettings() {
const { user } = useLoginQuery();
const { formatMessage, labels } = useMessages();
const { t, labels } = useMessages();
const { cloudMode } = useConfig();
if (!user) {
@@ -16,31 +16,31 @@ export function ProfileSettings() {
const renderRole = (value: string) => {
if (value === ROLES.user) {
return formatMessage(labels.user);
return t(labels.user);
}
if (value === ROLES.admin) {
return formatMessage(labels.admin);
return t(labels.admin);
}
if (value === ROLES.viewOnly) {
return formatMessage(labels.viewOnly);
return t(labels.viewOnly);
}
return formatMessage(labels.unknown);
return t(labels.unknown);
};
return (
<Column gap="6">
<Column>
<Label>{formatMessage(labels.username)}</Label>
<Label>{t(labels.username)}</Label>
{username}
</Column>
<Column>
<Label>{formatMessage(labels.role)}</Label>
<Label>{t(labels.role)}</Label>
{renderRole(role)}
</Column>
{!cloudMode && (
<Column>
<Label>{formatMessage(labels.password)}</Label>
<Label>{t(labels.password)}</Label>
<Row>
<PasswordChangeButton />
</Row>