diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index 270e0451..ec126093 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -61,6 +61,8 @@ "copied_link_to_clipboard": "Link copiado", "hours": "horas", "minutes": "minutos", + "amount_hours": "{{amount}} horas", + "amount_minutes": "{{amount}} minutos", "accuracy": "{{accuracy}}% de precisão", "add_to_library": "Adicionar à biblioteca", "remove_from_library": "Remover da biblioteca", diff --git a/src/renderer/src/pages/game-details/hero-panel.tsx b/src/renderer/src/pages/game-details/hero-panel.tsx index fafd0aaa..ae6d144e 100644 --- a/src/renderer/src/pages/game-details/hero-panel.tsx +++ b/src/renderer/src/pages/game-details/hero-panel.tsx @@ -57,19 +57,24 @@ export function HeroPanel({ } }, [game?.lastTimePlayed, formatDistance]); - const formatPlayTime = (milliseconds: number) => { - const seconds = milliseconds / 1000 - const minutes = seconds / 60 + const formatPlayTime = () => { + const milliseconds = game?.playTimeInMilliseconds || 0; + const seconds = milliseconds / 1000; + const minutes = seconds / 60; - if (minutes < 120) { - return minutes.toFixed(0) + " " + t("minutes") - } + if (minutes < 120) { + return t("amount_minutes", { + amount: minutes.toFixed(0), + }); + } - const numberFormat = new Intl.NumberFormat(i18n.language, { maximumFractionDigits: 1 }) + const numberFormat = new Intl.NumberFormat(i18n.language, { + maximumFractionDigits: 1, + }); - const hours = minutes / 60 - return numberFormat.format(hours) + " " + t("hours") - } + const hours = minutes / 60; + return t("amount_hours", { amount: numberFormat.format(hours) }); + }; const finalDownloadSize = useMemo(() => { if (!game) return "N/A";