From 973e16d58de7fa16f23f94b44bd7087baa465646 Mon Sep 17 00:00:00 2001 From: tincho70 Date: Tue, 16 Apr 2024 14:13:00 -0300 Subject: [PATCH] GameTime internationalization --- .../[locale]/components/GameTime/index.tsx | 19 ++++++++++++------- apps/web/translations/en/global.json | 7 ++++++- apps/web/translations/es/global.json | 7 ++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/web/app/[locale]/components/GameTime/index.tsx b/apps/web/app/[locale]/components/GameTime/index.tsx index 23c5e24..365e439 100644 --- a/apps/web/app/[locale]/components/GameTime/index.tsx +++ b/apps/web/app/[locale]/components/GameTime/index.tsx @@ -7,10 +7,11 @@ import { useContext, useMemo } from 'react'; import { RoundsContext } from '../../../../context/RoundsContext'; import { useMassacre } from '../../../../hooks/useMassacre'; import { useFormatter } from '@lawallet/react'; -import { useLocale } from 'next-intl'; +import { useLocale, useTranslations } from 'next-intl'; import type { AvailableLanguages } from '@lawallet/utils/types'; export function GameTime() { + const t = useTranslations(); const { currentBlock, status } = useMassacre(); const { currentRound } = useContext(RoundsContext); const locale = useLocale() as AvailableLanguages; @@ -42,19 +43,23 @@ export function GameTime() { - Ronda {round! + 1} + {t('ROUND')} {round! + 1} {status === 'FREEZE' && ' - Freezado'} - {currentRound && Massacre en #{formatAmount(currentRound!.height)}} + {currentRound && ( + + {t('MASSACRE_AT')} #{formatAmount(currentRound!.height)} + + )} {time && ( - Próxima en: + {t('NEXT_ROUND')}: - ~ {formatTime(time!)} + ~ {formatTime(time!, t('HOURS_LONG'), t('MINUTES_LONG'))} @@ -66,6 +71,6 @@ export function GameTime() { ); } -function formatTime(min: number): string { - return min > 120 ? `${(min / 60).toFixed(0)} horas` : `${min} minutos`; +function formatTime(min: number, hours: string, minutes: string): string { + return min > 120 ? `${(min / 60).toFixed(0)} ${hours}` : `${min} ${minutes}`; } diff --git a/apps/web/translations/en/global.json b/apps/web/translations/en/global.json index 465e5b9..e8d96d8 100644 --- a/apps/web/translations/en/global.json +++ b/apps/web/translations/en/global.json @@ -145,5 +145,10 @@ "POWER": "Power", "TICKET": "Ticket", "AND": "and", - "INSCRIPTION_CLOSED_TEXT": "Players inscription closed. Waiting for rounds schedule." + "INSCRIPTION_CLOSED_TEXT": "Players inscription closed. Waiting for rounds schedule.", + "MASSACRE_AT": "Massacre at", + "NEXT_ROUND": "Next in", + "HOURS_LONG": "hours", + "MINUTES_LONG": "minutes", + "ROUND": "Round" } diff --git a/apps/web/translations/es/global.json b/apps/web/translations/es/global.json index 1e1a9ec..bcd277f 100644 --- a/apps/web/translations/es/global.json +++ b/apps/web/translations/es/global.json @@ -145,5 +145,10 @@ "POWER": "Poder", "TICKET": "Ticket", "AND": "y", - "INSCRIPTION_CLOSED_TEXT": "Lista de participantes cerrada. Esperando calendario de rondas." + "INSCRIPTION_CLOSED_TEXT": "Lista de participantes cerrada. Esperando calendario de rondas.", + "MASSACRE_AT": "Massacre en", + "NEXT_ROUND": "Próxima en", + "HOURS_LONG": "horas", + "MINUTES_LONG": "minutos", + "ROUND": "Ronda" }