mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 12:35:38 +01:00
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:
parent
80cad6ea65
commit
50edb71687
247 changed files with 1660 additions and 2194 deletions
|
|
@ -6,7 +6,7 @@ import { DATE_RANGE_CONFIG, DEFAULT_DATE_RANGE_VALUE } from '@/lib/constants';
|
|||
import { getItem, setItem } from '@/lib/storage';
|
||||
|
||||
export function DateRangeSetting() {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { t, labels } = useMessages();
|
||||
const [date, setDate] = useState(getItem(DATE_RANGE_CONFIG) || DEFAULT_DATE_RANGE_VALUE);
|
||||
|
||||
const handleChange = (value: string) => {
|
||||
|
|
@ -27,7 +27,7 @@ export function DateRangeSetting() {
|
|||
placement="bottom start"
|
||||
style={{ minWidth: '250px' }}
|
||||
/>
|
||||
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
||||
<Button onPress={handleReset}>{t(labels.reset)}</Button>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { languages } from '@/lib/lang';
|
|||
|
||||
export function LanguageSetting() {
|
||||
const [search, setSearch] = useState('');
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { t, labels } = useMessages();
|
||||
const { locale, saveLocale } = useLocale();
|
||||
const items = search
|
||||
? Object.keys(languages).filter(n => {
|
||||
|
|
@ -43,7 +43,7 @@ export function LanguageSetting() {
|
|||
))}
|
||||
{!items.length && <ListItem></ListItem>}
|
||||
</Select>
|
||||
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
||||
<Button onPress={handleReset}>{t(labels.reset)}</Button>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { VersionSetting } from './VersionSetting';
|
|||
|
||||
export function PreferenceSettings() {
|
||||
const { user } = useLoginQuery();
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { t, labels } = useMessages();
|
||||
|
||||
if (!user) {
|
||||
return null;
|
||||
|
|
@ -17,23 +17,23 @@ export function PreferenceSettings() {
|
|||
return (
|
||||
<Column gap="6">
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.defaultDateRange)}</Label>
|
||||
<Label>{t(labels.defaultDateRange)}</Label>
|
||||
<DateRangeSetting />
|
||||
</Column>
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.timezone)}</Label>
|
||||
<Label>{t(labels.timezone)}</Label>
|
||||
<TimezoneSetting />
|
||||
</Column>
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.language)}</Label>
|
||||
<Label>{t(labels.language)}</Label>
|
||||
<LanguageSetting />
|
||||
</Column>
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.theme)}</Label>
|
||||
<Label>{t(labels.theme)}</Label>
|
||||
<ThemeSetting />
|
||||
</Column>
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.version)}</Label>
|
||||
<Label>{t(labels.version)}</Label>
|
||||
<VersionSetting />
|
||||
</Column>
|
||||
</Column>
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import { useMessages } from '@/components/hooks';
|
|||
import { PreferenceSettings } from './PreferenceSettings';
|
||||
|
||||
export function PreferencesPage() {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { t, labels } = useMessages();
|
||||
|
||||
return (
|
||||
<PageBody>
|
||||
<Column gap="6">
|
||||
<PageHeader title={formatMessage(labels.preferences)} />
|
||||
<PageHeader title={t(labels.preferences)} />
|
||||
<Panel>
|
||||
<PreferenceSettings />
|
||||
</Panel>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const timezones = Intl.supportedValuesOf('timeZone');
|
|||
|
||||
export function TimezoneSetting() {
|
||||
const [search, setSearch] = useState('');
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { t, labels } = useMessages();
|
||||
const { timezone, saveTimezone } = useTimezone();
|
||||
const items = search
|
||||
? timezones.filter(n => n.toLowerCase().includes(search.toLowerCase()))
|
||||
|
|
@ -39,7 +39,7 @@ export function TimezoneSetting() {
|
|||
))}
|
||||
{!items.length && <ListItem></ListItem>}
|
||||
</Select>
|
||||
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
|
||||
<Button onPress={handleReset}>{t(labels.reset)}</Button>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue