Updated messages.

This commit is contained in:
Mike Cao 2022-02-22 13:31:37 -08:00
parent 7270d95240
commit 7071f5fba5
3 changed files with 6 additions and 12 deletions

View File

@ -1,5 +1,4 @@
import React from 'react'; import { defineMessages } from 'react-intl';
import { defineMessages, FormattedMessage } from 'react-intl';
export const labels = defineMessages({ export const labels = defineMessages({
unknown: { id: 'label.unknown', defaultMessage: 'Unknown' }, unknown: { id: 'label.unknown', defaultMessage: 'Unknown' },
@ -13,5 +12,5 @@ export const devices = defineMessages({
}); });
export function getDeviceMessage(device) { export function getDeviceMessage(device) {
return <FormattedMessage {...(devices[device] || labels.unknown)} />; return devices[device] || labels.unknown;
} }

View File

@ -11,7 +11,7 @@ export default function DevicesTable({ websiteId, ...props }) {
type="device" type="device"
metric={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />} metric={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />}
websiteId={websiteId} websiteId={websiteId}
renderLabel={({ x }) => getDeviceMessage(x)} renderLabel={({ x }) => <FormattedMessage {...getDeviceMessage(x)} />}
/> />
); );
} }

View File

@ -7,7 +7,7 @@ import Tag from 'components/common/Tag';
import Dot from 'components/common/Dot'; import Dot from 'components/common/Dot';
import FilterButtons from 'components/common/FilterButtons'; import FilterButtons from 'components/common/FilterButtons';
import NoData from 'components/common/NoData'; import NoData from 'components/common/NoData';
import { getDeviceMessage } from 'components/messages'; import { getDeviceMessage, labels } from 'components/messages';
import useLocale from 'hooks/useLocale'; import useLocale from 'hooks/useLocale';
import useCountryNames from 'hooks/useCountryNames'; import useCountryNames from 'hooks/useCountryNames';
import { BROWSERS } from 'lib/constants'; import { BROWSERS } from 'lib/constants';
@ -129,15 +129,10 @@ export default function RealtimeLog({ data, websites, websiteId }) {
id="message.log.visitor" id="message.log.visitor"
defaultMessage="Visitor from {country} using {browser} on {os} {device}" defaultMessage="Visitor from {country} using {browser} on {os} {device}"
values={{ values={{
country: ( country: <b>{countryNames[country] || intl.formatMessage(labels.unknown)}</b>,
<b>
{countryNames[country] ||
intl.formatMessage({ id: 'label.unknown', defaultMessage: 'Unknown' })}
</b>
),
browser: <b>{BROWSERS[browser]}</b>, browser: <b>{BROWSERS[browser]}</b>,
os: <b>{os}</b>, os: <b>{os}</b>,
device: <b>{getDeviceMessage(device)}</b>, device: <b>{intl.formatMessage(getDeviceMessage(device))}</b>,
}} }}
/> />
); );