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

🌐 Split pt translation into pt (EU) and pt_BR (Brazil) #694

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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 apps/builder/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const nextConfig = {
],
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr', 'pt', 'de'],
locales: ['en', 'fr', 'pt', 'pt_BR', 'de'],
},
experimental: {
outputFileTracingRoot: join(__dirname, '../../'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import { ChevronDownIcon } from '@/components/icons'
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'

const localeHumanReadable = {
en: 'English',
fr: 'Français',
de: 'Deutsch',
pt: 'Português',
en: 'English',
fr: 'Français',
de: 'Deutsch',
pt: 'Português',
pt_BR: 'Português (BR)'
} as const

export const UserPreferencesForm = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const CurrentSubscriptionSummary = ({ workspace }: Props) => {
<PlanTag plan={workspace.plan} />
{data?.subscription?.cancelDate && (
<Text fontSize="sm">
(Will be cancelled on {data.subscription.cancelDate.toDateString()})
({scopedT('cancelDate')} {data.subscription.cancelDate.toDateString()})
</Text>
)}
</HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const UsageProgressBars = ({ workspace }: Props) => {
<Text>
/{' '}
{workspaceChatsLimit === -1
? 'Unlimited'
? scopedT('unlimited')
: parseNumberWithCommas(workspaceChatsLimit)}
</Text>
</HStack>
Expand Down Expand Up @@ -141,7 +141,7 @@ export const UsageProgressBars = ({ workspace }: Props) => {
<Text>
/{' '}
{workspaceStorageLimit === -1
? 'Unlimited'
? scopedT('unlimited')
: `${workspaceStorageLimit} GB`}
</Text>
</HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { TextInput } from '@/components/inputs'
import { useState } from 'react'
import { UploadButton } from '@/components/ImageUploadContent/UploadButton'
import { SwitchWithLabel } from '@/components/inputs/SwitchWithLabel'
import { I18nFunction } from '@/locales'

type Props = {
scopedT: I18nFunction
fileUploadPath: string
content: AudioBubbleContent
onContentChange: (content: AudioBubbleContent) => void
}

export const AudioBubbleForm = ({
scopedT,
fileUploadPath,
content,
onContentChange,
Expand All @@ -31,14 +34,14 @@ export const AudioBubbleForm = ({
onClick={() => setCurrentTab('upload')}
size="sm"
>
Upload
{scopedT('bubbles.audio.button.upload.label')}
</Button>
<Button
variant={currentTab === 'link' ? 'solid' : 'ghost'}
onClick={() => setCurrentTab('link')}
size="sm"
>
Embed link
{scopedT('bubbles.audio.button.embedLink.label')}
</Button>
</HStack>
<Stack p="2" spacing={4}>
Expand All @@ -51,25 +54,25 @@ export const AudioBubbleForm = ({
onFileUploaded={updateUrl}
colorScheme="blue"
>
Choose a file
{scopedT('bubbles.audio.button.chooseFile.label')}
</UploadButton>
</Flex>
)}
{currentTab === 'link' && (
<>
<TextInput
placeholder="Paste the audio file link..."
placeholder={scopedT('bubbles.audio.textInput.worksWith.placeholder')}
defaultValue={content.url ?? ''}
onChange={updateUrl}
/>
<Text fontSize="sm" color="gray.400" textAlign="center">
Works with .MP3s and .WAVs
{scopedT('bubbles.audio.textInput.worksWith.text')}
</Text>
</>
)}
</Stack>
<SwitchWithLabel
label={'Enable autoplay'}
label={scopedT('bubbles.audio.switchWithLabel.autoplay.label')}
initialValue={content.isAutoplayEnabled ?? true}
onCheckChange={updateAutoPlay}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Text } from '@chakra-ui/react'
import { AudioBubbleContent } from '@typebot.io/schemas'
import { isDefined } from '@typebot.io/lib'
import { I18nFunction } from '@/locales'

type Props = {
scopedT: I18nFunction
url: AudioBubbleContent['url']
}

export const AudioBubbleNode = ({ url }: Props) =>
export const AudioBubbleNode = ({ scopedT, url }: Props) =>
isDefined(url) ? (
<audio src={url} controls />
) : (
<Text color={'gray.500'}>Click to edit...</Text>
<Text color={'gray.500'}>{scopedT('bubbles.audio.node.clickToEdit.text')}</Text>
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Text } from '@chakra-ui/react'
import { EmbedBubbleBlock } from '@typebot.io/schemas'
import { I18nFunction } from '@/locales'

export const EmbedBubbleContent = ({ block }: { block: EmbedBubbleBlock }) => {
if (!block.content?.url) return <Text color="gray.500">Click to edit...</Text>
return <Text>Show embed</Text>
type Props = {
scopedT: I18nFunction
block: EmbedBubbleBlock
}

export const EmbedBubbleContent = ({ scopedT, block }: Props) => {
if (!block.content?.url) return <Text color="gray.500">{scopedT('bubbles.embed.node.clickToEdit.text')}</Text>
return <Text>{scopedT('node.show.text')}</Text>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { TextInput, NumberInput } from '@/components/inputs'
import { HStack, Stack, Text } from '@chakra-ui/react'
import { EmbedBubbleContent } from '@typebot.io/schemas'
import { sanitizeUrl } from '@typebot.io/lib'
import { I18nFunction } from '@/locales'

type Props = {
scopedT: I18nFunction
content: EmbedBubbleContent
onSubmit: (content: EmbedBubbleContent) => void
}

export const EmbedUploadContent = ({ content, onSubmit }: Props) => {
export const EmbedUploadContent = ({ scopedT, content, onSubmit }: Props) => {
const handleUrlChange = (url: string) => {
const iframeUrl = sanitizeUrl(
url.trim().startsWith('<iframe') ? extractUrlFromIframe(url) : url
Expand All @@ -23,12 +25,12 @@ export const EmbedUploadContent = ({ content, onSubmit }: Props) => {
<Stack p="2" spacing={6}>
<Stack>
<TextInput
placeholder="Paste the link or code..."
placeholder={scopedT('bubbles.embed.worksWith.placeholder')}
defaultValue={content?.url ?? ''}
onChange={handleUrlChange}
/>
<Text fontSize="sm" color="gray.400" textAlign="center">
Works with PDFs, iframes, websites...
{scopedT('bubbles.embed.worksWith.text')}
</Text>
</Stack>

Expand All @@ -38,7 +40,7 @@ export const EmbedUploadContent = ({ content, onSubmit }: Props) => {
defaultValue={content?.height}
onValueChange={handleHeightChange}
/>
<Text>px</Text>
<Text>{scopedT('bubbles.embed.numberInput.unit')}</Text>
</HStack>
</Stack>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { Box, Text, Image } from '@chakra-ui/react'
import { ImageBubbleBlock } from '@typebot.io/schemas'
import { I18nFunction } from '@/locales'

export const ImageBubbleContent = ({ block }: { block: ImageBubbleBlock }) => {
type Props = {
scopedT: I18nFunction
block: ImageBubbleBlock
}

export const ImageBubbleContent = ({ scopedT, block }: Props) => {
const containsVariables =
block.content?.url?.includes('{{') && block.content.url.includes('}}')
return !block.content?.url ? (
<Text color={'gray.500'}>Click to edit...</Text>
<Text color={'gray.500'}>{scopedT('bubbles.image.node.clickToEdit.text')}</Text>
) : (
<Box w="full">
<Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import { Stack } from '@chakra-ui/react'
import { isDefined, isNotEmpty } from '@typebot.io/lib'
import { ImageBubbleBlock } from '@typebot.io/schemas'
import React, { useState } from 'react'
import { I18nFunction } from '@/locales'

type Props = {
scopedT: I18nFunction
typebotId: string
block: ImageBubbleBlock
onContentChange: (content: ImageBubbleBlock['content']) => void
}

export const ImageBubbleSettings = ({
scopedT,
typebotId,
block,
onContentChange,
Expand Down Expand Up @@ -55,7 +58,7 @@ export const ImageBubbleSettings = ({
/>
<Stack>
<SwitchWithLabel
label={'On click link'}
label={scopedT('bubbles.image.switchWithLabel.onClick.label')}
initialValue={showClickLinkInput}
onCheckChange={toggleClickLink}
/>
Expand All @@ -68,7 +71,7 @@ export const ImageBubbleSettings = ({
defaultValue={block.content.clickLink?.url}
/>
<TextInput
placeholder="Link alt text (description)"
placeholder={scopedT('bubbles.image.switchWithLabel.onClick.placeholder')}
onChange={updateClickLinkAltText}
defaultValue={block.content.clickLink?.alt}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { colors } from '@/lib/theme'
import { useOutsideClick } from '@/hooks/useOutsideClick'
import { selectEditor, TElement } from '@udecode/plate-common'
import { TextEditorToolBar } from './TextEditorToolBar'
import { useScopedI18n } from '@/locales'

type TextBubbleEditorContentProps = {
id: string
Expand All @@ -30,6 +31,7 @@ const TextBubbleEditorContent = ({
textEditorValue,
onClose,
}: TextBubbleEditorContentProps) => {
const scopedT = useScopedI18n('editor.blocks.bubbles')
const editor = usePlateEditorRef()
const varDropdownRef = useRef<HTMLDivElement | null>(null)
const rememberedSelection = useRef<BaseSelection | null>(null)
Expand Down Expand Up @@ -135,7 +137,7 @@ const TextBubbleEditorContent = ({
})
setIsFirstFocus(false)
},
'aria-label': 'Text editor',
'aria-label': `${scopedT('textEditor.plate.label')}`,
onBlur: () => {
rememberedSelection.current = editor?.selection
},
Expand All @@ -154,7 +156,7 @@ const TextBubbleEditorContent = ({
<VariableSearchInput
initialVariableId={undefined}
onSelectVariable={handleVariableSelected}
placeholder="Search for a variable"
placeholder={scopedT('textEditor.searchVariable.placeholder')}
autoFocus
/>
</PopoverContent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Box, Text } from '@chakra-ui/react'
import { VideoBubbleBlock, VideoBubbleContentType } from '@typebot.io/schemas'
import { I18nFunction } from '@/locales'

export const VideoBubbleContent = ({ block }: { block: VideoBubbleBlock }) => {
type Props = {
scopedT: I18nFunction
block: VideoBubbleBlock
}

export const VideoBubbleContent = ({ scopedT, block }: Props) => {
if (!block.content?.url || !block.content.type)
return <Text color="gray.500">Click to edit...</Text>
return <Text color="gray.500">{scopedT('bubbles.video.node.clickToEdit.text')}</Text>
switch (block.content.type) {
case VideoBubbleContentType.URL:
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { Stack, Text } from '@chakra-ui/react'
import { VideoBubbleContent, VideoBubbleContentType } from '@typebot.io/schemas'
import { TextInput } from '@/components/inputs'
import { I18nFunction } from '@/locales'

const vimeoRegex = /vimeo\.com\/(\d+)/
const youtubeRegex = /youtube\.com\/(watch\?v=|shorts\/)(\w+)|youtu\.be\/(\w+)/

type Props = {
scopedT: I18nFunction
content?: VideoBubbleContent
onSubmit: (content: VideoBubbleContent) => void
}

export const VideoUploadContent = ({ content, onSubmit }: Props) => {
export const VideoUploadContent = ({ scopedT, content, onSubmit }: Props) => {
const handleUrlChange = (url: string) => {
const info = parseVideoUrl(url)
return onSubmit({
Expand All @@ -22,12 +24,12 @@ export const VideoUploadContent = ({ content, onSubmit }: Props) => {
return (
<Stack p="2">
<TextInput
placeholder="Paste the video link..."
placeholder={scopedT('bubbles.video.textInput.worksWith.placeholder')}
defaultValue={content?.url ?? ''}
onChange={handleUrlChange}
/>
<Text fontSize="sm" color="gray.400" textAlign="center">
Works with Youtube, Vimeo and others
{scopedT('bubbles.video.textInput.worksWith.text')}
</Text>
</Stack>
)
Expand Down
Loading
Loading