Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates modal pt-BR translation #1120

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"i18n-ally.localesPaths": ["apps/builder/public/locales"],
"i18n-ally.localesPaths": ["apps/builder/src/i18n"],
"i18n-ally.keystyle": "flat",
"i18n-ally.displayLanguage": "en",
"i18n-ally.enabledFrameworks": ["custom"],
Expand Down
70 changes: 10 additions & 60 deletions apps/builder/src/features/templates/components/TemplatesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { Standard } from '@typebot.io/nextjs'
import { Typebot } from '@typebot.io/schemas'
import React, { useCallback, useEffect, useState } from 'react'
import { templates } from '../data'
import { useTemplates } from '../hooks/useTemplates'
import { TemplateProps } from '../types'
import { useToast } from '@/hooks/useToast'
import { sendRequest } from '@typebot.io/lib'
Expand All @@ -37,6 +37,7 @@ export const TemplatesModal = ({
const { t } = useTranslate()
const templateCardBackgroundColor = useColorModeValue('white', 'gray.800')
const [typebot, setTypebot] = useState<Typebot>()
const templates = useTemplates()
const [selectedTemplate, setSelectedTemplate] = useState<TemplateProps>(
templates[0]
)
Expand All @@ -50,14 +51,15 @@ export const TemplatesModal = ({
)
if (error)
return showToast({ title: error.name, description: error.message })
setTypebot(data as Typebot)
setTypebot({ ...(data as Typebot), name: template.name })
},
[showToast]
)

useEffect(() => {
if (typebot) return
fetchTemplate(templates[0])
}, [fetchTemplate])
}, [fetchTemplate, typebot, templates])

const onUseThisTemplateClick = async () => {
if (!typebot) return
Expand Down Expand Up @@ -112,15 +114,7 @@ export const TemplatesModal = ({
>
<HStack overflow="hidden" fontSize="sm" w="full">
<Text>{template.emoji}</Text>
<Text>
{t(
createTranslationKey(
template.name,
template.category
),
template.name
)}
</Text>
<Text>{template.name}</Text>
{template.isNew && (
<Tag colorScheme="orange" size="sm" flexShrink={0}>
{t('templates.modal.menuHeading.new.tag')}
Expand Down Expand Up @@ -156,15 +150,7 @@ export const TemplatesModal = ({
>
<HStack overflow="hidden" fontSize="sm" w="full">
<Text>{template.emoji}</Text>
<Text>
{t(
createTranslationKey(
template.name,
template.category
),
template.name
)}
</Text>
<Text>{template.name}</Text>
{template.isNew && (
<Tag colorScheme="orange" size="sm" flexShrink={0}>
{t('templates.modal.menuHeading.new.tag')}
Expand Down Expand Up @@ -200,15 +186,7 @@ export const TemplatesModal = ({
>
<HStack overflow="hidden" fontSize="sm" w="full">
<Text>{template.emoji}</Text>
<Text>
{t(
createTranslationKey(
template.name,
template.category
),
template.name
)}
</Text>
<Text>{template.name}</Text>
{template.isNew && (
<Tag colorScheme="orange" size="sm" flexShrink={0}>
{t('templates.modal.menuHeading.new.tag')}
Expand Down Expand Up @@ -249,26 +227,9 @@ export const TemplatesModal = ({
<Stack flex="1" spacing={4}>
<Heading fontSize="2xl">
{selectedTemplate.emoji}{' '}
<chakra.span ml="2">
{t(
createTranslationKey(
selectedTemplate.name,
selectedTemplate.category
),
selectedTemplate.name
)}
</chakra.span>
<chakra.span ml="2">{selectedTemplate.name}</chakra.span>
</Heading>
<Text>
{t(
createTranslationKey(
selectedTemplate.name,
selectedTemplate.category,
'description'
),
selectedTemplate.description
)}
</Text>
<Text>{selectedTemplate.description}</Text>
</Stack>
<Button
colorScheme="blue"
Expand All @@ -284,14 +245,3 @@ export const TemplatesModal = ({
</Modal>
)
}

const createTranslationKey = (
label: string,
category: 'marketing' | 'product' | undefined,
type?: 'name' | 'description'
) =>
'templates.modal.' +
(category ?? 'other') +
'.' +
label.replace(/\s/g, '') +
`.${type ?? 'name'}`
136 changes: 0 additions & 136 deletions apps/builder/src/features/templates/data.ts

This file was deleted.

Loading