🌐 Add i18n-ally config and upgrade next-international

This commit is contained in:
Baptiste Arnaud
2023-09-05 16:44:44 +02:00
parent 9e8fa124b5
commit e4ece315ed
11 changed files with 44 additions and 33 deletions

View File

@@ -11,13 +11,12 @@ import {
import { Stats } from '@typebot.io/schemas'
import React from 'react'
const computeCompletionRate = (
totalCompleted: number,
totalStarts: number
): string => {
if (totalStarts === 0) return 'Not available'
return `${Math.round((totalCompleted / totalStarts) * 100)}%`
}
const computeCompletionRate =
(notAvailableLabel: string) =>
(totalCompleted: number, totalStarts: number): string => {
if (totalStarts === 0) return notAvailableLabel
return `${Math.round((totalCompleted / totalStarts) * 100)}%`
}
export const StatsCards = ({
stats,
@@ -48,7 +47,10 @@ export const StatsCards = ({
<StatLabel>{scopedT('completionRateLabel')}</StatLabel>
{stats ? (
<StatNumber>
{computeCompletionRate(stats.totalCompleted, stats.totalStarts)}
{computeCompletionRate(scopedT('notAvailableLabel'))(
stats.totalCompleted,
stats.totalStarts
)}
</StatNumber>
) : (
<Skeleton w="50%" h="10px" mt="2" />

View File

@@ -149,7 +149,7 @@ export const TypebotButton = ({
top="27px"
size="sm"
>
Live
{scopedT('live')}
</Tag>
)}
{!isReadOnly && (