mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
28 lines
861 B
JavaScript
28 lines
861 B
JavaScript
import MetricsTable from './MetricsTable';
|
|
import { percentFilter } from 'lib/filters';
|
|
import useLanguageNames from 'hooks/useLanguageNames';
|
|
import useLocale from 'hooks/useLocale';
|
|
import useMessages from 'hooks/useMessages';
|
|
|
|
export default function LanguagesTable({ websiteId, onDataLoad, ...props }) {
|
|
const { formatMessage, labels } = useMessages();
|
|
const { locale } = useLocale();
|
|
const languageNames = useLanguageNames(locale);
|
|
|
|
const renderLabel = ({ x }) => {
|
|
return <div className={locale}>{languageNames[x?.split('-')[0]] ?? x}</div>;
|
|
};
|
|
|
|
return (
|
|
<MetricsTable
|
|
{...props}
|
|
title={formatMessage(labels.languages)}
|
|
type="language"
|
|
metric={formatMessage(labels.visitors)}
|
|
websiteId={websiteId}
|
|
onDataLoad={data => onDataLoad?.(percentFilter(data))}
|
|
renderLabel={renderLabel}
|
|
/>
|
|
);
|
|
}
|