From 8dfe186e8ae339816ad8dde9fce88e05fa661ba3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 19 Sep 2025 15:19:23 -0500 Subject: [PATCH] Translate more pages --- src/components/Shakespeare/PreviewPane.tsx | 18 +++-- src/lib/i18n.ts | 90 ++++++++++++++++++++++ src/pages/Clone.tsx | 50 ++++++------ src/pages/ProjectView.tsx | 12 +-- 4 files changed, 133 insertions(+), 37 deletions(-) diff --git a/src/components/Shakespeare/PreviewPane.tsx b/src/components/Shakespeare/PreviewPane.tsx index 4ca07b70..c795e9d8 100644 --- a/src/components/Shakespeare/PreviewPane.tsx +++ b/src/components/Shakespeare/PreviewPane.tsx @@ -1,5 +1,6 @@ import { encodeBase64 } from '@std/encoding/base64'; import { useState, useEffect, useCallback, useRef } from 'react'; +import { useTranslation } from 'react-i18next'; import { useProjectsManager } from '@/hooks/useProjectsManager'; import { useFS } from '@/hooks/useFS'; import { Tabs, TabsContent } from '@/components/ui/tabs'; @@ -49,6 +50,7 @@ interface JSONRPCResponse { } export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { + const { t } = useTranslation(); const [selectedFile, setSelectedFile] = useState(null); const [fileContent, setFileContent] = useState(''); const [isLoading, setIsLoading] = useState(false); @@ -376,9 +378,9 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { ) : (
-

Project Preview

+

{t('projectPreview')}

- Build your project to see the preview here + {t('buildProjectToSeePreview')}

@@ -392,7 +394,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) { <>
-

File Explorer

+

{t('fileExplorer')}

@@ -419,7 +421,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {

- {selectedFile ? selectedFile.split('/').pop() : 'File Editor'} + {selectedFile ? selectedFile.split('/').pop() : t('fileEditor')}

@@ -437,7 +439,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {

- Select a file from the explorer to edit + {t('selectFileFromExplorer')}

@@ -459,7 +461,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
-

File Explorer

+

{t('fileExplorer')}

@@ -488,7 +490,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {

- Select a file from the explorer to edit + {t('selectFileFromExplorer')}

diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index b7524239..1898b5e9 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -103,6 +103,19 @@ const resources = { stopGeneration: 'Stop generation', running: 'Running', + // Project View Navigation + chat: 'Chat', + preview: 'Preview', + code: 'Code', + + // Preview Pane + projectPreview: 'Project Preview', + buildProjectToSeePreview: 'Build your project to see the preview here', + fileExplorer: 'File Explorer', + fileEditor: 'File Editor', + selectFileFromExplorer: 'Select a file from the explorer to edit', + openFileExplorer: 'Open File Explorer', + // File Editor unsavedChanges: 'Unsaved changes', saving: 'Saving...', @@ -252,6 +265,23 @@ const resources = { addAccount: 'Add Account', relayConfiguration: 'Relay Configuration', selectedRelay: 'Selected Relay', + + // Clone Page + cloneGitRepository: 'Clone a Git repository into your Shakespeare workspace', + pleaseEnterRepositoryUrl: 'Please enter a repository URL', + pleaseEnterValidGitUrl: 'Please enter a valid Git repository URL or Nostr clone URI (e.g., nostr://npub.../repo-name)', + cloningRepository: 'Cloning Repository...', + nostrRepositoryImportedSuccessfully: 'Nostr repository imported successfully', + repositoryClonedFromNostr: '"{{repoName}}" has been cloned from Nostr and is ready for development.', + repositoryImportedSuccessfully: 'Repository imported successfully', + repositoryClonedReady: '"{{repoName}}" has been cloned and is ready for development.', + failedToImportRepository: 'Failed to import repository', + repositoryNotFoundOnNostr: 'Repository not found on Nostr network. Please check the URI and try again.', + noCloneUrlsFound: 'Repository announcement found but no clone URLs available.', + allCloneAttemptsFailed: 'Repository found but all clone URLs failed. The repository may be unavailable.', + repositoryNotFound: 'Repository not found. Please check the URL and try again.', + accessDenied: 'Access denied. The repository may be private or require authentication.', + networkError: 'Network error. Please check your connection and try again.', } }, pt: { @@ -354,6 +384,19 @@ const resources = { stopGeneration: 'Parar geração', running: 'Executando', + // Project View Navigation + chat: 'Chat', + preview: 'Visualização', + code: 'Código', + + // Preview Pane + projectPreview: 'Visualização do Projeto', + buildProjectToSeePreview: 'Construa seu projeto para ver a visualização aqui', + fileExplorer: 'Explorador de Arquivos', + fileEditor: 'Editor de Arquivos', + selectFileFromExplorer: 'Selecione um arquivo do explorador para editar', + openFileExplorer: 'Abrir Explorador de Arquivos', + // File Editor unsavedChanges: 'Alterações não salvas', saving: 'Salvando...', @@ -503,6 +546,23 @@ const resources = { addAccount: 'Adicionar Conta', relayConfiguration: 'Configuração de Relay', selectedRelay: 'Relay Selecionado', + + // Clone Page + cloneGitRepository: 'Clone um repositório Git para seu workspace Shakespeare', + pleaseEnterRepositoryUrl: 'Por favor, digite uma URL do repositório', + pleaseEnterValidGitUrl: 'Por favor, digite uma URL válida de repositório Git ou URI de clone Nostr (ex: nostr://npub.../nome-repo)', + cloningRepository: 'Clonando Repositório...', + nostrRepositoryImportedSuccessfully: 'Repositório Nostr importado com sucesso', + repositoryClonedFromNostr: '"{{repoName}}" foi clonado do Nostr e está pronto para desenvolvimento.', + repositoryImportedSuccessfully: 'Repositório importado com sucesso', + repositoryClonedReady: '"{{repoName}}" foi clonado e está pronto para desenvolvimento.', + failedToImportRepository: 'Falha ao importar repositório', + repositoryNotFoundOnNostr: 'Repositório não encontrado na rede Nostr. Verifique a URI e tente novamente.', + noCloneUrlsFound: 'Anúncio do repositório encontrado, mas nenhuma URL de clone disponível.', + allCloneAttemptsFailed: 'Repositório encontrado, mas todas as URLs de clone falharam. O repositório pode estar indisponível.', + repositoryNotFound: 'Repositório não encontrado. Verifique a URL e tente novamente.', + accessDenied: 'Acesso negado. O repositório pode ser privado ou requer autenticação.', + networkError: 'Erro de rede. Verifique sua conexão e tente novamente.', } }, zh: { @@ -605,6 +665,19 @@ const resources = { stopGeneration: '停止生成', running: '运行中', + // Project View Navigation + chat: '聊天', + preview: '预览', + code: '代码', + + // Preview Pane + projectPreview: '项目预览', + buildProjectToSeePreview: '构建您的项目以在此处查看预览', + fileExplorer: '文件浏览器', + fileEditor: '文件编辑器', + selectFileFromExplorer: '从浏览器中选择一个文件进行编辑', + openFileExplorer: '打开文件浏览器', + // File Editor unsavedChanges: '未保存的更改', saving: '保存中...', @@ -754,6 +827,23 @@ const resources = { addAccount: '添加账户', relayConfiguration: '中继配置', selectedRelay: '选定的中继', + + // Clone Page + cloneGitRepository: '将Git仓库克隆到您的Shakespeare工作空间', + pleaseEnterRepositoryUrl: '请输入仓库URL', + pleaseEnterValidGitUrl: '请输入有效的Git仓库URL或Nostr克隆URI(例如:nostr://npub.../仓库名)', + cloningRepository: '正在克隆仓库...', + nostrRepositoryImportedSuccessfully: 'Nostr仓库导入成功', + repositoryClonedFromNostr: '"{{repoName}}"已从Nostr克隆并准备好进行开发。', + repositoryImportedSuccessfully: '仓库导入成功', + repositoryClonedReady: '"{{repoName}}"已克隆并准备好进行开发。', + failedToImportRepository: '导入仓库失败', + repositoryNotFoundOnNostr: '在Nostr网络上未找到仓库。请检查URI并重试。', + noCloneUrlsFound: '找到仓库公告但没有可用的克隆URL。', + allCloneAttemptsFailed: '找到仓库但所有克隆URL都失败了。仓库可能不可用。', + repositoryNotFound: '未找到仓库。请检查URL并重试。', + accessDenied: '访问被拒绝。仓库可能是私有的或需要身份验证。', + networkError: '网络错误。请检查您的连接并重试。', } } }; diff --git a/src/pages/Clone.tsx b/src/pages/Clone.tsx index 7302e845..892b3261 100644 --- a/src/pages/Clone.tsx +++ b/src/pages/Clone.tsx @@ -1,5 +1,6 @@ import { useState, useEffect, useCallback } from 'react'; import { useNavigate, useSearchParams } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; import { AppLayout } from '@/components/AppLayout'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; @@ -20,6 +21,7 @@ interface NostrCloneUri { } export default function Clone() { + const { t } = useTranslation(); const [repoUrl, setRepoUrl] = useState(''); const [isCloning, setIsCloning] = useState(false); const [error, setError] = useState(null); @@ -30,8 +32,8 @@ export default function Clone() { const { nostr } = useNostr(); useSeoMeta({ - title: 'Import Repository - Shakespeare', - description: 'Import a Git repository into your Shakespeare workspace', + title: `${t('importRepository')} - Shakespeare`, + description: t('cloneGitRepository'), }); const extractRepoName = (url: string): string => { @@ -201,14 +203,14 @@ export default function Clone() { const handleClone = useCallback(async (url?: string) => { const targetUrl = url || repoUrl; - + if (!targetUrl.trim()) { - setError('Please enter a repository URL'); + setError(t('pleaseEnterRepositoryUrl')); return; } if (!validateGitUrl(targetUrl)) { - setError('Please enter a valid Git repository URL or Nostr clone URI (e.g., nostr://npub.../repo-name)'); + setError(t('pleaseEnterValidGitUrl')); return; } @@ -236,8 +238,8 @@ export default function Clone() { const project = await tryCloneUrls(cloneUrls, repoName); toast({ - title: "Nostr repository imported successfully", - description: `"${repoName}" has been cloned from Nostr and is ready for development.`, + title: t('nostrRepositoryImportedSuccessfully'), + description: t('repositoryClonedFromNostr', { repoName }), }); // Navigate to the new project @@ -248,8 +250,8 @@ export default function Clone() { const project = await projectsManager.cloneProject(repoName, targetUrl.trim()); toast({ - title: "Repository imported successfully", - description: `"${repoName}" has been cloned and is ready for development.`, + title: t('repositoryImportedSuccessfully'), + description: t('repositoryClonedReady', { repoName }), }); // Navigate to the new project @@ -258,20 +260,20 @@ export default function Clone() { } catch (error) { console.error('Failed to clone repository:', error); - let errorMessage = 'Failed to clone repository'; + let errorMessage = t('failedToImportRepository'); if (error instanceof Error) { if (error.message.includes('Repository not found on Nostr network')) { - errorMessage = 'Repository not found on Nostr network. Please check the URI and try again.'; + errorMessage = t('repositoryNotFoundOnNostr'); } else if (error.message.includes('No clone URLs found')) { - errorMessage = 'Repository announcement found but no clone URLs available.'; + errorMessage = t('noCloneUrlsFound'); } else if (error.message.includes('All clone attempts failed')) { - errorMessage = 'Repository found but all clone URLs failed. The repository may be unavailable.'; + errorMessage = t('allCloneAttemptsFailed'); } else if (error.message.includes('404') || error.message.includes('not found')) { - errorMessage = 'Repository not found. Please check the URL and try again.'; + errorMessage = t('repositoryNotFound'); } else if (error.message.includes('403') || error.message.includes('forbidden')) { - errorMessage = 'Access denied. The repository may be private or require authentication.'; + errorMessage = t('accessDenied'); } else if (error.message.includes('network') || error.message.includes('fetch')) { - errorMessage = 'Network error. Please check your connection and try again.'; + errorMessage = t('networkError'); } else { errorMessage = error.message; } @@ -280,14 +282,14 @@ export default function Clone() { setError(errorMessage); toast({ - title: "Failed to import repository", + title: t('failedToImportRepository'), description: errorMessage, variant: "destructive", }); } finally { setIsCloning(false); } - }, [fetchNostrRepository, navigate, projectsManager, repoUrl, toast, tryCloneUrls, validateGitUrl]); + }, [fetchNostrRepository, navigate, projectsManager, repoUrl, t, toast, tryCloneUrls, validateGitUrl]); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !isCloning) { @@ -301,24 +303,24 @@ export default function Clone() { if (urlParam) { const decodedUrl = decodeURIComponent(urlParam); setRepoUrl(decodedUrl); - + // Automatically start the clone process with the URL directly handleClone(decodedUrl); } }, [handleClone, searchParams]); return ( - +

- Import Repository + {t('importRepository')}

- Clone a Git repository into your Shakespeare workspace + {t('cloneGitRepository')}

@@ -352,12 +354,12 @@ export default function Clone() { {isCloning ? ( <> - Cloning Repository... + {t('cloningRepository')} ) : ( <> - Import Repository + {t('importRepository')} )} diff --git a/src/pages/ProjectView.tsx b/src/pages/ProjectView.tsx index 591f7667..50cfe558 100644 --- a/src/pages/ProjectView.tsx +++ b/src/pages/ProjectView.tsx @@ -1,5 +1,6 @@ import { useState, useEffect, useCallback, useRef } from 'react'; import { useParams } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; import { type Project } from '@/lib/ProjectsManager'; import { useProjectsManager } from '@/hooks/useProjectsManager'; import { ChatPane, type ChatPaneRef } from '@/components/Shakespeare/ChatPane'; @@ -27,6 +28,7 @@ import { useToast } from "@/hooks/useToast"; export function ProjectView() { const { projectId } = useParams<{ projectId: string }>(); + const { t } = useTranslation(); const [project, setProject] = useState(null); const [isLoading, setIsLoading] = useState(true); const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview'); @@ -318,7 +320,7 @@ export function ProjectView() { disabled={!project} > - Chat + {t('chat')}