diff --git a/.gitignore b/.gitignore index 715ff703..32d3cbce 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ .DS_Store .idea *.iml +*.log .vscode/* # debug diff --git a/components/common/Dot.js b/components/common/Dot.js index 3f424820..d5dcf914 100644 --- a/components/common/Dot.js +++ b/components/common/Dot.js @@ -4,12 +4,14 @@ import styles from './Dot.module.css'; export default function Dot({ color, size, className }) { return ( -
+
+
+
); } diff --git a/components/common/Dot.module.css b/components/common/Dot.module.css index 9081dc5c..258d6e87 100644 --- a/components/common/Dot.module.css +++ b/components/common/Dot.module.css @@ -1,9 +1,14 @@ +.wrapper { + background: var(--gray50); + margin-right: 10px; + border-radius: 100%; +} + .dot { background: var(--green400); width: 10px; height: 10px; border-radius: 100%; - margin-right: 10px; } .dot.small { diff --git a/components/common/Favicon.js b/components/common/Favicon.js new file mode 100644 index 00000000..07ec696c --- /dev/null +++ b/components/common/Favicon.js @@ -0,0 +1,21 @@ +import React from 'react'; +import styles from './Favicon.module.css'; + +function getHostName(url) { + const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?=]+)/im); + return match && match.length > 1 ? match[1] : null; +} + +export default function Favicon({ domain, ...props }) { + const hostName = domain ? getHostName(domain) : null; + + return hostName ? ( + + ) : null; +} diff --git a/components/common/Favicon.module.css b/components/common/Favicon.module.css new file mode 100644 index 00000000..82c85c42 --- /dev/null +++ b/components/common/Favicon.module.css @@ -0,0 +1,3 @@ +.favicon { + margin-right: 8px; +} diff --git a/components/common/NoData.module.css b/components/common/NoData.module.css index d1c712eb..82f9c3ee 100644 --- a/components/common/NoData.module.css +++ b/components/common/NoData.module.css @@ -1,5 +1,6 @@ .container { color: var(--gray500); + font-size: var(--font-size-normal); position: absolute; top: 50%; left: 50%; diff --git a/components/metrics/BarChart.js b/components/metrics/BarChart.js index a31a6f40..f42cf73f 100644 --- a/components/metrics/BarChart.js +++ b/components/metrics/BarChart.js @@ -1,13 +1,15 @@ import React, { useState, useRef, useEffect } from 'react'; -import ReactTooltip from 'react-tooltip'; import classNames from 'classnames'; import ChartJS from 'chart.js'; +import Legend from 'components/metrics/Legend'; import { formatLongNumber } from 'lib/format'; import { dateFormat } from 'lib/lang'; import useLocale from 'hooks/useLocale'; import useTheme from 'hooks/useTheme'; import { DEFAUL_CHART_HEIGHT, DEFAULT_ANIMATION_DURATION, THEME_COLORS } from 'lib/constants'; import styles from './BarChart.module.css'; +import ChartTooltip from './ChartTooltip'; +import useForceUpdate from '../../hooks/useForceUpdate'; export default function BarChart({ chartId, @@ -27,6 +29,8 @@ export default function BarChart({ const [tooltip, setTooltip] = useState(null); const [locale] = useLocale(); const [theme] = useTheme(); + const forceUpdate = useForceUpdate(); + const colors = { text: THEME_COLORS[theme].gray700, line: THEME_COLORS[theme].gray200, @@ -111,9 +115,7 @@ export default function BarChart({ responsiveAnimationDuration: 0, maintainAspectRatio: false, legend: { - labels: { - fontColor: colors.text, - }, + display: false, }, scales: { xAxes: [ @@ -179,6 +181,10 @@ export default function BarChart({ options.tooltips.custom = renderTooltip; onUpdate(chart.current); + + chart.current.update(); + + forceUpdate(); } useEffect(() => { @@ -202,23 +208,8 @@ export default function BarChart({ >
- - {tooltip ? : null} - + + ); } - -const Tooltip = ({ title, value, label, labelColor }) => ( -
-
-
{title}
-
-
-
-
- {value} {label} -
-
-
-); diff --git a/components/metrics/BarChart.module.css b/components/metrics/BarChart.module.css index cd26d3af..aea86a4c 100644 --- a/components/metrics/BarChart.module.css +++ b/components/metrics/BarChart.module.css @@ -1,43 +1,3 @@ .chart { position: relative; } - -.tooltip { - color: var(--msgColor); - pointer-events: none; - z-index: 1; -} - -.content { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - text-align: center; -} - -.title { - font-size: var(--font-size-xsmall); - font-weight: 600; -} - -.metric { - display: flex; - justify-content: center; - align-items: center; - font-size: var(--font-size-small); - font-weight: 600; -} - -.dot { - position: relative; - overflow: hidden; - border-radius: 100%; - margin-right: 8px; - background: var(--gray50); -} - -.color { - width: 10px; - height: 10px; -} diff --git a/components/metrics/ChartTooltip.js b/components/metrics/ChartTooltip.js new file mode 100644 index 00000000..fb290b66 --- /dev/null +++ b/components/metrics/ChartTooltip.js @@ -0,0 +1,26 @@ +import React from 'react'; +import Dot from 'components/common/Dot'; +import styles from './ChartTooltip.module.css'; +import ReactTooltip from 'react-tooltip'; + +export default function ChartTooltip({ chartId, tooltip }) { + if (!tooltip) { + return null; + } + + const { title, value, label, labelColor } = tooltip; + + return ( + +
+
+
{title}
+
+ + {value} {label} +
+
+
+
+ ); +} diff --git a/components/metrics/ChartTooltip.module.css b/components/metrics/ChartTooltip.module.css new file mode 100644 index 00000000..cd26d3af --- /dev/null +++ b/components/metrics/ChartTooltip.module.css @@ -0,0 +1,43 @@ +.chart { + position: relative; +} + +.tooltip { + color: var(--msgColor); + pointer-events: none; + z-index: 1; +} + +.content { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; +} + +.title { + font-size: var(--font-size-xsmall); + font-weight: 600; +} + +.metric { + display: flex; + justify-content: center; + align-items: center; + font-size: var(--font-size-small); + font-weight: 600; +} + +.dot { + position: relative; + overflow: hidden; + border-radius: 100%; + margin-right: 8px; + background: var(--gray50); +} + +.color { + width: 10px; + height: 10px; +} diff --git a/components/metrics/EventsChart.js b/components/metrics/EventsChart.js index 9a5827b2..68556c96 100644 --- a/components/metrics/EventsChart.js +++ b/components/metrics/EventsChart.js @@ -16,7 +16,7 @@ export default function EventsChart({ websiteId, className, token }) { const { query } = usePageQuery(); const shareToken = useShareToken(); - const { data } = useFetch( + const { data, loading } = useFetch( `/api/website/${websiteId}/events`, { params: { @@ -31,8 +31,10 @@ export default function EventsChart({ websiteId, className, token }) { }, [modified], ); + const datasets = useMemo(() => { if (!data) return []; + if (loading) return data; const map = data.reduce((obj, { x, t, y }) => { if (!obj[x]) { @@ -59,15 +61,7 @@ export default function EventsChart({ websiteId, className, token }) { borderWidth: 1, }; }); - }, [data]); - - function handleCreate(options) { - const legend = { - position: 'bottom', - }; - - options.legend = legend; - } + }, [data, loading]); function handleUpdate(chart) { chart.data.datasets = datasets; @@ -85,9 +79,10 @@ export default function EventsChart({ websiteId, className, token }) { className={className} datasets={datasets} unit={unit} + height={300} records={getDateLength(startDate, endDate, unit)} - onCreate={handleCreate} onUpdate={handleUpdate} + loading={loading} stacked /> ); diff --git a/components/metrics/Legend.js b/components/metrics/Legend.js new file mode 100644 index 00000000..a40ff411 --- /dev/null +++ b/components/metrics/Legend.js @@ -0,0 +1,40 @@ +import React from 'react'; +import classNames from 'classnames'; +import Dot from 'components/common/Dot'; +import useLocale from 'hooks/useLocale'; +import styles from './Legend.module.css'; +import useForceUpdate from '../../hooks/useForceUpdate'; + +export default function Legend({ chart }) { + const [locale] = useLocale(); + const forceUpdate = useForceUpdate(); + + function handleClick(index) { + const meta = chart.getDatasetMeta(index); + + meta.hidden = meta.hidden === null ? !chart.data.datasets[index].hidden : null; + + chart.update(); + + forceUpdate(); + } + + if (!chart?.legend?.legendItems.find(({ text }) => text)) { + return null; + } + + return ( +
+ {chart.legend.legendItems.map(({ text, fillStyle, datasetIndex, hidden }) => ( + + ))} +
+ ); +} diff --git a/components/metrics/Legend.module.css b/components/metrics/Legend.module.css new file mode 100644 index 00000000..faa197e3 --- /dev/null +++ b/components/metrics/Legend.module.css @@ -0,0 +1,21 @@ +.legend { + display: flex; + justify-content: center; + flex-wrap: wrap; + margin-top: 10px; +} + +.label { + display: flex; + align-items: center; + font-size: var(--font-size-xsmall); + cursor: pointer; +} + +.label + .label { + margin-left: 20px; +} + +.hidden { + color: var(--gray400); +} diff --git a/components/metrics/MetricsBar.js b/components/metrics/MetricsBar.js index 33b6eaad..886ee5f0 100644 --- a/components/metrics/MetricsBar.js +++ b/components/metrics/MetricsBar.js @@ -31,7 +31,7 @@ export default function MetricsBar({ websiteId, className }) { }, headers: { [TOKEN_HEADER]: shareToken?.token }, }, - [modified], + [url, modified], ); const formatFunc = format ? formatLongNumber : formatNumber; diff --git a/components/metrics/MetricsTable.js b/components/metrics/MetricsTable.js index 16f61836..25bb4a08 100644 --- a/components/metrics/MetricsTable.js +++ b/components/metrics/MetricsTable.js @@ -1,5 +1,6 @@ import React, { useMemo } from 'react'; import { FormattedMessage } from 'react-intl'; +import firstBy from 'thenby'; import classNames from 'classnames'; import Link from 'components/common/Link'; import Loading from 'components/common/Loading'; @@ -55,9 +56,9 @@ export default function MetricsTable({ if (data) { const items = percentFilter(dataFilter ? dataFilter(data, filterOptions) : data); if (limit) { - return items.filter((e, i) => i < limit); + return items.filter((e, i) => i < limit).sort(firstBy('y', -1).thenBy('x')); } - return items; + return items.sort(firstBy('y', -1).thenBy('x')); } return []; }, [data, error, dataFilter, filterOptions]); diff --git a/components/metrics/PageviewsChart.js b/components/metrics/PageviewsChart.js index 79fe4917..e9d30449 100644 --- a/components/metrics/PageviewsChart.js +++ b/components/metrics/PageviewsChart.js @@ -45,8 +45,6 @@ export default function PageviewsChart({ id: 'metrics.page-views', defaultMessage: 'Page views', }); - - chart.update(); }; if (!data) { diff --git a/components/metrics/RealtimeHeader.module.css b/components/metrics/RealtimeHeader.module.css index 8f948eb1..28aabc3e 100644 --- a/components/metrics/RealtimeHeader.module.css +++ b/components/metrics/RealtimeHeader.module.css @@ -1,3 +1,4 @@ .metrics { display: flex; + margin-bottom: 10px; } diff --git a/components/metrics/RealtimeLog.js b/components/metrics/RealtimeLog.js index c2de333b..18f064e8 100644 --- a/components/metrics/RealtimeLog.js +++ b/components/metrics/RealtimeLog.js @@ -1,5 +1,5 @@ import React, { useMemo, useState } from 'react'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, useIntl } from 'react-intl'; import { FixedSizeList } from 'react-window'; import firstBy from 'thenby'; import { format } from 'date-fns'; @@ -7,6 +7,7 @@ import Icon from 'components/common/Icon'; import Tag from 'components/common/Tag'; import Dot from 'components/common/Dot'; import FilterButtons from 'components/common/FilterButtons'; +import { devices } from 'components/messages'; import useLocale from 'hooks/useLocale'; import useCountryNames from 'hooks/useCountryNames'; import { BROWSERS } from 'lib/constants'; @@ -15,6 +16,7 @@ import Visitor from 'assets/visitor.svg'; import Eye from 'assets/eye.svg'; import { stringToColor } from 'lib/format'; import styles from './RealtimeLog.module.css'; +import NoData from '../common/NoData'; const TYPE_ALL = 0; const TYPE_PAGEVIEW = 1; @@ -28,6 +30,7 @@ const TYPE_ICONS = { }; export default function RealtimeLog({ data, websites }) { + const intl = useIntl(); const [locale] = useLocale(); const countryNames = useCountryNames(locale); const [filter, setFilter] = useState(TYPE_ALL); @@ -116,9 +119,9 @@ export default function RealtimeLog({ data, websites }) { defaultMessage="Visitor from {country} using {browser} on {os} {device}" values={{ country: {countryNames[country]}, - browser: BROWSERS[browser], - os, - device, + browser: {BROWSERS[browser]}, + os: {os}, + device: {intl.formatMessage(devices[device])?.toLowerCase()}, }} /> ); @@ -159,6 +162,7 @@ export default function RealtimeLog({ data, websites }) {
+ {logs?.length === 0 && } {Row} diff --git a/components/metrics/WebsiteChart.js b/components/metrics/WebsiteChart.js index 07ba5161..0f4b48c3 100644 --- a/components/metrics/WebsiteChart.js +++ b/components/metrics/WebsiteChart.js @@ -20,6 +20,7 @@ import { TOKEN_HEADER } from '../../lib/constants'; export default function WebsiteChart({ websiteId, title, + domain, stickyHeader = false, showLink = false, onDataLoad = () => {}, @@ -47,7 +48,7 @@ export default function WebsiteChart({ onDataLoad, headers: { [TOKEN_HEADER]: shareToken?.token }, }, - [modified], + [url, modified], ); const chartData = useMemo(() => { @@ -66,7 +67,7 @@ export default function WebsiteChart({ return (
- +
-
{title}
+
+ + {title} +
diff --git a/components/pages/TestConsole.js b/components/pages/TestConsole.js index fef6c620..b715b4a8 100644 --- a/components/pages/TestConsole.js +++ b/components/pages/TestConsole.js @@ -82,7 +82,12 @@ export default function TestConsole() {
- + Events
diff --git a/components/pages/WebsiteDetails.js b/components/pages/WebsiteDetails.js index 6c310909..81cde3ad 100644 --- a/components/pages/WebsiteDetails.js +++ b/components/pages/WebsiteDetails.js @@ -120,6 +120,7 @@ export default function WebsiteDetails({ websiteId }) { - {data.map(({ website_id, name }) => ( + {data.map(({ website_id, name, domain }) => (
- +
))} {data.length === 0 && ( diff --git a/components/settings/LanguageButton.js b/components/settings/LanguageButton.js index 2d340ed0..cf9db28a 100644 --- a/components/settings/LanguageButton.js +++ b/components/settings/LanguageButton.js @@ -22,6 +22,12 @@ export default function LanguageButton() { rel="stylesheet" /> )} + {locale === 'zh-TW' && ( + + )} {locale === 'ja-JP' && ( ); - const DetailsLink = ({ website_id, name }) => ( + const DetailsLink = ({ website_id, name, domain }) => ( + {name} ); diff --git a/lang-ignore.json b/lang-ignore.json new file mode 100644 index 00000000..56042b8d --- /dev/null +++ b/lang-ignore.json @@ -0,0 +1,21 @@ +{ + "de-DE": [ + "label.administrator", + "label.name", + "label.domain", + "metrics.device.desktop", + "metrics.device.laptop", + "metrics.device.tablet", + "metrics.referrers" + ], + "fr-FR": ["metrics.actions", "metrics.pages"], + "nb-NO": ["label.administrator", "label.dashboard"], + "nl-NL": [ + "label.administrator", + "label.websites", + "metrics.browsers", + "metrics.device.desktop", + "metrics.device.laptop", + "metrics.device.tablet" + ] +} diff --git a/lang/de-DE.json b/lang/de-DE.json index 9ece852f..ac9ac040 100644 --- a/lang/de-DE.json +++ b/lang/de-DE.json @@ -65,7 +65,7 @@ "message.get-tracking-code": "Erstelle Tracking Kennung", "message.go-to-settings": "Zu den Einstellungen", "message.incorrect-username-password": "Falsches Passwort oder Benutzername.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", + "message.log.visitor": "Besucher aus {country} benutzt {browser} auf {os} {device}", "message.new-version-available": "Eine neue Version umami {version} ist verfügbar!", "message.no-data-available": "Keine Daten vorhanden.", "message.no-websites-configured": "Es ist keine Webseite vorhanden.", diff --git a/lang/es-MX.json b/lang/es-MX.json index 47cec6f0..4d57ac3c 100644 --- a/lang/es-MX.json +++ b/lang/es-MX.json @@ -3,22 +3,22 @@ "label.add-account": "Agregar usuario", "label.add-website": "Agregar sitio", "label.administrator": "Administrador", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Todos", + "label.all-websites": "Todos los sitios", "label.back": "Atrás", "label.cancel": "Cancelar", "label.change-password": "Cambiar contraseña", "label.confirm-password": "Confirmar contraseña", "label.copy-to-clipboard": "Copiar al portapapeles", "label.current-password": "Contraseña actual", - "label.custom-range": "Custom range", + "label.custom-range": "Intervalo personalizado", "label.dashboard": "Panel de control", - "label.date-range": "Date range", - "label.default-date-range": "Default date range", + "label.date-range": "Fechas", + "label.default-date-range": "Intervalo por defecto", "label.delete": "Eliminar", "label.delete-account": "Eliminar usuario", "label.delete-website": "Eliminar sitio", - "label.dismiss": "Dismiss", + "label.dismiss": "Ignorar", "label.domain": "Dominio", "label.edit": "Editar", "label.edit-account": "Editar usuario", @@ -37,22 +37,22 @@ "label.password": "Contraseña", "label.passwords-dont-match": "Las contraseñas no coinciden", "label.profile": "Perfil", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", - "label.refresh": "Refresh", + "label.realtime": "Tiempo real", + "label.realtime-logs": "Registros en tiempo real", + "label.refresh": "Actualizar", "label.required": "Requerido", - "label.reset": "Reset", + "label.reset": "Reiniciar", "label.save": "Guardar", "label.settings": "Configuraciones", "label.share-url": "Compartir URL", - "label.single-day": "Single day", + "label.single-day": "Dia", "label.this-month": "Este mes", "label.this-week": "Esta semana", "label.this-year": "Este año", - "label.timezone": "Timezone", + "label.timezone": "Zona horaria", "label.today": "Hoy", "label.tracking-code": "Código de rastreo", - "label.unknown": "Unknown", + "label.unknown": "Desconocida", "label.username": "Nombre de usuario", "label.view-details": "Ver detalles", "label.websites": "Sitios", @@ -65,8 +65,8 @@ "message.get-tracking-code": "Obtener código de rastreo", "message.go-to-settings": "Ir a la configuración", "message.incorrect-username-password": "Nombre de usuario o contraseña incorrectos.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", - "message.new-version-available": "A new version of umami {version} is available!", + "message.log.visitor": "Visitante desde {country} usando {browser} en {os} {device}", + "message.new-version-available": "Una nueva versíon de umami {version} esta disponible!", "message.no-data-available": "Sin información disponible.", "message.no-websites-configured": "No tienes ningún sitio configurado.", "message.page-not-found": "Page not found", @@ -83,7 +83,7 @@ "metrics.device.desktop": "Desktop", "metrics.device.laptop": "Laptop", "metrics.device.mobile": "Mobile", - "metrics.device.tablet": "Tablet", + "metrics.device.tablet": "Tableta", "metrics.devices": "Dispositivos", "metrics.events": "Eventos", "metrics.filter.combined": "Combinado", diff --git a/lang/fo-FO.json b/lang/fo-FO.json index e103ca47..c358be1e 100644 --- a/lang/fo-FO.json +++ b/lang/fo-FO.json @@ -1,24 +1,24 @@ { "label.accounts": "Brúkarar", "label.add-account": "Ger brúkara", - "label.add-website": "Legg heimasíðu avtrat", - "label.administrator": "Administrator", - "label.all": "All", - "label.all-websites": "All websites", + "label.add-website": "Legg heimasíðu afturat", + "label.administrator": "Fyrisitari", + "label.all": "Alt", + "label.all-websites": "Allar heimasíður", "label.back": "Aftur", "label.cancel": "Strika", "label.change-password": "Skift loyniorð", "label.confirm-password": "Vátta loyniorð", - "label.copy-to-clipboard": "Kopier til clipboard", + "label.copy-to-clipboard": "Avrita til setiðborð", "label.current-password": "Núverandi loyniorð", "label.custom-range": "Tillaga spenni", "label.dashboard": "Yvirlitsskíggi", "label.date-range": "Vel dato", - "label.default-date-range": "Standard dato", + "label.default-date-range": "Forsett dato", "label.delete": "Sletta", "label.delete-account": "Sletta brúkara", "label.delete-website": "Sletta heimasíðu", - "label.dismiss": "Dismiss", + "label.dismiss": "Lat fara", "label.domain": "Økisnavn", "label.edit": "Ger broyting", "label.edit-account": "Broyt brúkara", @@ -27,7 +27,7 @@ "label.invalid": "Ógilda", "label.invalid-domain": "Ógilt økisnavn", "label.last-days": "Seinastu {x} dagarnar", - "label.last-hours": "Seinastu {x} tímanar", + "label.last-hours": "Seinastu {x} tímarnar", "label.logged-in-as": "Ritaður inn sum {username}", "label.login": "Rita inn", "label.logout": "Rita út", @@ -36,11 +36,11 @@ "label.new-password": "Nýtt loyniorð", "label.password": "Loyniorð", "label.passwords-dont-match": "Loyniorðini eru ikki eins", - "label.profile": "Brúkari", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.profile": "Vangi", + "label.realtime": "Beinleiðis", + "label.realtime-logs": "Beinleiðis skrá", "label.refresh": "Endurskapa", - "label.required": "Krav", + "label.required": "Kravt", "label.reset": "Nulstilla", "label.save": "Goym", "label.settings": "Stillingar", @@ -54,25 +54,25 @@ "label.tracking-code": "Spori kota", "label.unknown": "Ókent", "label.username": "Brúkaranavn", - "label.view-details": "Vís upplýsingar", + "label.view-details": "Vís frágreiðing", "label.websites": "Heimasíður", "message.active-users": "{x} í løtuni {x, plural, one {vitjandi} other { vitjandi }}", - "message.confirm-delete": "Ert tú sikkur at tú ynskir at sletta {target}?", - "message.copied": "Kopiera!", - "message.delete-warning": "Øll data ið er knýtt at verður eisini sletta.", + "message.confirm-delete": "Ert tú sikkur at tú ynskir at strika {target}?", + "message.copied": "Avrita!", + "message.delete-warning": "Øll data ið er knýtt at verður eisini strika.", "message.failure": "Okkurt bleiv gali.", "message.get-share-url": "Fá leinku sum tú kanst deila", "message.get-tracking-code": "Fá sporings kotu", "message.go-to-settings": "Far til stillingar", "message.incorrect-username-password": "Skeivt brúkaranavn/loyniorð.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", - "message.new-version-available": "A new version of umami {version} is available!", + "message.log.visitor": "Vitjandi frá {country} brúkar {browser} á {os} {device}", + "message.new-version-available": "Ein nýggj útgava av umami {version} er tøkt!", "message.no-data-available": "Einki data tøk.", "message.no-websites-configured": "Tú hevur ongar heimasíður stillaða til.", "message.page-not-found": "Síðan bleiv ikki funnin.", "message.powered-by": "Powered by {name}", "message.save-success": "Goymt.", - "message.share-url": "Hetta er tann almenna leinkan av {target}.", + "message.share-url": "Hettar er tann almenna leinkan av {target}.", "message.track-stats": "Fyri at spora hagtøl fyri {target}, koyr kotuna í {head} partin á tínari heimasíðu.", "message.type-delete": "Skriva {delete} í feltið fyri at vátta", "metrics.actions": "Gerðir", @@ -94,6 +94,6 @@ "metrics.pages": "Síðir", "metrics.referrers": "Framsendingar", "metrics.unique-visitors": "Einsýna vitjanir", - "metrics.views": "Vitjanir", + "metrics.views": "Sýningar", "metrics.visitors": "Vitjandi" } diff --git a/lang/fr-FR.json b/lang/fr-FR.json index b8676948..622c760f 100644 --- a/lang/fr-FR.json +++ b/lang/fr-FR.json @@ -3,22 +3,22 @@ "label.add-account": "Ajouter un compte", "label.add-website": "Ajouter un site", "label.administrator": "Administrateur", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Tout", + "label.all-websites": "Tous les sites web", "label.back": "Retour", "label.cancel": "Annuler", "label.change-password": "Changer le mot de passe", "label.confirm-password": "Confirmation du mot de passe", "label.copy-to-clipboard": "Copier dans le presse papier", "label.current-password": "Mot de passe actuel", - "label.custom-range": "Plage personnalisée", + "label.custom-range": "Intervalle personnalisé", "label.dashboard": "Tableau de bord", - "label.date-range": "Date range", - "label.default-date-range": "Default date range", + "label.date-range": "Intervalle", + "label.default-date-range": "Intervalle par défaut", "label.delete": "Supprimer", "label.delete-account": "Supprimer le compte", - "label.delete-website": "Suprimer le site", - "label.dismiss": "Dismiss", + "label.delete-website": "Supprimer le site", + "label.dismiss": "Ignorer", "label.domain": "Domaine", "label.edit": "Modifier", "label.edit-account": "Modifier le compte", @@ -36,28 +36,28 @@ "label.new-password": "Nouveau mot de passe", "label.password": "Mot de passe", "label.passwords-dont-match": "Les mots de passe ne correspondent pas", - "label.profile": "Profile", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", - "label.refresh": "Refresh", + "label.profile": "Profil", + "label.realtime": "Temps réel", + "label.realtime-logs": "Logs en temps réel", + "label.refresh": "Rafraîchir", "label.required": "Requis", - "label.reset": "Reset", + "label.reset": "Réinitialiser", "label.save": "Sauvegarder", "label.settings": "Paramètres", "label.share-url": "Partager l'URL", - "label.single-day": "Single day", + "label.single-day": "Journée", "label.this-month": "Ce mois ci", "label.this-week": "Cette semaine", "label.this-year": "Cette année", - "label.timezone": "Timezone", + "label.timezone": "Fuseau horaire", "label.today": "Aujourd'hui", "label.tracking-code": "Code de suivi", - "label.unknown": "Unknown", + "label.unknown": "Inconnu", "label.username": "Nom d'utilisateur", "label.view-details": "Voir les details", "label.websites": "Sites", "message.active-users": "{x} {x, plural, one {visiteur} other {visiteurs}} actuellement", - "message.confirm-delete": "Êtes-vous sur de vouloir supprimer {target}?", + "message.confirm-delete": "Êtes-vous sûr de vouloir supprimer {target} ?", "message.copied": "Copié !", "message.delete-warning": "Toutes les données associées seront également supprimées.", "message.failure": "Un problème est survenu.", @@ -65,8 +65,8 @@ "message.get-tracking-code": "Obtenez le code de suivi", "message.go-to-settings": "Aller aux paramètres", "message.incorrect-username-password": "nom d'utilisateurs/mot de passe incorrect.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", - "message.new-version-available": "A new version of umami {version} is available!", + "message.log.visitor": "Visiteur de {country} utilisant {browser} sur {os} {device}", + "message.new-version-available": "Une nouvelle version de umami {version} est disponible !", "message.no-data-available": "Pas de données disponibles.", "message.no-websites-configured": "Vous n'avez configuré aucun site Web.", "message.page-not-found": "Page non trouvée.", @@ -80,10 +80,10 @@ "metrics.bounce-rate": "Taux de rebond", "metrics.browsers": "Navigateurs", "metrics.countries": "Pays", - "metrics.device.desktop": "Desktop", - "metrics.device.laptop": "Laptop", - "metrics.device.mobile": "Mobile", - "metrics.device.tablet": "Tablet", + "metrics.device.desktop": "Ordinateur", + "metrics.device.laptop": "Portable", + "metrics.device.mobile": "Téléphone", + "metrics.device.tablet": "Tablette", "metrics.devices": "Appareils", "metrics.events": "Événements", "metrics.filter.combined": "Combiné", diff --git a/lang/id-ID.json b/lang/id-ID.json index 37dd600c..99fd0fe5 100644 --- a/lang/id-ID.json +++ b/lang/id-ID.json @@ -3,8 +3,8 @@ "label.add-account": "Tambah akun", "label.add-website": "Tambah situs web", "label.administrator": "Pengelola", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Semua", + "label.all-websites": "Semua website", "label.back": "Kembali", "label.cancel": "Batal", "label.change-password": "Ganti kata sandi", @@ -14,7 +14,7 @@ "label.custom-range": "Rentang khusus", "label.dashboard": "Dasbor", "label.date-range": "Rentang tanggal", - "label.default-date-range": "Rentang tanggal default", + "label.default-date-range": "Rentang tanggal bawaan", "label.delete": "Hapus", "label.delete-account": "Hapus akun", "label.delete-website": "Hapus situs web", @@ -37,8 +37,8 @@ "label.password": "Kata sandi", "label.passwords-dont-match": "Kata sandi tidak cocok", "label.profile": "Profil", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.realtime": "Waktu nyata", + "label.realtime-logs": "Log waktu nyata", "label.refresh": "Segarkan", "label.required": "Wajib", "label.reset": "Atur ulang", @@ -65,7 +65,7 @@ "message.get-tracking-code": "Dapatkan kode pelacakan", "message.go-to-settings": "Pergi ke pengaturan", "message.incorrect-username-password": "Nama pengguna/kata sandi salah.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", + "message.log.visitor": "Pengunjung dari {country} dengan {browser} di {device} {os}", "message.new-version-available": "Versi terbaru umami {version} telah tersedia!", "message.no-data-available": "Tidak ada data.", "message.no-websites-configured": "Anda tidak memiliki situs web yang dikonfigurasi.", @@ -77,8 +77,8 @@ "message.type-delete": "Ketikkan {delete} pada kotak di bawah untuk konfirmasi.", "metrics.actions": "Aksi", "metrics.average-visit-time": "Waktu kunjungan rata-rata", - "metrics.bounce-rate": "Tingkat bouncing", - "metrics.browsers": "Browser", + "metrics.bounce-rate": "Rasio pentalan", + "metrics.browsers": "Peramban", "metrics.countries": "Negara", "metrics.device.desktop": "Desktop", "metrics.device.laptop": "Laptop", @@ -88,7 +88,7 @@ "metrics.events": "Perihal", "metrics.filter.combined": "Gabungan", "metrics.filter.domain-only": "Hanya domain", - "metrics.filter.raw": "Raw", + "metrics.filter.raw": "Mentah", "metrics.operating-systems": "Sistem Operasi", "metrics.page-views": "Tampilan halaman", "metrics.pages": "Halaman", diff --git a/lang/nb-NO.json b/lang/nb-NO.json index 6cc8af0c..75f9020a 100644 --- a/lang/nb-NO.json +++ b/lang/nb-NO.json @@ -3,8 +3,8 @@ "label.add-account": "Legg til konto", "label.add-website": "Legg til nettsted", "label.administrator": "Administrator", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Alle", + "label.all-websites": "Alle nettsteder", "label.back": "Tilbake", "label.cancel": "Avvis", "label.change-password": "Bytt passord", @@ -37,8 +37,8 @@ "label.password": "Passord", "label.passwords-dont-match": "Passordene er ikke like", "label.profile": "Profil", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.realtime": "Sanntid", + "label.realtime-logs": "Sanntidslogger", "label.refresh": "Oppdater", "label.required": "Påkrevd", "label.reset": "Nullstill", @@ -65,7 +65,7 @@ "message.get-tracking-code": "Få sporingskode", "message.go-to-settings": "Gå til innstillinger", "message.incorrect-username-password": "Ugyldig brukernavn/passord.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", + "message.log.visitor": "Besøkende fra {country} med {browser} på {os} {device}", "message.new-version-available": "En ny versjon av umami {version} er tilgjengelig!", "message.no-data-available": "Ingen data tilgjengelig.", "message.no-websites-configured": "Du har ikke satt opp noen nettsteder.", @@ -80,8 +80,8 @@ "metrics.bounce-rate": "Avvisningsfrekvens", "metrics.browsers": "Nettlesere", "metrics.countries": "Land", - "metrics.device.desktop": "Desktop", - "metrics.device.laptop": "Laptop", + "metrics.device.desktop": "Stasjonær", + "metrics.device.laptop": "Bærbar", "metrics.device.mobile": "Mobiltelefon", "metrics.device.tablet": "Nettbrett", "metrics.devices": "Enheter", diff --git a/lang/nl-NL.json b/lang/nl-NL.json index 518ffaa8..56eaf90a 100644 --- a/lang/nl-NL.json +++ b/lang/nl-NL.json @@ -3,8 +3,8 @@ "label.add-account": "Account toevoegen", "label.add-website": "Website toevoegen", "label.administrator": "Administrator", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Alles", + "label.all-websites": "Alle websites", "label.back": "Terug", "label.cancel": "Annuleren", "label.change-password": "Wachtwoord wijzigen", @@ -37,8 +37,8 @@ "label.password": "Wachtwoord", "label.passwords-dont-match": "Wachtwoorden komen niet overeen", "label.profile": "Profiel", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.realtime": "Actueel", + "label.realtime-logs": "Actueel logboek", "label.refresh": "Vernieuwen", "label.required": "Verplicht", "label.reset": "Resetten", @@ -51,7 +51,7 @@ "label.this-year": "Dit jaar", "label.timezone": "Tijdzone", "label.today": "Vandaag", - "label.tracking-code": "Tracking code", + "label.tracking-code": "Volgcode", "label.unknown": "Onbekend", "label.username": "Gebruikersnaam", "label.view-details": "Meer details", @@ -65,7 +65,7 @@ "message.get-tracking-code": "Tracking code", "message.go-to-settings": "Naar instellingen", "message.incorrect-username-password": "Incorrecte gebruikersnaam/wachtwoord.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", + "message.log.visitor": "Bezoeker uit {country} met {browser} op een {os} {device}", "message.new-version-available": "Een nieuwe versie van umami {version} is beschikbaar!", "message.no-data-available": "Geen gegevens beschikbaar.", "message.no-websites-configured": "Je hebt geen websites ingesteld.", diff --git a/lang/tr-TR.json b/lang/tr-TR.json index b223f3ed..b821d5dc 100644 --- a/lang/tr-TR.json +++ b/lang/tr-TR.json @@ -3,8 +3,8 @@ "label.add-account": "Hesap ekle", "label.add-website": "Web sitesi ekle", "label.administrator": "Yönetici", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Tümü", + "label.all-websites": "Tüm web siteleri", "label.back": "Geri", "label.cancel": "İptal", "label.change-password": "Şifre değiştir", @@ -18,13 +18,13 @@ "label.delete": "Sil", "label.delete-account": "Hesabı sil", "label.delete-website": "Web sitesini sil", - "label.dismiss": "Dismiss", + "label.dismiss": "Reddet", "label.domain": "Alan adı", "label.edit": "Düzenle", "label.edit-account": "Hesabı düzenle", "label.edit-website": "Web sitesini düzenle", "label.enable-share-url": "Anonim paylaşım URL'i aktif", - "label.invalid": "Geçeriz", + "label.invalid": "Geçersiz", "label.invalid-domain": "Geçersiz alan adı", "label.last-days": "Son {x} gün", "label.last-hours": "Son {x} saat", @@ -37,8 +37,8 @@ "label.password": "Parola", "label.passwords-dont-match": "Parolalar uyuşmuyor", "label.profile": "Profil", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.realtime": "Gerçek Zamanlı", + "label.realtime-logs": "Gerçek zamanlı kayıtlar", "label.refresh": "Yenile", "label.required": "Zorunlu alan", "label.reset": "Sıfırla", @@ -65,8 +65,8 @@ "message.get-tracking-code": "İzleme kodunu al", "message.go-to-settings": "Ayarlara git", "message.incorrect-username-password": "Hatalı kullanıcı adı ya da parola.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", - "message.new-version-available": "A new version of umami {version} is available!", + "message.log.visitor": "Yeni ziyaretçi: {country}, {os}, {device}, {browser}", + "message.new-version-available": "umami'nin yeni bir versiyonu ({version}) mevcut!", "message.no-data-available": "Henüz hiç veri yok.", "message.no-websites-configured": "Henüz hiç web sitesi tanımlamadınız", "message.page-not-found": "Sayfa bulunamadı.", @@ -96,4 +96,4 @@ "metrics.unique-visitors": "Tekil kullanıcı", "metrics.views": "Görüntüleme", "metrics.visitors": "Ziyaretçi" -} +} \ No newline at end of file diff --git a/lang/uk-UA.json b/lang/uk-UA.json index f1631d30..cb504fe1 100644 --- a/lang/uk-UA.json +++ b/lang/uk-UA.json @@ -1,10 +1,10 @@ { "label.accounts": "Облікові записи", "label.add-account": "Додати обліковий запис", - "label.add-website": "Додати website", + "label.add-website": "Додати вебсайт", "label.administrator": "Адміністратор", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "Всі", + "label.all-websites": "Всі вебсайти", "label.back": "Назад", "label.cancel": "Відмінити", "label.change-password": "Змінити пароль", @@ -17,12 +17,12 @@ "label.default-date-range": "Діапазон дат за умовчанням", "label.delete": "Видалити", "label.delete-account": "Видалити обліковий запис", - "label.delete-website": "Видалити веб-сайт", + "label.delete-website": "Видалити вебсайт", "label.dismiss": "Відхилити", "label.domain": "Домен", "label.edit": "Редагувати", "label.edit-account": "Редагувати обліковий запис", - "label.edit-website": "Редагувати веб-сайт", + "label.edit-website": "Редагувати вебсайт", "label.enable-share-url": "Дозволити ділитися посиланням", "label.invalid": "Некоректний", "label.invalid-domain": "Некоректний домен", @@ -37,8 +37,8 @@ "label.password": "Пароль", "label.passwords-dont-match": "Паролі не співпадають", "label.profile": "Профіль", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.realtime": "У реальному часі", + "label.realtime-logs": "Логи у реальному часі", "label.refresh": "Оновити", "label.required": "Обов'язкове", "label.reset": "Скинути", @@ -55,7 +55,7 @@ "label.unknown": "Невідомо", "label.username": "Ім'я користувача", "label.view-details": "Переглянути деталі", - "label.websites": "Веб-сайти", + "label.websites": "Вебсайти", "message.active-users": "{x} поточних відвідувачів", "message.confirm-delete": "Ви впевнені, що бажаєте видалити {target}?", "message.copied": "Скопійовано!", @@ -65,15 +65,15 @@ "message.get-tracking-code": "Отримати код для відслідковування", "message.go-to-settings": "Перейти до налаштувань", "message.incorrect-username-password": "Невірне ім'я користувача або пароль.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", + "message.log.visitor": "Відвідувач з {country} використовуючи {browser} на {os} {device}", "message.new-version-available": "Нова версія umami {version} доступна!", "message.no-data-available": "Немає даних.", - "message.no-websites-configured": "У вас немає налаштованих веб-сайтів.", + "message.no-websites-configured": "У вас немає налаштованих вебсайтів.", "message.page-not-found": "Сторінку не знайдено.", "message.powered-by": "На базі {name}", "message.save-success": "Збережено успішно.", "message.share-url": "Це публічне посилання для {target}.", - "message.track-stats": "Або відслідковувати статистику для {target}, розмістіть наступний код у {head} секції вашого веб-сайту.", + "message.track-stats": "Або відслідковувати статистику для {target}, розмістіть наступний код у {head} секції вашого вебсайту.", "message.type-delete": "Введіть {delete} у полі нижче щоб підтвердити.", "metrics.actions": "Дії", "metrics.average-visit-time": "Середній час візиту", diff --git a/lang/zh-CN.json b/lang/zh-CN.json index 303fe9e4..101cd6cd 100644 --- a/lang/zh-CN.json +++ b/lang/zh-CN.json @@ -3,8 +3,8 @@ "label.add-account": "添加账户", "label.add-website": "添加网站", "label.administrator": "管理员", - "label.all": "All", - "label.all-websites": "All websites", + "label.all": "所有", + "label.all-websites": "全部网站", "label.back": "返回", "label.cancel": "取消", "label.change-password": "更新密码", @@ -18,7 +18,7 @@ "label.delete": "删除", "label.delete-account": "删除账户", "label.delete-website": "删除网站", - "label.dismiss": "Dismiss", + "label.dismiss": "关闭", "label.domain": "域名", "label.edit": "编辑", "label.edit-account": "编辑账户", @@ -37,8 +37,8 @@ "label.password": "密码", "label.passwords-dont-match": "密码不一致", "label.profile": "个人资料", - "label.realtime": "Realtime", - "label.realtime-logs": "Realtime logs", + "label.realtime": "实时", + "label.realtime-logs": "实时日志", "label.refresh": "刷新", "label.required": "必填", "label.reset": "重置", @@ -65,8 +65,8 @@ "message.get-tracking-code": "获得跟踪代码", "message.go-to-settings": "去设置", "message.incorrect-username-password": "用户名密码不正确.", - "message.log.visitor": "Visitor from {country} using {browser} on {os} {device}", - "message.new-version-available": "A new version of umami {version} is available!", + "message.log.visitor": "来自 {country} 的访客在搭载 {os} 的 {device} 上使用 {browser} 进行访问.", + "message.new-version-available": "umami 有新版本 {version} 发布啦!", "message.no-data-available": "无可用数据.", "message.no-websites-configured": "你还没有设置任何网站.", "message.page-not-found": "网页未找到.", diff --git a/lang/zh-TW.json b/lang/zh-TW.json new file mode 100644 index 00000000..c979c89b --- /dev/null +++ b/lang/zh-TW.json @@ -0,0 +1,99 @@ +{ + "label.accounts": "帳戶", + "label.add-account": "增加帳戶", + "label.add-website": "增加網站", + "label.administrator": "管理員", + "label.all": "所有", + "label.all-websites": "全部網站", + "label.back": "返回", + "label.cancel": "取消", + "label.change-password": "更新密碼", + "label.confirm-password": "確認密碼", + "label.copy-to-clipboard": "複製", + "label.current-password": "目前密碼", + "label.custom-range": "自定義時段", + "label.dashboard": "管理面板", + "label.date-range": "多日", + "label.default-date-range": "默認日期範圍", + "label.delete": "刪除", + "label.delete-account": "刪除帳戶", + "label.delete-website": "删除網站", + "label.dismiss": "關閉", + "label.domain": "域名", + "label.edit": "編輯", + "label.edit-account": "編輯帳戶", + "label.edit-website": "編輯網站", + "label.enable-share-url": "啟用分享連結", + "label.invalid": "無效輸入", + "label.invalid-domain": "無效域名", + "label.last-days": "最近 {x} 天", + "label.last-hours": "最近 {x} 小時", + "label.logged-in-as": "用戶名: {username}", + "label.login": "登入", + "label.logout": "退出", + "label.more": "更多", + "label.name": "名字", + "label.new-password": "新密碼", + "label.password": "密碼", + "label.passwords-dont-match": "密碼不一致", + "label.profile": "個人資料", + "label.realtime": "實時", + "label.realtime-logs": "實時日志", + "label.refresh": "刷新", + "label.required": "必填", + "label.reset": "重置", + "label.save": "保存", + "label.settings": "設置", + "label.share-url": "分享連結", + "label.single-day": "單日", + "label.this-month": "本月", + "label.this-week": "本週", + "label.this-year": "今年", + "label.timezone": "時區", + "label.today": "今天", + "label.tracking-code": "追蹤代碼", + "label.unknown": "未知", + "label.username": "用户名", + "label.view-details": "查看更多", + "label.websites": "網站", + "message.active-users": "当前線上 {x} 人", + "message.confirm-delete": "你確定要删除{target}嗎?", + "message.copied": "複製成功!", + "message.delete-warning": "所有相關數據將會被删除.", + "message.failure": "出現錯誤.", + "message.get-share-url": "獲得分享連結", + "message.get-tracking-code": "獲得追蹤代碼", + "message.go-to-settings": "去設定", + "message.incorrect-username-password": "用户名或密碼不正確.", + "message.log.visitor": "自 {country} 的訪客在搭載 {os} 的 {device} 上使用 {browser} 進行訪問.", + "message.new-version-available": "umami 有新版本 {version} 發佈啦!", + "message.no-data-available": "無可用數據.", + "message.no-websites-configured": "目前無任何網站設定.", + "message.page-not-found": "網頁未找到.", + "message.powered-by": "運行 {name}", + "message.save-success": "成功保存.", + "message.share-url": "這是 {target} 的分享連結.", + "message.track-stats": "將以下代碼放入被設定網站的{head}部分来收集{target}的資料.", + "message.type-delete": "在下方空格輸入{delete}確認", + "metrics.actions": "用戶行為", + "metrics.average-visit-time": "平均訪問時間", + "metrics.bounce-rate": "跳出率", + "metrics.browsers": "瀏覽器", + "metrics.countries": "國家", + "metrics.device.desktop": "桌機", + "metrics.device.laptop": "筆記本", + "metrics.device.mobile": "手機", + "metrics.device.tablet": "平板", + "metrics.devices": "裝置", + "metrics.events": "行為類別", + "metrics.filter.combined": "總和", + "metrics.filter.domain-only": "僅域名", + "metrics.filter.raw": "原始", + "metrics.operating-systems": "操作系统", + "metrics.page-views": "網頁流量", + "metrics.pages": "網頁", + "metrics.referrers": "指入域名", + "metrics.unique-visitors": "獨立訪客", + "metrics.views": "页面流量", + "metrics.visitors": "獨立訪客" +} \ No newline at end of file diff --git a/lib/filters.js b/lib/filters.js index 7fd5d833..d4853618 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -1,4 +1,3 @@ -import firstBy from 'thenby'; import { BROWSERS } from './constants'; import { removeTrailingSlash, removeWWW, getDomainName } from './url'; @@ -43,9 +42,7 @@ export const urlFilter = (data, { raw }) => { return obj; }, {}); - return Object.keys(map) - .map(key => ({ x: key, y: map[key] })) - .sort(firstBy('y', -1).thenBy('x')); + return Object.keys(map).map(key => ({ x: key, y: map[key] })); }; export const refFilter = (data, { domain, domainOnly, raw }) => { @@ -70,7 +67,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => { } if (domainOnly && hostname) { - return hostname; + return removeWWW(hostname); } if (!origin || origin === 'null') { @@ -113,9 +110,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => { return obj; }, {}); - return Object.keys(map) - .map(key => ({ x: key, y: map[key], w: links[key] })) - .sort(firstBy('y', -1).thenBy('x')); + return Object.keys(map).map(key => ({ x: key, y: map[key], w: links[key] })); }; export const browserFilter = data => diff --git a/lib/lang.js b/lib/lang.js index 4b1841f5..25fcb5d7 100644 --- a/lib/lang.js +++ b/lib/lang.js @@ -3,6 +3,7 @@ import { enUS, nl, zhCN, + zhTW, tr, ru, de, @@ -22,6 +23,7 @@ import { import enMessages from 'lang-compiled/en-US.json'; import nlMessages from 'lang-compiled/nl-NL.json'; import zhCNMessages from 'lang-compiled/zh-CN.json'; +import zhTWMessages from 'lang-compiled/zh-TW.json'; import trTRMessages from 'lang-compiled/tr-TR.json'; import ruRUMessages from 'lang-compiled/ru-RU.json'; import deDEMessages from 'lang-compiled/de-DE.json'; @@ -44,6 +46,7 @@ export const messages = { 'en-US': enMessages, 'nl-NL': nlMessages, 'zh-CN': zhCNMessages, + 'zh-TW': zhTWMessages, 'de-DE': deDEMessages, 'ru-RU': ruRUMessages, 'tr-TR': trTRMessages, @@ -67,6 +70,7 @@ export const dateLocales = { 'en-US': enUS, 'nl-NL': nl, 'zh-CN': zhCN, + 'zh-TW': zhTW, 'de-DE': de, 'da-DK': da, 'ru-RU': ru, @@ -88,6 +92,7 @@ export const dateLocales = { export const menuOptions = [ { label: '中文', value: 'zh-CN', display: 'cn' }, + { label: '中文(繁體)', value: 'zh-TW', display: 'tw' }, { label: 'Dansk', value: 'da-DK', display: 'da' }, { label: 'Deutsch', value: 'de-DE', display: 'de' }, { label: 'English', value: 'en-US', display: 'en' }, diff --git a/package.json b/package.json index 1f26ba1e..b6dea4b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "umami", - "version": "0.96.0", + "version": "1.0.0", "description": "A simple, fast, website analytics alternative to Google Analytics. ", "author": "Mike Cao ", "license": "MIT", @@ -76,6 +76,7 @@ "maxmind": "^4.3.0", "moment-timezone": "^0.5.31", "next": "^9.5.5", + "prompts": "2.3.2", "react": "^16.13.1", "react-dom": "^16.13.1", "react-intl": "^5.8.4", diff --git a/scripts/change-password.js b/scripts/change-password.js new file mode 100644 index 00000000..ff294bc3 --- /dev/null +++ b/scripts/change-password.js @@ -0,0 +1,98 @@ +require('dotenv').config(); +const bcrypt = require('bcrypt'); +const chalk = require('chalk'); +const prompts = require('prompts'); +const { PrismaClient } = require('@prisma/client'); + +const prisma = new PrismaClient(); +const SALT_ROUNDS = 10; + +const runQuery = async query => { + return query.catch(e => { + throw e; + }); +}; + +const updateAccountByUsername = (username, data) => { + return runQuery( + prisma.account.update({ + where: { + username, + }, + data, + }), + ); +}; + +const hashPassword = password => { + return bcrypt.hash(password, SALT_ROUNDS); +}; + +const changePassword = async (username, newPassword) => { + const password = await hashPassword(newPassword); + return updateAccountByUsername(username, { password }); +}; + +const getUsernameAndPassword = async () => { + let [username, password] = process.argv.slice(2); + if (username && password) { + return { username, password }; + } + + const questions = []; + if (!username) { + questions.push({ + type: 'text', + name: 'username', + message: 'Enter account to change password', + }); + } + if (!password) { + questions.push( + { + type: 'password', + name: 'password', + message: 'Enter new password', + }, + { + type: 'password', + name: 'confirmation', + message: 'Confirm new password', + }, + ); + } + + const answers = await prompts(questions); + if (answers.password !== answers.confirmation) { + throw new Error(`Passwords don't match`); + } + + return { + username: username || answers.username, + password: answers.password, + }; +}; + +(async () => { + let username, password; + + try { + ({ username, password } = await getUsernameAndPassword()); + } catch (error) { + console.log(chalk.redBright(error.message)); + return; + } + + try { + await changePassword(username, password); + console.log('Password changed for user', chalk.greenBright(username)); + } catch (error) { + if (error.message.includes('RecordNotFound')) { + console.log('Account not found:', chalk.redBright(username)); + } else { + throw error; + } + } + + prisma.$disconnect(); +})(); diff --git a/scripts/check-lang.js b/scripts/check-lang.js index a8c54538..b843efeb 100644 --- a/scripts/check-lang.js +++ b/scripts/check-lang.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); const chalk = require('chalk'); const messages = require('../lang/en-US.json'); -const ignore = require('./lang-ignore.json'); +const ignore = require('../lang-ignore.json'); const dir = path.resolve(__dirname, '../lang'); const files = fs.readdirSync(dir); @@ -13,7 +13,8 @@ files.forEach(file => { const lang = require(`../lang/${file}`); const id = file.replace('.json', ''); - console.log(chalk.yellowBright(`\n## ${file}`)); + console.log(chalk.yellowBright(`\n## ${file.replace('.json', '')}`)); + let count = 0; keys.forEach(key => { const orig = messages[key]; const check = lang[key]; @@ -21,7 +22,12 @@ files.forEach(file => { if (!ignored && (!check || check === orig)) { console.log(chalk.redBright('*'), chalk.greenBright(`${key}:`), orig); + count++; } }); + + if (count === 0) { + console.log('**👍 Complete!**'); + } } }); diff --git a/scripts/lang-ignore.json b/scripts/lang-ignore.json deleted file mode 100644 index 418fad16..00000000 --- a/scripts/lang-ignore.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "de-DE": [ - "label.administrator", - "label.name", - "metrics.device.desktop", - "metrics.device.laptop", - "metrics.device.tablet", - "metrics.referrers" - ] -} diff --git a/yarn.lock b/yarn.lock index 70310b2e..9e3a815b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5281,6 +5281,11 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + klona@^2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0" @@ -7187,6 +7192,14 @@ promise-inflight@^1.0.1: resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= +prompts@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.3.2.tgz#480572d89ecf39566d2bd3fe2c9fccb7c4c0b068" + integrity sha512-Q06uKs2CkNYVID0VqwfAl9mipo99zkBv/n2JtWY89Yxa3ZabWSrs0e2KTudKVa3peLUvYXMefDqIleLPVUBZMA== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.4" + prop-types@15.7.2, prop-types@^15.5.8, prop-types@^15.6.2, prop-types@^15.7.2: version "15.7.2" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" @@ -8028,6 +8041,11 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== +sisteransi@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"