mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Translate more pages
This commit is contained in:
4 files changed
+133
-37
No files matched your search
@@ -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<string | null>(null);
|
||||
const [fileContent, setFileContent] = useState<string>('');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -376,9 +378,9 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
) : (
|
||||
<div className="h-full flex items-center justify-center bg-muted">
|
||||
<div className="text-center">
|
||||
<h3 className="text-lg font-semibold mb-2">Project Preview</h3>
|
||||
<h3 className="text-lg font-semibold mb-2">{t('projectPreview')}</h3>
|
||||
<p className="text-muted-foreground mb-4">
|
||||
Build your project to see the preview here
|
||||
{t('buildProjectToSeePreview')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -392,7 +394,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
<>
|
||||
<div className="p-3 border-b bg-gradient-to-r from-primary/5 to-accent/5">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">File Explorer</h3>
|
||||
<h3 className="font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">{t('fileExplorer')}</h3>
|
||||
<GitStatusIndicator projectId={projectId} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -419,7 +421,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
<h3 className="font-semibold flex-1 truncate bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
{selectedFile ? selectedFile.split('/').pop() : 'File Editor'}
|
||||
{selectedFile ? selectedFile.split('/').pop() : t('fileEditor')}
|
||||
</h3>
|
||||
<GitStatusIndicator projectId={projectId} />
|
||||
</div>
|
||||
@@ -437,7 +439,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
<div className="text-center">
|
||||
<FolderOpen className="h-12 w-12 mx-auto text-muted-foreground mb-4" />
|
||||
<p className="text-muted-foreground">
|
||||
Select a file from the explorer to edit
|
||||
{t('selectFileFromExplorer')}
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
@@ -445,7 +447,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
onClick={() => setMobileCodeView('explorer')}
|
||||
className="mt-4"
|
||||
>
|
||||
Open File Explorer
|
||||
{t('openFileExplorer')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -459,7 +461,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
<div className="w-1/3 border-r">
|
||||
<div className="p-4 border-b bg-gradient-to-r from-primary/5 to-accent/5">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">File Explorer</h3>
|
||||
<h3 className="font-semibold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">{t('fileExplorer')}</h3>
|
||||
<GitStatusIndicator projectId={projectId} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -488,7 +490,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
|
||||
<div className="h-full flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<p className="text-muted-foreground">
|
||||
Select a file from the explorer to edit
|
||||
{t('selectFileFromExplorer')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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: '网络错误。请检查您的连接并重试。',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+26
-24
@@ -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<string | null>(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 (
|
||||
<AppLayout title="Import Repository">
|
||||
<AppLayout title={t('importRepository')}>
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<div className="text-center mb-8">
|
||||
<div className="text-4xl mb-4">
|
||||
<GitBranch className="h-12 w-12 mx-auto text-primary" />
|
||||
</div>
|
||||
<h1 className="text-3xl font-bold mb-3 bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
|
||||
Import Repository
|
||||
{t('importRepository')}
|
||||
</h1>
|
||||
<p className="text-lg text-muted-foreground">
|
||||
Clone a Git repository into your Shakespeare workspace
|
||||
{t('cloneGitRepository')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -352,12 +354,12 @@ export default function Clone() {
|
||||
{isCloning ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
Cloning Repository...
|
||||
{t('cloningRepository')}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<GitBranch className="mr-2 h-4 w-4" />
|
||||
Import Repository
|
||||
{t('importRepository')}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
@@ -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<Project | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [activeTab, setActiveTab] = useState<'preview' | 'code'>('preview');
|
||||
@@ -318,7 +320,7 @@ export function ProjectView() {
|
||||
disabled={!project}
|
||||
>
|
||||
<MessageSquare className="h-4 w-4 mr-1" />
|
||||
Chat
|
||||
{t('chat')}
|
||||
</Button>
|
||||
<Button
|
||||
variant={mobileView === 'preview' ? 'default' : 'ghost'}
|
||||
@@ -328,7 +330,7 @@ export function ProjectView() {
|
||||
disabled={!project}
|
||||
>
|
||||
<Eye className="h-4 w-4 mr-1" />
|
||||
Preview
|
||||
{t('preview')}
|
||||
</Button>
|
||||
<Button
|
||||
variant={mobileView === 'code' ? 'default' : 'ghost'}
|
||||
@@ -338,7 +340,7 @@ export function ProjectView() {
|
||||
disabled={!project}
|
||||
>
|
||||
<Code className="h-4 w-4 mr-1" />
|
||||
Code
|
||||
{t('code')}
|
||||
{mobileView !== 'code' && project && (
|
||||
<GitStatusIndicator projectId={project.id} className="ml-1" />
|
||||
)}
|
||||
@@ -492,7 +494,7 @@ export function ProjectView() {
|
||||
onClick={() => setActiveTab('preview')}
|
||||
disabled={!project}
|
||||
>
|
||||
Preview
|
||||
{t('preview')}
|
||||
</Button>
|
||||
<Button
|
||||
variant={activeTab === 'code' ? 'default' : 'ghost'}
|
||||
@@ -501,7 +503,7 @@ export function ProjectView() {
|
||||
className="gap-2"
|
||||
disabled={!project}
|
||||
>
|
||||
Code
|
||||
{t('code')}
|
||||
{activeTab !== 'code' && project && (
|
||||
<GitStatusIndicator projectId={project.id} />
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user