2
0

🌐 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

6
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"i18n-ally.localesPaths": ["apps/builder/src/locales"],
"i18n-ally.enabledFrameworks": ["next-international"],
"i18n-ally.enabledParsers": ["ts"],
"i18n-ally.keystyle": "flat"
}

View File

@@ -71,7 +71,7 @@
"minio": "7.1.1", "minio": "7.1.1",
"next": "13.4.3", "next": "13.4.3",
"next-auth": "4.22.1", "next-auth": "4.22.1",
"next-international": "0.5.3", "next-international": "0.9.5",
"nextjs-cors": "^2.1.2", "nextjs-cors": "^2.1.2",
"nodemailer": "6.9.3", "nodemailer": "6.9.3",
"nprogress": "0.2.0", "nprogress": "0.2.0",

View File

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

View File

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

View File

@@ -1,4 +1,6 @@
export default { import { defineLocale } from '.'
export default defineLocale({
back: 'Zurück', back: 'Zurück',
'confirmModal.defaultTitle': 'Bist du sicher?', 'confirmModal.defaultTitle': 'Bist du sicher?',
'dashboard.header.settingsButton.label': 'Einstellungen & Mitglieder', 'dashboard.header.settingsButton.label': 'Einstellungen & Mitglieder',
@@ -70,6 +72,7 @@ export default {
'account.myAccount.nameInput.label': 'Name:', 'account.myAccount.nameInput.label': 'Name:',
'analytics.viewsLabel': 'Ansichten', 'analytics.viewsLabel': 'Ansichten',
'analytics.startsLabel': 'Starts', 'analytics.startsLabel': 'Starts',
'analytics.notAvailableLabel': 'Nicht verfügbar',
'analytics.completionRateLabel': 'Abschlussrate', 'analytics.completionRateLabel': 'Abschlussrate',
'auth.signin.heading': 'Anmelden', 'auth.signin.heading': 'Anmelden',
'auth.signin.noAccountLabel.preLink': 'Noch kein Konto?', 'auth.signin.noAccountLabel.preLink': 'Noch kein Konto?',
@@ -119,7 +122,6 @@ export default {
'Um {type} hinzuzufügen, musst du deinen Tarif aktualisieren', 'Um {type} hinzuzufügen, musst du deinen Tarif aktualisieren',
'billing.currentSubscription.heading': 'Abonnement', 'billing.currentSubscription.heading': 'Abonnement',
'billing.currentSubscription.subheading': 'Aktuelles Workspace-Abonnement:', 'billing.currentSubscription.subheading': 'Aktuelles Workspace-Abonnement:',
'billing.currentSubscription.cancelLink': 'Mein Abonnement kündigen',
'billing.invoices.heading': 'Rechnungen', 'billing.invoices.heading': 'Rechnungen',
'billing.invoices.empty': 'Keine Rechnungen für diesen Workspace gefunden.', 'billing.invoices.empty': 'Keine Rechnungen für diesen Workspace gefunden.',
'billing.invoices.paidAt': 'Bezahlt am', 'billing.invoices.paidAt': 'Bezahlt am',
@@ -188,4 +190,4 @@ export default {
'workspace.settings.modal.menu.version.label': 'Version: {version}', 'workspace.settings.modal.menu.version.label': 'Version: {version}',
'workspace.dropdown.newButton.label': 'Neuer Workspace', 'workspace.dropdown.newButton.label': 'Neuer Workspace',
'workspace.dropdown.logoutButton.label': 'Abmelden', 'workspace.dropdown.logoutButton.label': 'Abmelden',
} as const })

View File

@@ -69,6 +69,7 @@ export default {
'account.myAccount.nameInput.label': 'Name:', 'account.myAccount.nameInput.label': 'Name:',
'analytics.viewsLabel': 'Views', 'analytics.viewsLabel': 'Views',
'analytics.startsLabel': 'Starts', 'analytics.startsLabel': 'Starts',
'analytics.notAvailableLabel': 'Not available',
'analytics.completionRateLabel': 'Completion rate', 'analytics.completionRateLabel': 'Completion rate',
'auth.signin.heading': 'Sign In', 'auth.signin.heading': 'Sign In',
'auth.signin.noAccountLabel.preLink': "Don't have an account?", 'auth.signin.noAccountLabel.preLink': "Don't have an account?",
@@ -114,7 +115,6 @@ export default {
'You need to upgrade your plan in order to {type}', 'You need to upgrade your plan in order to {type}',
'billing.currentSubscription.heading': 'Subscription', 'billing.currentSubscription.heading': 'Subscription',
'billing.currentSubscription.subheading': 'Current workspace subscription:', 'billing.currentSubscription.subheading': 'Current workspace subscription:',
'billing.currentSubscription.cancelLink': 'Cancel my subscription',
'billing.invoices.heading': 'Invoices', 'billing.invoices.heading': 'Invoices',
'billing.invoices.empty': 'No invoices found for this workspace.', 'billing.invoices.empty': 'No invoices found for this workspace.',
'billing.invoices.paidAt': 'Paid at', 'billing.invoices.paidAt': 'Paid at',

View File

@@ -1,4 +1,6 @@
export default { import { defineLocale } from '.'
export default defineLocale({
back: 'Retour', back: 'Retour',
'confirmModal.defaultTitle': 'Es-tu sûr ?', 'confirmModal.defaultTitle': 'Es-tu sûr ?',
'dashboard.header.settingsButton.label': 'Paramètres & Membres', 'dashboard.header.settingsButton.label': 'Paramètres & Membres',
@@ -69,6 +71,7 @@ export default {
'account.myAccount.nameInput.label': 'Nom:', 'account.myAccount.nameInput.label': 'Nom:',
'analytics.viewsLabel': 'Vues', 'analytics.viewsLabel': 'Vues',
'analytics.startsLabel': 'Démarrés', 'analytics.startsLabel': 'Démarrés',
'analytics.notAvailableLabel': 'Non disponible',
'analytics.completionRateLabel': 'Taux de complétion', 'analytics.completionRateLabel': 'Taux de complétion',
'auth.signin.heading': 'Se connecter', 'auth.signin.heading': 'Se connecter',
'auth.signin.noAccountLabel.preLink': "Tu n'as pas de compte?", 'auth.signin.noAccountLabel.preLink': "Tu n'as pas de compte?",
@@ -116,7 +119,6 @@ export default {
'Tu dois mettre à niveau ton abonnement pour {type}', 'Tu dois mettre à niveau ton abonnement pour {type}',
'billing.currentSubscription.heading': 'Abonnement', 'billing.currentSubscription.heading': 'Abonnement',
'billing.currentSubscription.subheading': 'Abonnement actuel du workspace :', 'billing.currentSubscription.subheading': 'Abonnement actuel du workspace :',
'billing.currentSubscription.cancelLink': "Annuler l'abonnement",
'billing.invoices.heading': 'Factures', 'billing.invoices.heading': 'Factures',
'billing.invoices.empty': 'Aucune facture trouvée pour ce workspace.', 'billing.invoices.empty': 'Aucune facture trouvée pour ce workspace.',
'billing.invoices.paidAt': 'Payé le', 'billing.invoices.paidAt': 'Payé le',
@@ -188,4 +190,4 @@ export default {
'workspace.settings.modal.menu.version.label': 'Version : {version}', 'workspace.settings.modal.menu.version.label': 'Version : {version}',
'workspace.dropdown.newButton.label': 'Nouveau workspace', 'workspace.dropdown.newButton.label': 'Nouveau workspace',
'workspace.dropdown.logoutButton.label': 'Déconnexion', 'workspace.dropdown.logoutButton.label': 'Déconnexion',
} as const })

View File

@@ -7,6 +7,7 @@ export const {
getLocaleProps, getLocaleProps,
useCurrentLocale, useCurrentLocale,
useChangeLocale, useChangeLocale,
defineLocale,
} = createI18n({ } = createI18n({
en: () => import('./en'), en: () => import('./en'),
fr: () => import('./fr'), fr: () => import('./fr'),

View File

@@ -1,4 +1,6 @@
export default { import { defineLocale } from '.'
export default defineLocale({
back: 'Voltar', back: 'Voltar',
'confirmModal.defaultTitle': 'Tem certeza?', 'confirmModal.defaultTitle': 'Tem certeza?',
'dashboard.header.settingsButton.label': 'Configurações & Membros', 'dashboard.header.settingsButton.label': 'Configurações & Membros',
@@ -70,6 +72,7 @@ export default {
'account.myAccount.nameInput.label': 'Nome:', 'account.myAccount.nameInput.label': 'Nome:',
'analytics.viewsLabel': 'Visualizações', 'analytics.viewsLabel': 'Visualizações',
'analytics.startsLabel': 'Inícios', 'analytics.startsLabel': 'Inícios',
'analytics.notAvailableLabel': 'Não disponível',
'analytics.completionRateLabel': 'Taxa de conclusão', 'analytics.completionRateLabel': 'Taxa de conclusão',
'auth.signin.heading': 'Entrar', 'auth.signin.heading': 'Entrar',
'auth.signin.noAccountLabel.preLink': 'Não tem uma conta?', 'auth.signin.noAccountLabel.preLink': 'Não tem uma conta?',
@@ -118,7 +121,6 @@ export default {
'billing.currentSubscription.heading': 'Assinatura', 'billing.currentSubscription.heading': 'Assinatura',
'billing.currentSubscription.subheading': 'billing.currentSubscription.subheading':
'Assinatura atual do espaço de trabalho:', 'Assinatura atual do espaço de trabalho:',
'billing.currentSubscription.cancelLink': 'Cancelar minha assinatura',
'billing.invoices.heading': 'Faturas', 'billing.invoices.heading': 'Faturas',
'billing.invoices.empty': 'billing.invoices.empty':
'Nenhuma fatura encontrada para este espaço de trabalho.', 'Nenhuma fatura encontrada para este espaço de trabalho.',
@@ -190,4 +192,4 @@ export default {
'workspace.settings.modal.menu.version.label': 'Versão: {version}', 'workspace.settings.modal.menu.version.label': 'Versão: {version}',
'workspace.dropdown.newButton.label': 'Novo espaço de trabalho', 'workspace.dropdown.newButton.label': 'Novo espaço de trabalho',
'workspace.dropdown.logoutButton.label': 'Sair', 'workspace.dropdown.logoutButton.label': 'Sair',
} as const })

View File

@@ -19,6 +19,7 @@ import { I18nProvider } from '@/locales'
import { TypebotProvider } from '@/features/editor/providers/TypebotProvider' import { TypebotProvider } from '@/features/editor/providers/TypebotProvider'
import { WorkspaceProvider } from '@/features/workspace/WorkspaceProvider' import { WorkspaceProvider } from '@/features/workspace/WorkspaceProvider'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance' import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import en from '@/locales/en'
import { initPostHogIfEnabled } from '@/features/telemetry/posthog' import { initPostHogIfEnabled } from '@/features/telemetry/posthog'
initPostHogIfEnabled() initPostHogIfEnabled()
@@ -55,7 +56,7 @@ const App = ({ Component, pageProps }: AppProps) => {
return ( return (
<> <>
<ToastContainer /> <ToastContainer />
<I18nProvider locale={pageProps.locale}> <I18nProvider locale={pageProps.locale} fallbackLocale={en}>
<ChakraProvider theme={customTheme}> <ChakraProvider theme={customTheme}>
<SessionProvider session={pageProps.session}> <SessionProvider session={pageProps.session}>
<UserProvider> <UserProvider>

19
pnpm-lock.yaml generated
View File

@@ -207,8 +207,8 @@ importers:
specifier: 4.22.1 specifier: 4.22.1
version: 4.22.1(next@13.4.3)(nodemailer@6.9.3)(react-dom@18.2.0)(react@18.2.0) version: 4.22.1(next@13.4.3)(nodemailer@6.9.3)(react-dom@18.2.0)(react@18.2.0)
next-international: next-international:
specifier: 0.5.3 specifier: 0.9.5
version: 0.5.3(next@13.4.3)(react@18.2.0) version: 0.9.5
nextjs-cors: nextjs-cors:
specifier: ^2.1.2 specifier: ^2.1.2
version: 2.1.2(next@13.4.3) version: 2.1.2(next@13.4.3)
@@ -15044,8 +15044,8 @@ packages:
has: 1.0.3 has: 1.0.3
side-channel: 1.0.4 side-channel: 1.0.4
/international-types@0.5.3: /international-types@0.8.0:
resolution: {integrity: sha512-itSEB3Ohnxd08OTTp8+y8irFJVOy1cKr1J6tfrhXnpDz9/Oa3dDAUrcbxiWM7jvGmF6+gdTwVCBVUoGG4E9vdg==} resolution: {integrity: sha512-cJwagIBzMG0FTK81TABeSBU0eReIXWmvW18m/URn8ZA+GLoWIcdL43kfjArwHVmZJ1n+IFchsBj8tQLYUqmwnA==}
dev: false dev: false
/interpret@1.4.0: /interpret@1.4.0:
@@ -17232,16 +17232,11 @@ packages:
uuid: 8.3.2 uuid: 8.3.2
dev: false dev: false
/next-international@0.5.3(next@13.4.3)(react@18.2.0): /next-international@0.9.5:
resolution: {integrity: sha512-Nvw0b+ZfXowC6zedqg2UsV0c23gQAmr00v4eSp+XMaT1j9FgH3jSovMk2nyQ51Q23iXVOGMP+Tiftbp4FpXuiw==} resolution: {integrity: sha512-yS6DnuNAK+2EO5KWLgw2FPGwBkQ8gylrG0vNSeJD0/BAHSyIpPCn6E+1KPzawQffB5r6wVP6vHjDoSlUOxWWew==}
peerDependencies:
next: ^13.0.0 || ^12.0.0 || ^11.0.0
react: ^18.0.0 || ^17.0.0
dependencies: dependencies:
client-only: 0.0.1 client-only: 0.0.1
international-types: 0.5.3 international-types: 0.8.0
next: 13.4.3(@babel/core@7.22.9)(react-dom@18.2.0)(react@18.2.0)
react: 18.2.0
server-only: 0.0.1 server-only: 0.0.1
dev: false dev: false